java - javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: driver for class: Script1 -
script written in jsr223 + groovy sampler in jmeter load testing. when run code multiple threads(users) of them passed , other failed , shows error message:
javax.script.scriptexception: groovy.lang.missingpropertyexception: no such property: driver class: script1
import org.openqa.selenium.by import org.openqa.selenium.javascriptexecutor import org.openqa.selenium.phantomjs.phantomjsdriver import org.openqa.selenium.phantomjs.phantomjsdriverservice import org.openqa.selenium.remote.desiredcapabilities import org.openqa.selenium.support.ui.expectedconditions import org.openqa.selenium.support.ui.webdriverwait boolean result=true; try { file src=new file("projects\\phantomjs.exe"); system.setproperty("phantomjs.binary.path", src.getabsolutepath()); driver=new phantomjsdriver(); driver.manage().window().maximize(); driver.get("https://rx.vurvhealth.com/vurv_server/"); webdriverwait wait = new webdriverwait(driver, 50000); string uname= args[0]; string pass= args[1]; string drug= args[2]; string zip= args[3]; // logged in driver.findelement(by.xpath("//*[contains(@id,'menu-item')]//*[text()='login']")).click(); wait.until(expectedconditions.visibilityofallelementslocatedby(by.id("username"))); driver.findelement(by.id("username")).sendkeys(uname); driver.findelement(by.id("password")).sendkeys(pass); driver.findelement(by.xpath("//*[@id='woocommerce-login-nonce']/following-sibling::*[@name='login']")).click(); // prescription search driver.findelement(by.cssselector(".dropdown-toggle")).click(); wait.until(expectedconditions.visibilityofallelementslocatedby(by.id("drug_name"))); driver.findelement(by.id("drug_name")).sendkeys(drug); driver.findelement(by.id("location")).sendkeys(zip); ((javascriptexecutor)driver).executescript("arguments[0].click()",driver.findelement(by.id("btnsearch"))); // logged out wait.until(expectedconditions.visibilityofallelementslocatedby(by.cssselector(".header-logged-in>a"))); ((javascriptexecutor)driver).executescript("arguments[0].click()",driver.findelement(by.xpath("//*[@id='masthead']//*[text()='sign out']"))); wait.until(expectedconditions.visibilityofallelementslocatedby(by.id("username"))); } catch (exception ex) { ex.printstacktrace(); log.error(ex.getmessage()); sampleresult.setsuccessful(false); sampleresult.setresponsecode("500"); sampleresult.setresponsemessage(ex.getmessage()); } catch (throwable thex) { thex.printstacktrace(); } { driver.close(); } sampleresult.setsuccessful(result); return result;
error message:::
javax.script.scriptexception: groovy.lang.missingpropertyexception: no such property: driver class: script2 @ org.codehaus.groovy.jsr223.groovyscriptengineimpl.eval(groovyscriptengineimpl.java:320) ~[groovy-all-2.4.10.jar:2.4.10] @ org.codehaus.groovy.jsr223.groovycompiledscript.eval(groovycompiledscript.java:72) ~[groovy-all-2.4.10.jar:2.4.10] @ javax.script.compiledscript.eval(unknown source) ~[?:1.8.0_40] @ org.apache.jmeter.util.jsr223testelement.processfileorscript(jsr223testelement.java:220) ~[apachejmeter_core.jar:3.2 r1790748] @ org.apache.jmeter.protocol.java.sampler.jsr223sampler.sample(jsr223sampler.java:69) [apachejmeter_java.jar:3.2 r1790748] @ org.apache.jmeter.threads.jmeterthread.executesamplepackage(jmeterthread.java:491) [apachejmeter_core.jar:3.2 r1790748] @ org.apache.jmeter.threads.jmeterthread.processsampler(jmeterthread.java:425) [apachejmeter_core.jar:3.2 r1790748] @ org.apache.jmeter.threads.jmeterthread.run(jmeterthread.java:254) [apachejmeter_core.jar:3.2 r1790748] @ java.lang.thread.run(unknown source) [?:1.8.0_40] caused by: groovy.lang.missingpropertyexception: no such property: driver class: script2 @ org.codehaus.groovy.runtime.scriptbytecodeadapter.unwrap(scriptbytecodeadapter.java:53) ~[groovy-all-2.4.10.jar:2.4.10] @ org.codehaus.groovy.runtime.callsite.pogogetpropertysite.getproperty(pogogetpropertysite.java:52) ~[groovy-all-2.4.10.jar:2.4.10] @ org.codehaus.groovy.runtime.callsite.abstractcallsite.callgroovyobjectgetproperty(abstractcallsite.java:307) ~[groovy-all-2.4.10.jar:2.4.10] @ script2.run(script2.groovy:73) ~[?:?] @ org.codehaus.groovy.jsr223.groovyscriptengineimpl.eval(groovyscriptengineimpl.java:317) ~[groovy-all-2.4.10.jar:2.4.10] ... 8 more
thanks in advance!!
the problem here:
driver=new phantomjsdriver();
you attempting assign variable driver
new instance of phantomjsdriver
without first declaring variable type. should be:
phantomjsdriver driver = new phantomjsdriver();
hope helps.
wiki
Comments
Post a Comment