如何在Webdriver-Sampler中传递变量Jmeter Webdriver [英] How to pass variable in Webdriver-Sampler | Jmeter Webdriver
问题描述
我得到了一个Testscript,其中包含8个以上的Webdriver-Sampler和一个变量,这些变量在某些Webdriver-Sampler中有所变化.
I got a Testscript with more than 8 Webdriver-Sampler and a variable, which change in some of the Webdriver-Sampler.
例如:
第一个采样器: 状态=登录成功"
First Sampler: status = "login successful"
第二个采样器: status =登录成功,搜索失败"
Second Sampler: status = "login successful, search for something failed"
第三次采样器: status =登录成功,搜索失败,注销成功"
Third Sampler: status = "login successful, search for something failed, logout successful"
因此,我必须每次都传递变量,然后编辑该变量. 我知道可以传递有关参数字段的变量.但是,如何在脚本中编辑用户定义变量?
So I have to pass the variable everytime and then edit this variable. I know it is possible to pass a varibale about the Parameter-field. But how can I edit a user define variable in script?
推荐答案
您可以访问 JMeterVariables 类实例,通过
You can access JMeterVariables class instance via JMeterContext.getVariables() method like:
var vars = org.apache.jmeter.threads.JMeterContextService.getContext().getVariables()
vars.put('foo','bar')
var foo = vars.get('foo')
//etc
请参见 WebDriver采样器:您回答的十大问题有关更多WebDriver Sampler提示和技巧的指南
See The WebDriver Sampler: Your Top 10 Questions Answered guide for more WebDriver Sampler tips and tricks
这篇关于如何在Webdriver-Sampler中传递变量Jmeter Webdriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!