In this blog, a brief summary about types of selenium frameworks is explained. As we all know, framework is a platform for developing software applications. A framework is a structure where we can build a software. It serves as a foundation, so that we do not have to start entirely from scratch. By using frameworks, we can save time and risk of errors can be reduced. Some of the advantages of frameworks are
1. More Secure code
2. Eliminate the need to write a lot of repetitive code
3. Simpler testing and debugging
4. Avoiding duplicate code
5. Can be extended
6. Clean and easily adaptable code
There are mainly three types of frameworks created by Selenium WebDriver to automate test cases:
1. Data Driven Framework
2. Keyword Driven Test Framework
3. Hybrid Test Framework
Each framework has its own architecture and benefits and disadvantages. We have to decide and choose which framework is suitable for our application.
Data Driven Framework
As the name says “Data Driven”, this framework is related data/ data sets which mean we need a data set or collection of test data to use this framework. Data Driven framework is used to separate the test script from the test data. Then the same script is ran for multiple sets of data. Suppose we have written automation scripts for employee registration form of any demo website, there can many employees for registration, the only thing that may vary are employee name, age, address and phone number. In this case, we do have to write separate scripts for each employee, this is where data driven framework comes into picture.
Here we have to execute the same script with multiple sets of test data, whose storage is at a different place and not present inside the test script. Any changes done to the data will not impact the code of the test. It is used to fetch test cases and suites from external files like Excel, .csv, .xml or some database tables.
To read or write an Excel, Apache provides a very famous library POI. This library is capable enough to read and write both XLS and XLSX file format of Excel. To read XLS files, an HSSF implementation is provided by POI library.
Test cases can be modified without much changes to code.
It allows testing the application with multiple sets of data values, especially during regression testing.
It helps us to separate the logic of the test cases/scripts from the test data.
Keyword Driven Framework
Keyword Driven Framework in Selenium is a method used for speeding up automated testing by separating keywords for common set of functions and instructions. All the operations and instructions to be performed are written in some external file like an Excel sheet. The Keyword-Driven framework is a technique to externalize keywords/actions that are used in the script in a separate Object Repository (here, it is a Java Class file), which will give positive outcomes like increased code-reusability, reduced script maintenance, and higher portability.
There are five components of Keyword Driven Testing Framework:
1. Function Library
This is the Java Class file where the Keywords are defined. All the actions that are performed on the application are defined as user-defined methods (which are keywords) in the library class file.
2. Excel Sheet to store Keywords
All the user-defined methods along with its functionality details should be mentioned in the excel sheet so that the user can understand what Keyword the library file holds.
3. Design Test Case Template
Test Case Template can be created according to project convenience. There is no particular rule to create a template. It is designed depending on how much the project needs the framework to externalize. The externalization might be only for Keywords, or sometimes even Test Data and UI Elements are also externalized.
4. Object Repository for Elements/Locators
UI locator can be identified and its value can be either mentioned in the test case template or maintained in a separate Object Repository.
5. Test Scripts or Driver Script
This is the main script that reads all the contents of the excel sheet and performs the corresponding action.
It allows functional testers to plan test automation before the application is ready
Tests can be developed without programming knowledge
It is not dependent on a specific programming language or tool
Compatible with any automation tools available in the market
Effortless Tool Switching
Hybrid Driven Framework
Hybrid Driven Framework is a combination of both the Data-Driven and Keyword-Driven framework. Here, the keywords, as well as the test data, are externalized. Keywords are maintained in a separate Java class file and test data can be maintained either in a properties file/excel file/can use the data provider of a TestNG framework.
Hybrid Framework in Selenium is a concept where we are using the advantage of both Keyword driven framework as well as Data driven framework. It is an easy to use framework which allows manual testers to create test cases by just looking at the keywords, test data and object repository without coding in the framework.
· Hybrid Framework can be created and used to automate any application.
· Man-hours spent in scripting the automation code is reduced, since a framework once created can be used to automate multiple applications.
Hope you got the basic idea about selenium frameworks. Thank you for reading.