• Selenium Video Tutorials

Selenium - Automation Frameworks



Selenium Webdriver can be used to develop test scripts which are based on the keyword, data, and hybrid driven framework. A keyword driven framework is mostly used to create functional test cases where there is a clear demarcation between the design of the test cases and development. A data driven framework is mostly used to create test cases which are dependent on data available from an external source and can also be used for regression testing. A hybrid driven framework is a combination of a keyword driven and data driven framework.

Need of Automation Frameworks

Let us take a situation where a team of three people are asked to create test scripts for the same application. Along with writing the test scripts for certain requirements, they also need to incorporate logging and reporting logic within the test scripts.

In the absence of a framework, all the three team members will start creating test scripts in a way they are comfortable with their matching skill sets. Apart from that, all the test scripts will be developed by taking different approaches which may make it difficult to execute all the test scripts together.

Moreover, every test script will follow custom logging which will make it difficult in collecting logs post the execution. The requirements given to them may require data to be fetched from external sources. In such a situation, the team members may hard code the data, or use an excel file, or an xml file, and so on. So there will not be any uniformity.

The requirements given to the team may have a common functionality like login to the application. In the absence of a framework, each team member will create test scripts for the common login feature along with the other unique requirements. Thus the login feature can not be reused leading it duplicacy of test scripts.

While reporting the test scripts as pass/fail, a different approach will be taken by each member of the team which will make it difficult in reporting post the execution. Also, test scripts can be executed in different test runners like using plain Java, TestNG, JUnit, Maven,and so on. In the absence of a framework, each team member can follow a different approach of running the test scripts, thus we may not be in a situation to run the test scripts as a suite.

To fix these issues we need automation frameworks.

What is an Automation Framework?

An automated framework is a group of standards, assumptions and guidelines for creating test scripts that everyone should adhere to. Every organization or team may use different frameworks but each of them should be guided by a common set of rules.

A framework development is a continuous process and it needs time for development of an exhaustive framework. A framework requires regular updates and maintenance. For example, some libraries may be deprecated, for that we may have to update the libraries, additional libraries may be added in some cases to make the framework more powerful.

Once a dynamic framework has been developed after a period of time, new test scripts can be developed in a very short span of time. Along with that, maintenance also becomes relatively easier.

Components of an Automation Framework

The components of an automation framework are −

  • Standardization of test cases(Tests) − The test cases should be developed in a uniform manner. For example, test cases can be created by following a design pattern approach called the Page Object Model.

  • Standardization of logging(Logger) − The test cases should be developed such that there is proper logging to examine what went right or wrong during execution, and to debug.

  • Standardization of test data and configuration(Data Providers) − The test cases should be developed such that there is minimal hard coding and test data and configurations should be maintained in separate files. Thus, in case there are changes, we will need to update only those files and not other areas.

  • Standardization of utility libraries(Helper/Reusable libraries) − There are some utilities which are project independent like capturing screenshots on failures, synchronizations, generating reports, logs, and so on. In addition to this, there are some utilities which are project dependent and mostly reusable like the login feature.

  • Test Execution Engines(Test Runner) − There should be proper execution engines identified and defined. The test cases can run from Jenkins, Maven, TestNG, and so on.

  • Standardization of reporting(Reporter) − There should be proper reporting to showcase how the execution went to project stakeholders. A report should at least cover the features on which the tests ran, total number of tests, count of passed and failed tests, duration of tests, screenshots of failures, and so on.

Types of Automation Frameworks

The types of automation frameworks are listed below −

  • Keyword Driven Frameworks

  • Data Driven Frameworks

  • Hybrid Driven Frameworks

Keyword Driven Frameworks

A keyword testing or a keyword driven framework is a set of guidelines followed while automating test cases, in which the implementation logic and the technical information are hidden. The usage and maintenance of a keyword driven framework is very easy.

A group of keywords in a particular and purposeful order has to be incorporated as a part of test case preparation to perform a particular task or tasks on the application. All these keywords are described in the common repository or a reusable library.

Data Driven Frameworks

A data driven framework is the one in which the test cases are segregated from the data set. Also, it gives the provision to run the same test case against multiple sets of data. Since the test code implementation and test data are independent of each other, the data set can be modified without impacting the implementation logic and vice-versa.

In a data driven testing framework, more than one set of data can be run against the same test case, thus the same application can be tested against a wide data range without requiring additional code. Thus code is developed once but reused multiple times.

Hybrid Driven Frameworks

A hybrid driven framework works in combination of data driven and keyword driven frameworks. Both the test data and keywords(i.e the actions to be performed on the application) are fed from external files.

The external test data source can be any file having extensions with .txt, .properties, .xlsx, .xls, .csv, and also with the help of data providers. The keywords can be from Java class files, excel files, and so on.

This concludes our comprehensive take on the tutorial on Selenium Webdriver - Automation Frameworks. We’ve started with describing why we need automation frameworks, what is an automation framework, what are the components and types of an automation framework, and described keyword driven, data driven, and hybrid frameworks.

This equips you with in-depth knowledge of the automation frameworks in Selenium Webdriver. It is wise to keep practicing what you’ve learned and exploring others relevant to Selenium to deepen your understanding and expand your horizons.

Advertisements