I want to measure performance of a Web page in real time. So, got the 1st option of JMeter with Selenium.
I am able to do some navigations and click operations using JSR223 sampler in Java.
But, while waiting for all the JQuery and DOM ready state, I am failed to do in Javascript Executor(org.openqa.selenium.JavascriptExecutor). Below is my code of Wait statements.
setStrictJava(false);
/*
---some block of code---
*/
while(true){
Boolean isAjaxCompletes = (Boolean) ((JavascriptExecutor)driver).executeScript("return jQuery.active == 0;");
Boolean isJsLoaded = ((JavascriptExecutor)driver).executeScript("return document.readyState;").toString().equals("complete");
if(isAjaxCompletes && isJsLoaded){
break;
}
}
I am getting the below error:
2018-04-02 18:39:33,794 ERROR o.a.j.p.j.s.JSR223Sampler: Problem in JSR223 script JSR223 Sampler, message: javax.script.ScriptException: Sourced file: inline evaluation of: ``import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; impor . . . '' : Error in method invocation: Static method executeScript( java.lang.String ) not found in class'org.openqa.selenium.JavascriptExecutor' : at Line: 36 :
in file: inline evaluation of: ``import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; impor . . . '' : JavascriptExecutor .executeScript ( "return jQuery.active == 0;" )
in inline evaluation of: ``import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; impor . . . '' at line number 36
javax.script.ScriptException: Sourced file: inline evaluation of: ``import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; impor . . . '' : Error in method invocation: Static method executeScript( java.lang.String ) not found in class'org.openqa.selenium.JavascriptExecutor' : at Line: 36 : in file: inline evaluation of: ``import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; impor . . . '' : JavascriptExecutor .executeScript ( "return jQuery.active == 0;" )
in inline evaluation of: ``import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; impor . . . '' at line number 36
at bsh.engine.BshScriptEngine.evalSource(BshScriptEngine.java:93) ~[bsh-2.0b6.jar:2.0b6 2016-02-05 05:16:19]
at bsh.engine.BshScriptEngine.eval(BshScriptEngine.java:46) ~[bsh-2.0b6.jar:2.0b6 2016-02-05 05:16:19]
at javax.script.AbstractScriptEngine.eval(Unknown Source) ~[?:1.8.0_151]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:223) ~[ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:69) [ApacheJMeter_java.jar:4.0 r1823414]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:490) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:416) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250) [ApacheJMeter_core.jar:4.0 r1823414]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_151]
Kindly help me to solve this.
JMeter version: 4.0
Plugins auto downloaded selenium version: 2.52.0
Java: 1.8, update 151