Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
900 views
in Technique[技术] by (71.8m points)

selenium - How to pass variable in Webdriver-Sampler | Jmeter Webdriver

I got a Testscript with more than 8 Webdriver-Sampler and a variable, which change in some of the Webdriver-Sampler.

For Example:

First Sampler: status = "login successful"

Second Sampler: status = "login successful, search for something failed"

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 Sampler Demo

See The WebDriver Sampler: Your Top 10 Questions Answered guide for more WebDriver Sampler tips and tricks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...