Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

507
Views
How to extract variable from jmeter selenium webdriver

I have a token thats being returned in the body.

WDS.browser.findElement(org.openqa.selenium.By.xpath("//*[contains(@name,'RequestVerificationToken')]")).getText();

This is the token I'm trying to extract:

enter image description here

Now what im trying to do is to pass that variable out of the selenium webdriver to the rest of the threads.

Usually when im working with normal pages I go for regular expression extractor as a post processor and set to a variable then correlate it but Im not sure where to go here.

How do I make it a global variable in JS?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can consider the complete value of the name attribute. Additionally, the token is actually the value attribute, so you have to use getAttribute("value") instead as follows:

WDS.browser.findElement(org.openqa.selenium.By.xpath("//input[@name='__RequestVerificationToken']")).getAttribute("value");
about 4 years ago · Santiago Trujillo Report

0

The element you want to interact with doesn't have text, what you need is value attribute so you need to amend your code as:

var token = WDS.browser.findElement(org.openqa.selenium.By.xpath("//*[contains(@name,'RequestVerificationToken')]")).getAttribute('value')

If you want to share this token with all threads in this or other Thread Groups you can save it into a JMeter Property like:

WDS.props.put('token', token)

so in other WebDriver Samplers instances you will be able to access it as:

var token = WDS.props.get('token')

and in other JMeter test elements it will be possible to use __P() function like:

${__P(token,)}

More information: The WebDriver Sampler: Your Top 10 Questions Answered

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!