Road to parameterization in Jmeter test script

Parameterization is process by which user input some values to test script at execution time using external files such as csv, xls, txt, xml etc. In Jmeter test, suppose we need to check login functionality with 100 set of user so in this case we parameterize users from external file. At execution time user picked dynamically .

Steps Jmeter parameterization.

1. After capturing request and responses of your web application you need to create a csv file and put data in file separated with comma. As I created below  csv file for urls parameterization


2. Right click on you Thread Group”  and add “CSV Data Set Config” by choosing option “Add>>Config Element>>CSV Data Set Config.
3. Click on created “CSV Data Set Config” and enter file name with absolute path, define variables name separated with coma as in below screen.


4. Above defined variable you can use in your jmeter test as I used “url” variable.in below screen.


5. Run  your Jmeter test, Jmeter should be fetch parameterized value automatically.

3 comments:

  1. how to read csv file in jmeter by using selenium web driver script.

    here code i am unable to read csv file in jmeter.

    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('http://gmail.com')
    WDS.log.info('Parameter 1:'+ WDS.args[0])
    WDS.log.info('Parameter 2:' + WDS.args[1])
    var wait = new support_ui.WebDriverWait(WDS.browser, 50000)
    var wait = new support_ui.WebDriverWait(WDS.browser, 50000)
    var userName = WDS.browser.findElement(pkg.By.id('user')).sendKeys('${user}')
    var userPwd = WDS.browser.findElement(pkg.By.id('pass')).sendKeys('${pass}')
    var button = WDS.browser.findElement(pkg.By.name('login2')).click()

    ReplyDelete
  2. how to read csv file in jmeter by using selenium web driver script.

    here code i am unable to read csv file in jmeter.

    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('http://gmail.com')
    WDS.log.info('Parameter 1:'+ WDS.args[0])
    WDS.log.info('Parameter 2:' + WDS.args[1])
    var wait = new support_ui.WebDriverWait(WDS.browser, 50000)
    var wait = new support_ui.WebDriverWait(WDS.browser, 50000)
    var userName = WDS.browser.findElement(pkg.By.id('user')).sendKeys('${user}')
    var userPwd = WDS.browser.findElement(pkg.By.id('pass')).sendKeys('${pass}')
    var button = WDS.browser.findElement(pkg.By.name('login2')).click()

    ReplyDelete
  3. Hi, I have entered Parameters ${username},${password} in Parameters section at web driver sampler page and My code is

    var pkg=JavaImporter(org.openqa.selenium) //import java selenium package
    var support_ui=JavaImporter(org.openqa.selenium.support.ui.WebDriverWait) //import WebDriverWait Package
    var ui=JavaImporter(org.openqa.selenium.support.ui) //import Selenium Support UI package
    var wait=new support_ui.WebDriverWait(WDS.browser,5000) // wait 5 seconds until page loads
    var uname = WDS.args[0]
    var pwd = WDS.args[1]
    WDS.log.info("username :"+uname)
    WDS.log.info("Password :"+pwd)
    WDS.sampleResult.sampleStart() //sample starting point
    WDS.browser.get('http://localhost:8180/pc') // opens website ""http://demo.mahara.org"
    wait.until(ui.ExpectedConditions.presenceOfElementLocated(pkg.By.id('Login:LoginScreen:LoginDV:username-inputEl')))
    var usernameField = WDS.browser.findElement(pkg.By.id('Login:LoginScreen:LoginDV:username-inputEl')) //define username field
    usernameField.sendKeys(uname) // types word “student1” in field
    var passwordField = WDS.browser.findElement(pkg.By.id('Login:LoginScreen:LoginDV:password-inputEl')) //define username field
    passwordField.sendKeys(pwd) // types word “Testing1” in field
    var loginButton=WDS.browser.findElement(pkg.By.id('Login:LoginScreen:LoginDV:submit-btnInnerEl')) //define login submit button
    loginButton.click() //click on the login button
    WDS.log.info(WDS.name + ' has logged an entry') //log message
    WDS.sampleResult.sampleEnd()

    but in console username getting correct value unmae, uname1
    for password it's displaying pwd,${password} and pwd1,${password} here why I am getting " ,${password} " instead of only pwd, pwd1 value.

    My CSV file is like
    uname,pwd
    uname1,pwd1

    Is there any changes in my code or csv file.

    ReplyDelete

Leave your comments, queries, suggestion I will try to provide solution