Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

508
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda