简体   繁体   English

使用Jmeter的selenium webdriver插件时,我的选择器或操作代码似乎不起作用

[英]While using Jmeter's selenium webdriver addon, my selector or action code doesn't seem to be working

I'm picking up someone's JMeter project at work and attempting to add some extra code to it for some extra functionality. 我正在工作中找到某个人的JMeter项目,并试图为它添加一些额外的代码以获得一些额外的功能。 It should be simple, since all I want to do is login. 它应该很简单,因为我想要做的就是登录。 But I can't seem to send the text to the text fields. 但我似乎无法将文本发送到文本字段。 I then tried an even simpler one by going to google and just searching for something, and then an even simpler one of just clicking the gmail link. 然后,我尝试了一个更简单的方法,去谷歌搜索一些东西,然后更简单的点击gmail链接。 None of these happen though. 但这些都不会发生。 It goes to the website, but then seems to ignore the code below that. 它进入了网站,但似乎忽略了下面的代码。

WDS.sampleResult.sampleStart()
WDS.browser.get('http://www.google.com')
var searchField = WDS.browser.findElement(pkg.By.linkText('Gmail')); //saves 
search field into searchField
searchField.click(); //clicks search field
WDS.sampleResult.sampleEnd()

WDS.sampleResult.sampleStart()
WDS.browser.get('http://www.google.com')
var searchField = WDS.browser.findElement(pkg.By.title('Search')); //saves 
search field into searchField
searchField.click(); //clicks search field
searchField.sendKeys(['blazemeter']);
WDS.sampleResult.sampleEnd()

I've tried the second one with sendkeys('blazmeter') and with the brackets as above. 我用sendkeys('blazmeter')和上面的括号尝试了第二个。

What am I doing wrong? 我究竟做错了什么?

Edit: This is using Chromedriver by the way. 编辑:顺便说一句,这是使用Chromedriver。

If this is your full code then pkg is not defined, it breaks on the line where you call it first time. 如果这是您的完整代码,则未定义pkg ,它会在您第一次调用它的行中断。

JMeter WebDriver错误

So either define it like: 所以要么定义它:

var pkg = JavaImporter(org.openqa.selenium)

Or use the following workaround: 或使用以下解决方法:

var searchField = WDS.browser.findElement(org.openqa.selenium.By.linkText('Gmail'))

References: 参考文献:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM