Reputation: 147
var pkg = JavaImporter(org.openqa.selenium)
var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
var wait = new support_ui.WebDriverWait(WDS.browser, 5000)
WDS.sampleResult.sampleStart()
WDS.browser.get('https://example.com')
var wait=new support_ui.WebDriverWait(WDS.browser,15000)
var userName = WDS.browser.findElement(pkg.By.id('Login_txtUserName')).sendKeys(['sample'])
//userName.click()
//userName.sendKeys(['pandian'])
var userPwd = WDS.browser.findElement(pkg.By.id('Login_txtPassword')).sendKeys(['1234'])
//userPwd.click()
//userPwd.sendKeys(['1234'])
var button = WDS.browser.findElement(pkg.By.id('Login_btnLogin')).click()
//button.click()
![In the Username:'Sample' & Password: '1234' i want to parameterize with list of values i have in csv][1]
If i try to parameterize with CSV config and if i use ${username} in my sendkeys...it doesn't execute. kindly provide some details for it.
Upvotes: 0
Views: 1116
Reputation: 168157
See Parameters
section at the top of "Script" input field.
You can pass your ${username}
and ${password}
in Parameters stanza you'll be able to refer it as WDS.args[0]
and WDS.args[1]
correspondingly
Something like:
var userName = WDS.browser.findElement(pkg.By.id('Login_txtUserName')).sendKeys([WDS.args[0]])
var userPwd = WDS.browser.findElement(pkg.By.id('Login_txtPassword')).sendKeys([WDS.args[1])
Should work.
You can test it as follows:
Assuming that you provide the following line as "Parameters"
Sample 1234
And having the following lines in "Script"
WDS.log.info('Parameter 1:'+ WDS.args[0])
WDS.log.info('Parameter 2:' + WDS.args[1])
You'll see something like:
2014/06/24 15:57:16 INFO - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Parameter 1:Sample
2014/06/24 15:57:16 INFO - com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler: Parameter 2:1234
in jmeter.log file (usually lives in /bin folder of JMeter installation)
See Using Selenium with JMeter's WebDriver Sampler guide for more details.
Upvotes: 3