Paili
Paili

Reputation: 845

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?

Upvotes: 1

Views: 5542

Answers (1)

Dmitri T
Dmitri T

Reputation: 168072

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

Upvotes: 8

Related Questions