Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

514
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda