SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

Parameterization in selenium ide - Example of data driven testing with selenium IDE

Data driven testing using selenium IDE software automation testing tool is not much more hard but initially you need to configure selenium IDE before you proceed for Parameterization using Advanced Selenium IDE features. There are 2 methods of Parameterization in selenium IDE software testing tool. Let me describe 1st method of Parameterization in this post. You can read my next post
for 2nd method of data driven testing in selenium IDE.

We need to attach external selenium IDE user extension to get support of "while" and "endWhile" commands in our Parameterization software test case. Also you need to attach data file(Only in .js format) with selenium IDE to read data from it.

1st Step is to Download user extension file for Parameterization and save it in your hard drive. Now i created data.js file for our example. Download data.js file and save it in your hard disc. Data.js file contains array of data which we will use in our script. Click here to read how to attach user extension and data file with selenium IDE.


After attaching user extension and data file, your selenium IDE option window will looks like bellow image.



Now restart your selenium IDE software testing tool and create bellow given Parameterization example software test case in your selenium IDE and run it.

New Test
CommandTargetValue
setSpeed500
storeEvalcarnamearray.length;length
store0MyVar
openhttp://www.google.com
whilestoredVars.MyVar < storedVars.length
storeEvalcarnamearray[storedVars.MyVar]carname
echo${carname}
typeid=gbqfq${carname}
clickid=gbqfba
pause2000
storejavascript{storedVars.MyVar++;}
endWhile


Note : You Can Find More Advanced Command Tutorials Of Selenium IDE On This Link.

Let me describe main steps how it works. 
  • 2nd command "storeEval" will read the length of array(carnamearray) from data.js file and save it in variable 'length'. There are 5 values inside array so value of variable 'length' = 5.
  • Initially, 'MyVar' has '0' value.
  • "while" command will rotate the loop 5 times as per given condition 'storedVars.MyVar <= storedVars.length'
  • Here, "storeEval" command is used to read value from data.js file and to store it in variable. When it will be executed 1st time, it will retrieve carnamearray[storedVars.MyVar] = carnamearray[0] = "Acura" from array of data.js file and it will save it in variable carname. 
  • (Note : Here, Name of array used in data.js file and used with "storeEval" command must be same. In our example, i used 'carnamearray' on both the places).
  • Now variable, carname contains "Acura" so next "type" and "click" commands will search with keyword "Acura" on Google.
  • 2nd last "store" command will increase the value of  variable 'MyVar' by 1. Now 'MyVar' = 1
  • 2nd time, "storeEval" command will retrieve carnamearray[storedVars.MyVar] = carnamearray[1] = "Audi" from array of data.js file and it will save it in variable carname.
This cycle will run for 5 times and everytime "storeEval" command will retrieve new data value from array of data.js file. In this way we can perform data driven software testing in selenium IDE.

16 comments:

  1. Thank u so much for the post. and i was searching long for this solution. it s so clear and fine.

    i have executed ur commands. it works really nice as expected. but still for me it executed 6 time, last value is taken as null and search for it.

    Can u pls clarify..


    Thanks & Regards
    danikadain

    ReplyDelete
  2. Is there any possibility to add xls for data? instead of .js file.

    ReplyDelete
    Replies
    1. No. You can attach only .js file with selenium IDE. But yes you can do it with webdriver and i am in process for publishing posts on webdriver.

      Delete
    2. Ok.. Waiting for ur Webdriver post. Thanks

      Delete
  3. How to use webdriver? I want to use .xls file.

    ReplyDelete
  4. How to export first 10 dynamic web suggestion?

    ReplyDelete
  5. I am getting this error message.
    [error] Element carnamearray.length; not found
    Can you please debug it

    ReplyDelete
  6. I believe the while loop needs to be started before you open the browser to google.com; otherwise, it keeps typing the car names back to back in the search field. You end up with searches like AcuraAudiBentley.

    ReplyDelete
  7. Is user extension file attached is usable for all other parametrization test cases? I can only use it with your example for all other test cases error shows up that array not found(error is shown in storeEval command)

    ReplyDelete
  8. Thank you so much

    ReplyDelete
  9. I am newbie to selenium could you please guide me how to parametrize log-in details using java script and ms-excel.
    A log-in page with 6-8 different users access with same/different passwords,after log-in the web content differs for each users.
    The requirement is to write those username and password in a excel sheet with the help of java script parametrize it and call in the Selenium IDE.On execution Selenium IDE will call JS having excel parameters to fill the log-in page.
    I am familiar with eclipse does the above scenario in easier format but our requirement is different executing from selenium ide.

    ReplyDelete
    Replies
    1. As per my knowladge, parameterization with ms excel is not supported by selenium IDE. It supports only .js file to store parameters.

      Delete
  10. Thank you, this was very Helpful!

    ReplyDelete
  11. Than you very much! This is exactly what I was looking for

    ReplyDelete
  12. Hi,
    When running the command showed the message "[error] Threw an exception: carnamearray is not defined". Lack declare anything?
    Tks.

    ReplyDelete
  13. Hi ,
    Can we import/load any xml data into selenium and run the test case?

    Thanks

    ReplyDelete