[英]Error in method invocation when executing java scripts in selenium using jmeter
I'm getting following error while try to execute the java script within my selenium code. 尝试在我的硒代码中执行Java脚本时遇到以下错误。
Error: Response message: javax.script.ScriptException: Sourced file: inline evaluation of: import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : Typed variable declaration : Error in method invocation: Method executeScript( java.lang.String ) not found in class'org.openqa.selenium.htmlunit.HtmlUnitDriver' : at Line: 47 : in file: inline evaluation of:
错误:响应消息:javax.script.ScriptException:源文件:内联评估:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : Typed variable declaration : Error in method invocation: Method executeScript( java.lang.String ) not found in class'org.openqa.selenium.htmlunit.HtmlUnitDriver' : at Line: 47 : in file: inline evaluation of:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : Typed variable declaration : Error in method invocation: Method executeScript( java.lang.String ) not found in class'org.openqa.selenium.htmlunit.HtmlUnitDriver' : at Line: 47 : in file: inline evaluation of:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : Typed variable declaration : Error in method invocation: Method executeScript( java.lang.String ) not found in class'org.openqa.selenium.htmlunit.HtmlUnitDriver' : at Line: 47 : in file: inline evaluation of:
import org.openqa.selenium.By; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org. . . . '' : Typed variable declaration : Error in method invocation: Method executeScript( java.lang.String ) not found in class'org.openqa.selenium.htmlunit.HtmlUnitDriver' : at Line: 47 : in file: inline evaluation of:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; 导入org.openqa.selenium.WebDriver; import org.
导入组织。 .
。 .
。 .
。 '' : executor .executeScript ( "document.getElementById('icon-2')[0].click()" ) in inline evaluation of: ``import org.openqa.selenium.By;
'':执行器.executeScript(“ document.getElementById('icon-2')[0] .click()”)的内联评估:``import org.openqa.selenium.By; import org.openqa.selenium.WebDriver;
导入org.openqa.selenium.WebDriver; import org.
导入组织。 .
。 .
。 .
。 '' at line number 47
''在第47行
Response headers: 响应头:
Code: 码:
public HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME,true);
JavascriptExecutor executor = (JavascriptExecutor)driver;
driver.get(appURL);
executor.executeScript("document.getElementById('icon-2')[0].click()");
How do I execute the java script within selenium? 如何在Selenium中执行Java脚本?
Page dom structure : 页面dom结构:
It seems that Beanshell interpreter doesn't support varargs therefore your attempt to call executeScript() method whose 2nd parameter is java.lang.Object... args
is failing. 似乎Beanshell解释器不支持varargs,因此您尝试调用其第二个参数为
java.lang.Object... args
executeScript()方法失败。
The easiest solution is switching to Groovy language as: 最简单的解决方案是按以下方式切换到Groovy语言:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.