如何在Jmeter-webdriver.plugin中使用ACTIONS类。 - Webdriver Sampler。?

时间:2016-12-20 09:24:10

标签: java webdriver performance-testing jmeter-plugins

使用Jmeter-WebDriver.plugin。 Webdriver采样器。

我在执行脚本时遇到焦点问题(光标未移动到可编辑字段)。所以想要通过Webdriver的Action点击该字段。

这是我的代码: -

var pkg = JavaImporter(org.openqa.selenium)
var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
var wait = new support_ui.WebDriverWait(WDS.browser, 5000)

WDS.sampleResult.sampleStart()
WDS.browser.get('')
WDS.browser.findElement(pkg.By.id('vxcvc')).sendKeys(['nabsnba'])
WDS.browser.findElement(pkg.By.id('CenPxcv_Password')).sendKeys(['fraxdy5'])

WDS.browser.findElement(pkg.By.cssSelector('.mdl-button__ripple-container')).click()


var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
var wait = new support_ui.WebDriverWait(WDS.browser, 50000)


WDS.browser.findElement(pkg.By.id('sdsdsdsd')).sendKeys(['sdfdsf'])    // On this  line  getting error 

错误是: -

2016/12/19 18:54:59 ERROR - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: unknown error: cannot focus element
  (Session info: chrome=55.0.2883.87)
  (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'ETPUN-DT009', ip: '192.168.254.13', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed), userDataDir=}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=55.0.2883.87, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: e71dd9ad489a2728c289cde547a77105

1 个答案:

答案 0 :(得分:1)

应该是这样的:

db.stuff.aggregate([{
  $unwind: { "$bar" },
  $group: {
    _id: null, 
    bar: {
      $addToSet: "$bar"
    }
  }
}])

=> { "_id" : null, "bar" : [ 4, 3, 5, 2, 6, 1 ] }

完整代码演示了JMeter Plugins项目主页上的JMeter徽标双击:

var actions = new org.openqa.selenium.interactions.Actions(WDS.browser)
// do what you need with actions

有关JMeter和Selenium集成的更多信息,请参阅The WebDriver Sampler: Your Top 10 Questions Answered文章