问题描述
我在JMeter中遇到了Webdriver Sampler的问题.我想在JSR233中定义一些函数,然后从其他线程组中调用它们.但是我不知道如何将WDS用作Webdriver Sampler.
I experienced the issue with Webdriver Sampler in JMeter. I would like to define some functions in JSR233, then call them from the other Thread Groups. But I don't know how to use WDS as Webdriver Sampler.
测试计划如下:
- 测试计划
- setUp线程组
- JSR233采样器(定义功能)
- Test Plan
- setUp Thread Group
- JSR233 Sampler (define function)
- Webdriver Sampler A(来自JSR233的调用函数)
- Webdriver采样器B
还有我定义的函数,如下所示:
And the function which I defined, like this:
var WDS = com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverScriptable; var getBroswer = WDS.browser.get('http://www.google.com.vn');
但是我得到了错误
2016/07/06 16:19:06 WARN - jmeter.protocol.java.sampler.BSFSampler: BSF error org.apache.bsf.BSFException: JavaScript Error: Java class "com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverScriptable" has no public instance field or method named "browser". 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)
所以,我的问题是,当我在BSF,JSR233中定义函数时,如何使用
WDS
以及WDS.browser
?So, my question is, how to use
WDS
, alsoWDS.browser
when I define function in BSF,JSR233?我认为这些问题的解决方法是相同的:
I think the way to do is the same these questions:
- 如何从WebDriver Sampler(JMeter)中使用JMeter Property props.get props.put
- 如何在Webdriver-Sampler中传递变量| Jmeter Webdriver
- 如何在WebDriver Sampler中设置JMeter Vars? /a>
- How to use JMeter Property props.get props.put from WebDriver Sampler (JMeter)
- How to pass variable in Webdriver-Sampler | Jmeter Webdriver
- How to set JMeter Vars from within WebDriver Sampler?
有人可以帮助我吗?预先感谢.
Can anyone please help me? Thanks in advance.
推荐答案
我认为您无法在不同的线程组之间共享BSF功能,请考虑使用 Beanshell测试元素和 bsh.shared命名空间.
I don't think you'll be able to share BSF functions across different Thread Groups, consider using Beanshell Test Elements and bsh.shared namespace instead.
这篇关于如何在BSF或JSR233(JMeter)中使用WDS变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
- setUp Thread Group
- setUp线程组