i

Selenium Step By Step Guide

Frameworks Introduction

In an organization, many test cases are bundled together in several test suites. This creates a need for creating a platform of automation where all the test cases can be automated, enhanced, and maintained with very minimal efforts. This can be achieved by creating a well-standardized automation framework.

Benefits of the framework:

1 Easy to maintain:

The main benefit of creating a framework is to maintain the test scripts and other modules. As the framework is a standard way to implement the code, it helps in maintaining and adding the test scripts of the automation suites.

2 An efficient way to use Test Data:

A well-versed framework helps in using the test data in a very efficient manner. We can create the connection of an excel file, properties file, or an XML file to provide the data to the test scripts. This way helps us to create, update, and delete the test data very efficiently.

3 Standard Reporting:

Another benefit of using a standard framework is to generate the expert reports of test results after running the test suites. Reporting plays a significant role in the execution of test suites as it gives a clear picture of the final status of the test execution.

4 Reusability:

Reusability is one of the most critical factors of a Standard Framework creation. In most of the automation we need to use the same set of methods again and again. Sometimes organization Test teams create their standard libraries to create their standardized framework. This kind of framework is used across the organization. Hence reusability of framework among different teams helps the team to implement the test automation for their applications.

Types of Framework:

Types of frameworks define the architecture of a framework. How a framework is designed, implemented, and what are the different Tools used!

Different factors/steps define the framework architecture such that are:

  1. Framework design
  2. Tools used.
  3. Test Data connection.
  4. Reusable methods collection.
  5. UI objects collection.
  6. Test class or runner class.

Based on the above factors, we can design frameworks in different ways to satisfy the needs of our application. Therefore, in recent times different types of frameworks have been introduced, and organizations are using them as per their design goals.

Let us see all those popular framework designs which are being used in the industry widely.

  1. Data-Driven Framework.
  2. Keyword Driven Framework.
  3. Hybrid Framework.
  4. BDD (Behavioral Driven Development) Framework.
  5. TDD (Test Driven Development) Framework.

Some other types are also available, but the above-listed design patterns are widely used in the industry.

1 Data-Driven Framework:

A data-driven approach is an approach where all the test data is supplied from some external files like excel, csv, XML, or a database table.

Apache Poi library helps us to read the data from an Excel file. This library is capable of reading both XLS and XLSX formats.

  • To read data from XLS format, we can use the HSSF implementation of the POI library.
  • To read data from XLSX format, we can use the XSSF implementation of the POI library.

2 Keyword Driven Framework:

A keyword-driven framework is an approach where all the actions that are performed against UI elements are kept in an excel file, and then those actions are called to execute the test cases.

The keyword-driven framework follows the below steps to implement the keyword framework design:

Let us understand the above flow step by step to get more clarification on the same:

  1. First, we can create a Test class from where we need to run the test cases.
  2. Now we need to create an Excel reader class to read the excel file.
  3. Create an Excel file having the keyword actions.
  4. Create a UI Actions class that keeps all the methods for each Keyword defined in the Keyword excel file.
  5. Object Reader class to extract the object from the object repository.

Test Case

Keyword

Object

Value

Login

 

 

 

OpenURL

 

 

EnterUserName

username

user1

EnterPassword

password

password1

 

Once we run the Test "Login", it picks up the Keyword like OpenURL, EnterUserName, and EnterPassword. Once the Keyword is picked up, then the corresponding object is used to locate the element to perform the actions by using Actions class on the corresponding element.

3 Hybrid Framework:

The hybrid test framework is a combination of Keyword driven and Data-driven framework. We can use the above-explained Keyword framework to maintain the test steps and test data. We can also use the TestNG for providing the data using the data provider. It's a combination of the different types of the framework, and thus it is called the Hybrid framework.

4 BDD Framework:

BDD is the acronym for Behavioral driven development that is used based on the business use case. BDD framework is created with the help of the Cucumber tool, which uses the Gherkin language. Gherkin is a simple text-based language that helps in creating the simple test steps in a feature file.

5 TDD Framework:

TDD (Test-driven development) framework is a framework that works on a predefined test method. These test methods are implemented as the development code is implemented. So, first, the test method is created, and then the development code is implemented to pass this test method, and the development code keeps on modifying until the test method gets passed.