1

I want to automate several users login with different credentials on the web page. I wrote code in JMeter with Selenium. I want to read usernames and passwords from an CSV file. For that I want to pass a JMeter variable in my code because I need it to be dynamic.

for example:

findElement(By.name("username")).sendKeys(${username}) <- here I want to pass JMeter variable

WDS.sampleResult.sampleStart()

WDS.browser.get('https://www.google.com/')

WDS.browser.findElement(org.openqa.selenium.By.name("q")).
sendKeys(**${here I want to put JMeter variable}**)

WDS.sampleResult.sampleEnd()

Could you please advise me on the best approach here?

1 Answer 1

2

There is WDS.vars shorthand which maps to JMeterVariables class instance so you can use it for getting JMeter Variables values

findElement(By.name("username")).sendKeys(WDS.vars.get("username")) <- here I want to pass JMeter variable

WDS.sampleResult.sampleStart()

WDS.browser.get('https://www.google.com/')

WDS.browser.findElement(org.openqa.selenium.By.name("q")).
sendKeys(WDS.vars.get("your_jmeter_variable_name"))

WDS.sampleResult.sampleEnd() 

More information:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.