如何在Jmeter-webdriver.plugin中使用ACTIONSclass。 - Webdriver 采样器。
How to use ACTIONS class in Jmeter-webdriver.plugin. - Webdriver Sampler.?
正在使用 Jmeter-WebDriver.plugin。 Webdriver 采样器。
我在执行脚本时遇到焦点问题(光标未移动到可编辑字段)。所以想通过 Webdriver 的操作单击该字段。
这是我的代码:-
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
应该是这样的:
var actions = new org.openqa.selenium.interactions.Actions(WDS.browser)
// do what you need with actions
在 JMeter Plugins 项目主页演示双击 JMeter 徽标的完整代码:
WDS.sampleResult.sampleStart()
WDS.browser.get('http://jmeter-plugins.org')
var jmeterLogo = WDS.browser.findElement(org.openqa.selenium.By.xpath("//img[@alt='Apache JMeter']"))
var actions = new org.openqa.selenium.interactions.Actions(WDS.browser)
actions.moveToElement(jmeterLogo).doubleClick().perform()
WDS.sampleResult.sampleEnd()
有关 JMeter 和 Selenium 集成的更多信息,请参阅 The WebDriver Sampler: Your Top 10 Questions Answered 文章
正在使用 Jmeter-WebDriver.plugin。 Webdriver 采样器。
我在执行脚本时遇到焦点问题(光标未移动到可编辑字段)。所以想通过 Webdriver 的操作单击该字段。
这是我的代码:-
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
应该是这样的:
var actions = new org.openqa.selenium.interactions.Actions(WDS.browser)
// do what you need with actions
在 JMeter Plugins 项目主页演示双击 JMeter 徽标的完整代码:
WDS.sampleResult.sampleStart()
WDS.browser.get('http://jmeter-plugins.org')
var jmeterLogo = WDS.browser.findElement(org.openqa.selenium.By.xpath("//img[@alt='Apache JMeter']"))
var actions = new org.openqa.selenium.interactions.Actions(WDS.browser)
actions.moveToElement(jmeterLogo).doubleClick().perform()
WDS.sampleResult.sampleEnd()
有关 JMeter 和 Selenium 集成的更多信息,请参阅 The WebDriver Sampler: Your Top 10 Questions Answered 文章