Insights from Our Experts

Blog image

How parameterization helps you in test automation

Author Image

Binu Babu,QA Engineer

Its every software tester's wet dream and business scenarios demand to have an efficient, resilient and reusable test automation framework that eliminates human errors, speeds up the process and makes the testing a continuous process. Selenium Automation is emerging to be the most sought-after test automation tool for testers and businesses for various reasons : 

  • Compatibility with OS

  • Supports multiple languages such as Java, Python and the list goes on.

  • Cuts down test execution time, which is a boon for large scale projects.

 

How Parameterization makes it easy .

The success of a test lies in making the application go through every possible permutation and combination of scenarios that may occur in the real world, and this is impossible with a single set of data, this is where Parameterization plays a key role in automation testing. To be able to pass multiple data to the application at runtime we need to parameterize our test scripts, this concept is called Data-Driven Testing.

 Parameterization is an execution strategy that runs a test case automatically, multiple times with different input values. The test design comes with the provision to read data from a file or database rather than hard-coded values.

 

 

Parameterization with Selenium Web-driver:

Selenium Webdriver automation testing tool but does not have a built-in structure or method to parameterize the test case.  Microsoft Excel can be used to parameterize a large amount of test data, Selenium web driver access data from the excel file using Java Excel APIs which opens, reads and writes data into Excel. Jxl.jar is an open-source Java API that supports this. For a demo, here we use Eclipse as IDE.

Eclipse Configuration 

  • Step 1: Download the latest jxl.jar file, from here. And extract the zip folder and find the jxl.jar file inside it. 

  • Step 2: To access the methods and classes provided by this API inside Eclipse we need to add this JAR file to the Java Build Path. Add jxl.jar in your project folder as an external jar. Right-click on your project folder in eclipse and go to Build Path -> Configure Buildpath-> Libraries tab -> Click on Add External JARs button and select jxl.jar.

  • Step 3: Create an Excel file named "Credential.xls" with the data in the below format, with the required test data. In the excel sheet, rename the first sheet as “LoginCredential”.

 

 

  • Step 4: Include all the header files listed below. 

 

  • Step 5: Create a new Java class and copy the following code into it. Change the path of the excel file as per your project specification.

 



Summary

Parameterization is an incredibly powerful and efficient test design for any automation testing tool. This allows you to replace the hard-coded input data with multiple data sets which could be data stored in Excel sheets, database tables, arrays etc. Parameterization gives great flexibility and agility to a QA to make the testing process much easier and faster. Selenium offers reusability, easy maintenance, and stable operation. These features of Selenium are making it a popular choice among QA experts and highly recommended to those who haven't tried it yet.


 

I Need

Help for