Karunagara
Karunagara

Reputation: 389

How to pass parameter from Selenium Webdriver to JMeter?

I need your guidance for passing username and password from Selenium Script to JMeter. Here's the scenario..

There is a CSV file which contains list of user names and passwords. In Selenium Webdriver, I have written a script for logging to my web application.

The script should take the user name and password from JMeter wherein CSV Config File is used as an external data source (where the list of usernames and passwords present).

How do we do this?

Thanks,
Karunagara Pandi

Upvotes: 3

Views: 4168

Answers (1)

Dmitri T
Dmitri T

Reputation: 168002

Given that you have defined variables as ${username} and ${password} you have 2 options:

Option 1: provide aforementioned variables via "Parameters" section and access them via WDS.args[0] and WDS.args[1] like in the below screenshot

WDS args

Alternatively you can get username and password from JMeter Variables as:

var vars = org.apache.jmeter.threads.JMeterContextService.getContext().getVariables()

var username = vars.get('username')
var password = vars.get('password')

See The WebDriver Sampler: Your Top 10 Questions Answered guide for more WebDriver Sampler tips and tricks.

Upvotes: 5

Related Questions