Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
917 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 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...