Many thanks Andrey Pokhilko,
I just wanna use WDS for define some functions, then call those function from Webdriver Sampler. So, can I call the API to use that variable WDS in the other places, such as BSF/BeanShell/JSR233?
If I define the function in Webdriver Sampler, it works well, but my test plan has many Thread Groups, so when one of the Thread Group end, the webdriver will be closed and functions will not be effected anymore. That's why I have to define function in BSF/BeanShell/JSR233.
My function in BSF Sampler (in 1st Thread Group) like this:
var Sampler = com.googlecode.jmeter.plugins.webdriver.sampler;
var WDS = new Sampler.WebDriverSampler.createScriptEngineWith();
function Command() {
this.URL = function (URL){
return WDS.browser.get(URL);
}
}
var command = new Command();
props.put("COMMAND", command);
And in my Webdriver Sampler (2nd Thread Group), I call that function
var props = org.apache.jmeter.util.JMeterUtils.getJMeterProperties();
var command = props.get("COMMAND");
command.URL('http://www.google.com')
But it didn't work, and show error in BSF Sampler:
2016/07/07 23:24:39 WARN - jmeter.protocol.java.sampler.BSFSampler: BSF error org.apache.bsf.BSFException: JavaScript Error: Java class "com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler" has no public instance field or method named "createScriptEngineWith".
at org.apache.jmeter.util.BSFJavaScriptEngine.handleError(BSFJavaScriptEngine.java:202)
at org.apache.jmeter.util.BSFJavaScriptEngine.eval(BSFJavaScriptEngine.java:152)
at org.apache.jmeter.protocol.java.sampler.BSFSampler.sample(BSFSampler.java:98)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:465)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:410)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:241)
at java.lang.Thread.run(Thread.java:745)
Can you help me, what api should I call to use the variable WDS?
Thanks,