Selenium is a tool which every tester is using because it is:
- Open Source
- Runs multiple tests at a time
- Supports all browsers like IE, Firefox, Mozilla, Safari
- Supports all programming languages Ruby,C#, Java and Python.
- Supports all Operating Systems
Data driven testing means we can run the same test multiple times with different data from an external data XML file instead of using the same hard-coded values each time the test runs
Selenium IDE is a Firefox plugin to record the users use of the browser for testing purposes, by installing the browser extension Sel Blocks, we are able to do Data driven tests
A – To install Selenium IDE
1, Download the latest Selenium IDE version
2, Install the Add-on
3, Restart Firefox
4, From the Firefox application, select Tools then Select Selenium-IDE
Next to do XML data driven testing we need to install SelBlocks
B – To Install SelBlocks
1, Download the latest Selenium SelBlocks version.
2, Install the Add-on
3, Restart Firefox
4, From the Firefox application, select Tools then Select Selenium-IDE
To Do XML Data driven testing, we need to create an XML file, a file with one record would look a bit like this
Example 1:
<testdata>
<vars Email=”Make_This_Unique@gmail.com” firstname=”First1″ lastname=”LastName1″ password=”123456″ rpassword=”12345″ npassword=”12345cc”/>
</testdata>
Parameterised data source:
C – Create the directory: ’01 Selenium’ on the C drive of your computer
D – Save the following files to the directory called ‘C:\01 Selenium’ on your computer
A, Test.xml –
B, Create_Account.HTML –
Please Note:
Each time you run this test, you must edit and update the Test.xml file with a unique email address for your test run
Parameterised data displayed in the Selenium IDE
1, Launch Firefox
2, Launch Selenium IDE
3, Open the Test Case ‘Create_Account’ in ‘C:\01 Selenium’
4, Run the Test Case ‘Create_Account’
Whats happening when you run this?
1, The script is creating an account for every entry in the XML file for a demo shopping site2, ‘forXml’ command in the script is used to set the target of the XML file’s path. The script ends by adding ‘endForXml’, both these command are provided from the SelBlock Add-on.
3, The variable in test data file is caled by using ‘${VARIABLE}’ in the syntax.
4, When this test is executed, Sel Blocks loads the content of XML file in memory and executes the script for number of times <vars> element present in the XML file.
5, In this example it will execute the test twice. Once you see it working, it is easy to copy and paste more data to be created
6, For all the attributes mentioned in <vars> element, Sel Blocks create internal variables that we can substitute as Selenium command parameters.
Selenium Log:
F – To do:
1, Analyze the Selenium IDE Log tab for the results.
2, If the expected data and actual data do not match, an error is reported in the Selenium IDE Log tab.
I hope this helps some people get started with some data driven tests, until the next time
Leave a Reply