简体   繁体   English

在类中找不到JMETER Beanshell(java.lang.String)

[英]JMETER Beanshell ( java.lang.String ) not found in class

I am developing a Jmeter beanshell script to work with Selenium. 我正在开发一个Jmeter beanshell脚本来使用Selenium。 I decided to use the beanshell sampler so i can use java and selenium commands not accessible in the WDS interface. 我决定使用beanshell采样器,因此我可以使用WDS界面中无法访问的java和selenium命令。

My code work fine except for some String inputs. 我的代码工作正常,除了一些String输入。 Here is a sample (torn down to barebones): 这是一个样本(拆除为准系统):

import org.openqa.selenium.chrome.ChromeOptions;

ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");

and i get this error 我得到这个错误

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

I see this similar in some other commands like sendkeys. 我在sendkeys等其他命令中看到了这一点。

Why is this command not taking my String? 为什么这个命令不带我的字符串? I can run the full script and the browser opens file so i know selenium is setup with jmeter. 我可以运行完整的脚本,浏览器打开文件,所以我知道selenium是用jmeter设置的。 It is just certain commands that use Strings that do this. 只是某些命令使用字符串来执行此操作。

Thanks J 谢谢J

Depending on your Selenium client libraries version you may not have this method taking single String as a parameter. 根据您的Selenium客户端库版本,您可能没有此方法将单个String作为参数。 Create a new Beanshell Sampler with the following line: 使用以下行创建一个新的Beanshell Sampler

log.info(javap(org.openqa.selenium.chrome.ChromeOptions));

And look into JMeter console: you will see javap command printing out all the available methods for the ChromeOptions class, for instance for my installation (I have WebDriver Sampler plugin) it outputs the following: 并查看JMeter控制台:您将看到javap命令打印出ChromeOptions类的所有可用方法,例如我的安装(我有WebDriver Sampler插件),它输出以下内容:

Class class org.openqa.selenium.chrome.ChromeOptions extends class java.lang.Object 类class org.openqa.selenium.chrome.ChromeOptions扩展了类java.lang.Object

public boolean org.openqa.selenium.chrome.ChromeOptions.equals(java.lang.Object) public boolean org.openqa.selenium.chrome.ChromeOptions.equals(java.lang.Object)

public int org.openqa.selenium.chrome.ChromeOptions.hashCode() public int org.openqa.selenium.chrome.ChromeOptions.hashCode()

public void org.openqa.selenium.chrome.ChromeOptions. public void org.openqa.selenium.chrome.ChromeOptions。 addArguments(java.lang.String[]) addArguments(java.lang.String中[])

public void org.openqa.selenium.chrome.ChromeOptions. public void org.openqa.selenium.chrome.ChromeOptions。 addArguments(java.util.List) addArguments(java.util.List中)

If you use the same Selenium libraries version (2.52.0) as I do you should change this line: 如果你像我一样使用相同的Selenium库版本(2.52.0),你应该改变这一行:

options.addArguments("start-maximized");

to this one: 到这一个:

options.addArguments(new String[] {"start-maximized"});

And your script should start working as expected. 并且您的脚本应该按预期开始工作。

See How to Use BeanShell: JMeter's Favorite Built-in Component article for more information on Beanshell scripting in JMeter tests. 有关JMeter测试中Beanshell脚本的更多信息,请参见如何使用BeanShell:JMeter最喜欢的内置组件文章。

暂无
暂无

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

相关问题 JMeter - 在类&#39;java.nio.file.Paths&#39;中找不到静态方法get(java.lang.String) - JMeter - Static method get( java.lang.String ) not found in class'java.nio.file.Paths' 找不到JSP方法:类java.lang.String - JSP Method not found: class java.lang.String 类需要一个找不到的“java.lang.String”类型的 bean - Class required a bean of type 'java.lang.String' that could not be found 在java.lang.Class中找不到错误getMethod(java.lang.String,java.lang.Class,java.lang.Class) - Error getMethod(java.lang.String,java.lang.Class,java.lang.Class) not found in java.lang.Class 找到不兼容的类型:java.lang.String - incompatible types found : java.lang.String 数组必需,但找到java.lang.String - Array Required, but java.lang.String found 复制文件时,JMeter Bean Shell采样器错误“在类&#39;java.nio.file.Paths中找不到静态方法get(java.lang.String)” - JMeter Bean Shell Sampler error “…Static method get( java.lang.String ) not found in class'java.nio.file.Paths” when copying files 在 java.util.Arrays 类中找不到静态方法 asList( java.lang.String ) - Static method asList( java.lang.String ) not found in the java.util.Arrays class 预期的数组类型; 找到:'java.util.map<java.lang.string,java.lang.string> '</java.lang.string,java.lang.string> - Array type expected; found: 'java.util.map<java.lang.String,java.lang.String>' 数组是必需的,但是找到了java.lang.String Java类数组错误 - array required, but java.lang.String found Java Class Array Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM