【发布时间】:2017-04-03 12:28:44
【问题描述】:
我正在开发一个 Jmeter beanshell 脚本来使用 Selenium。我决定使用 beanshell 采样器,这样我就可以使用在 WDS 界面中无法访问的 java 和 selenium 命令。
我的代码工作正常,除了一些字符串输入。这是一个示例(分解为准系统):
import org.openqa.selenium.chrome.ChromeOptions;
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
我得到了这个错误
2017/03/31 13:43:21 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.openqa.selenium.chrome.ChromeOptions; debug(); ChromeOptions options . . . '' : Error in method invocation: Method addArguments( java.lang.String ) not found in class'org.openqa.selenium.chrome.ChromeOptions' 2017/03/31 13:43:21 WARN - jmeter.protocol.java.sampler.BeanShellSampler: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.openqa.selenium.chrome.ChromeOptions; debug(); ChromeOptions options . . . '' : Error in method invocation: Method addArguments( java.lang.String ) not found in class'org.openqa.selenium.chrome.ChromeOptions' 201
我在 sendkeys 等其他一些命令中看到了类似的情况。
为什么这个命令不接受我的字符串?我可以运行完整的脚本并且浏览器打开文件,所以我知道 selenium 是用 jmeter 设置的。只是某些使用字符串的命令执行此操作。
谢谢 J
【问题讨论】:
-
您是如何将 Selenium 类添加到 JMeter 类路径的?
-
它不起作用,除非您正确映射硒罐。我建议您使用网络驱动程序采样器。 Beanshell 并不容易获得更好的性能。
标签: java selenium jmeter beanshell