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.
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 | ||
Command | Target | Value |
setSpeed | 500 | |
storeEval | carnamearray.length; | length |
store | 0 | MyVar |
open | http://www.google.com | |
while | storedVars.MyVar < storedVars.length | |
storeEval | carnamearray[storedVars.MyVar] | carname |
echo | ${carname} | |
type | id=gbqfq | ${carname} |
click | id=gbqfba | |
pause | 2000 | |
store | javascript{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.
Thank u so much for the post. and i was searching long for this solution. it s so clear and fine.
ReplyDeletei 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
Is there any possibility to add xls for data? instead of .js file.
ReplyDeleteNo. 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.
DeleteOk.. Waiting for ur Webdriver post. Thanks
DeleteHow to use webdriver? I want to use .xls file.
ReplyDeleteHow to export first 10 dynamic web suggestion?
ReplyDeleteI am getting this error message.
ReplyDelete[error] Element carnamearray.length; not found
Can you please debug it
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.
ReplyDeleteIs 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)
ReplyDeleteThank you so much
ReplyDeleteI am newbie to selenium could you please guide me how to parametrize log-in details using java script and ms-excel.
ReplyDeleteA 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.
As per my knowladge, parameterization with ms excel is not supported by selenium IDE. It supports only .js file to store parameters.
DeleteThank you, this was very Helpful!
ReplyDeleteThan you very much! This is exactly what I was looking for
ReplyDeleteHi,
ReplyDeleteWhen running the command showed the message "[error] Threw an exception: carnamearray is not defined". Lack declare anything?
Tks.
Hi ,
ReplyDeleteCan we import/load any xml data into selenium and run the test case?
Thanks