How to do Data Driven Testing using Selenium Ide?

  • Cubettech
  • Web App Development
  • 10 years ago

Selenium IDE is a Firefox plugin which records and plays back user interactions with the browser. By using some extensions we can use this for Data Driven Testing.

Data-driven testing means by using a single test to verify many test cases by driving the test with input and expected values from an external data source instead of using the same hard-coded values each time the test runs.

How to install Selenium ide?

1) Download the latest version.
2) Install the Add-on
3) Restart Firefox
4) After Firefox reboots, the Selenium-IDE will list under the Firefox Tools menu.

Add-on : Sel Blocks
Selenium IDE does not have in-built features to create data-driven tests. By using some user extension or Add-on we can do data driven tests. In this blog ,I am trying to do the data driven test with an Add-on called Sel Blocks .It provides various flow control elements such as conditional handling, looping, variables and data-driven testing in Selenium IDE tests.

How to do test driven Testing

1)Download
Download and install the Add-on SelBlocks.

2)Creating an XML file.
In this, we are importing the test data from the xml file.

How to create an xml file
2.1)Open a note pad
2.2) Write a Declaration Statement
XML declaration statement requires the language and version. This is to establish the page as an XML document.
2.3) Create a Root and child Element
Here we can add as Root element and as the child element. In child element we can define all the parameters needed for the test
2.4) Save the file with extension .xml

<testdata> <vars Email="qamail1@gmail.com" Remail="qamail1@gmail.com" Password="123456" Rpassword="123456"/> <vars Email="qamail2@gmail.com" Remail="qamail2@gmail.com" Password="123456" Rpassword="123456"/> <vars Email="qamail3@gmail.com" Remail="qamail3@gmail.com" Password="123456" Rpassword="123456"/> <vars Email="qamail4@gmail.com" Remail="qamail4@gmail.com" Password="123456" Rpassword="123456"/> <vars Email="qamail5@gmail.com" Remail="qamail5@gmail.com" Password="123456" Rpassword="123456"/> </testdata>

3)Create a test scripts  in  IDE.
In this, we are trying to parameterize the  registration page. The script for entering  single and multiple data into registration form is explained below.

Script using Single data

CommandTargetValues
openhttp://www.screencast-o-matic.com/login?url=%2F 
typeid=createEmailqamail@gmail.com
typeid=createEmailAgainqamail@gmail.com
typeid=createPassword123456
typeid=createPasswordAgain123456
clickid=termsCheckBox 
clickAndWaitid=createButton 
clickAndWait link=logout 

Script using Multiple data

CommandTargetValues
forXmlfile:///D:/Reshma/Selenium/xml/screen.xml 
openhttp://www.screencast-o-matic.com/login?url=%2F 
typeid=createEmail${Email}
typeid=createEmailAgain${Remail}
typeid=createPassword${Password}
typeid=createPasswordAgain${Rpassword}
clickid=termsCheckBox 
clickAndWaitid=createButton 
clickAndWaitlink=logout 
endForXml  

4)How it works
‘forXml’ command in the script is used to set the target of the XML file’s path. End the test script by adding ‘endForXml’ , both these commands are provided from the SelBlock Add-on. Replace the  keyword with variable in test data file  by using ‘${VARIABLE}’ syntax.

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. In this example it will execute the test for five times. For all the attributes mentioned in <vars> element, Sel Blocks create internal variables that we can substitute as Selenium command parameters. You can analyse the Selenium IDE Log tab for  results. If the expected data and actual data do not match, an error is reported in the Selenium IDE Log tab.

Know More About This Topic from our Techies

Check out how complex technology stack deployed to deliver amazing IoT solutions

Got a similar project idea?

Connect with us & let’s start the journey!

Questions about our products and services?

We're here to support you.

Staff augmentation is a flexible workforce strategy companies adopt to meet specific project needs or address skill gaps.

Begin your journey!
Need more help?