Earlier in this Selenium Tutorial series , we have seen basic concepts of Selenium. In this post, we will learn Types of Selenium Automation Framework (Test Automation Frameworks) – Data-Driven, Keyword Driven, and Hybrid Framework. This will help you to clear your Selenium Interview .
Before discussing the types of test automation frameworks, let’s see what is a framework.
What is a Framework?
A framework defines a set of rules or best practices that we can follow in a systematic way to achieve the desired results. So the above-mentioned test automation frameworks deal with best practices to achieve the goals of our automation project.
Let’s see a general example:
Most of us love a cup of tea. How we make a good tea.
To make it, we add ingredients like tea powder, sugar, milk and water to make a tea. To make a good tea, all the ingredients we add should be in right ratio.
In case you want to make it on daily basis how you do. Its not possible to add all the ingredients in right ratio on everyday.
If you add all the ingredients in right ratio in a jar. You can make the tea everytime with same taste.
Here the ‘jar‘ where we added all the ingredients required to make a good tea is Framework.
Do we really follow this process?
The answer is No.
We can make tea without following this process.
But if the above process is followed then the outcome will be good.
Similarly, if we follow a framework we can get better results.
What is Selenium Framework?
Selenium framework’s code structure helps you to reuse the code, reduce code maintenance, higher code readability, and allows multiple users to work on the same piece of the program.
Why do we need the Selenium Framework?
- Easy code maintenance
- Increase in code re-usage
- Higher code readability
- Reduced script maintenance cost
- Reduced tests’ time execution
- Reduced human resources
- Easy reporting
Types of Test Automation Frameworks:
Here in this post, I will explain the most popular Types of Selenium Automation Frameworks.
- 1. Linear Scripting Framework
- 2. Modular Testing Framework
- 3. Library Architecture Testing Framework
- 4. Data-driven Testing Framework
- 5. Keyword Driven Testing Framework
- 6. Hybrid Testing Framework
- 7. Behavior Driven Development Testing Framework
How to explain Test Automation Framework to the interviewer.
Check the below video to watch “Types of Automation Frameworks In Selenium / Types of Automation Frameworks in QTP/UFT”
Please be patient. The video will load in some time.
Linear Scripting Framework:
Linear Scripting Framework is a basic level test automation framework that is in the form of ‘Record and Playback’ in a linear fashion.
This framework is also known as the ‘Record and Playback’ framework.
This type of framework is used to test small-sized applications.
In this type, the creation, and execution of test scripts are done individually for each test case individually.
Testers capture each test step such as browsing, navigation, user inputs, enforcing checkpoints. Testers then play the scripts to carry out the tests.
Advantages of Linear Scripting Automation Framework:
- Can generate test scripts (Record and playback) without planning much or consume much time
- Coding knowledge is not required
- A quick way to generate test scripts
Disadvantages of Linear Scripting Automation Framework:
- Lack of reusability due to autogenerated scripts
- Hard coding the data doesn’t allow us to run with multiple data sets
- Maintenance is high – It requires a lot of effort to do even small changes.
Modular Testing Framework:
In the modular testing framework, testers create test scripts module wise by breaking down the complete application under test into smaller, independent tests.
In simple words, testers divide the application into multiple modules and create test scripts individually. These individual test scripts can be combined to make larger test scripts by using a master script to achieve the required scenarios. This master script is used to invoke the individual modules to run end to end test scenarios.
The main reason for using this framework is to build an abstraction layer to safeguard the master module from any changes made in individual tests.
In this framework, testers write function libraries to use it whenever required. This is AKA modularity framework or module-based framework.
Advantages of Modular Testing Framework:
- Better scalability and easier to maintain due to breaking down the complete application into different modules
- Can write test scripts independently
- Changes in one module bring no or low impact on the other modules
Disadvantages of Modular Testing Framework:
- Takes more time to analyze the test cases and to identify reusable flows
- Due to hardcoded data in the test scripts, it’s not possible to sue multiple data sets.
- Requires coding skills to set up the framework
Framework Interview Questions
Library Architecture Testing Framework:
Library Architecture Testing framework aka “Structured Scripting” or “Functional Decomposition”
It is based on the modular framework with some additional advantages.
In the modular testing framework, we divide the application under test into modules whereas here we identify the common tasks and grouped them into functions. Once the functions are grouped then these groups will be kept in a library. The test scripts reuse these libraries to create new test cases.
Advantages of a LIbrary Architecture Testing Framework:
- Script maintenance is simple
- Easy to scalable
- Functions library is reusable and it can be reusable
Disadvantages of a LIbrary Architecture Testing Framework:
- Coding skills are required
- It takes more time to prepare test scripts
- A fixed set of test data is hardcoded within the scripts
The data-driven test automation framework is focused on separating the test scripts logic and the test data from each other.
It allows us to create test automation scripts by passing different sets of test data.
The test data set is kept in the external files or resources such as MS Excel Sheets, MS Access Tables, SQL Database, XML files, etc.,
The test scripts connect to the external resources to get the test data.
By using this framework we could easily make the test scripts work properly for different sets of test data.
This framework significantly reduces the number of test scripts compared to the module-based framework.
This framework gives more test coverage with reusable tests and flexibility in the execution of tests only when required and by changing only the input test data.
It is reliable in terms of no impact on tests by changing the test data but it has its own drawbacks such as testers who work on this framework needs to have the hands-on programming knowledge to develop test scripts
Advantages of a Data-Driven Framework:
- It supports multiple data sets
- Modifying the test scripts won’t affect the test data
- No need to hardcode test data
- Saves time by executing more tests
Disadvantages of a Data-Driven Framework:
- Require coding skills
- Setting up the framework and test data takes more time
- Need experienced automation testers to design framework
How to handle excel sheets using Selenium for Data Driven Testing Framework
Keyword Driven Testing Framework:
It is also known as table-driven testing or action word based testing.
In Keyword-driven testing, we use a table format to define keywords or action words for each function or method that we would execute.
It performs automation test scripts based on the keywords specified in the excel sheet.
By using this Framework, testers can work with keywords to develop any test automation script, testers with less programming knowledge would also be able to work on the test scripts.
The logic to read keywords and call the required action mentioned in the external excel sheet is placed in the main class. Keyword-driven testing is similar to data-driven testing.
Even though to work on this framework doesn’t require much programming skills but the initial setup ( implement the framework) requires more expertise.
Advantages of Keyword-Driven Frameworks:
- No need to be an expert to write test scripts
- It is possible to reuse the code. We can point the different scripts to the same keyword
- Even though application changes, test scripts don’t change.
- Tests can be designed before developing the application
- Test scripts work independently of an application under test with basic modifications
- Not dependent on test tools
Disadvantages of Keyword-Driven Frameworks:
- Take more time to design
- The initial cost is high
- Employees with good test automation skills needed
Hybrid Driven Testing Framework:
Hybrid Test automation framework is the combination of two or more frameworks mentioned above. It attempts to leverage the strengths and benefits of other frameworks for the particular test environment it manages. Most of the teams are building this hybrid driven framework in the current market.
Behavior Driven Development Testing Framework:
The purpose of this Behavior Driven Development framework is to create a platform that allows everyone (such as Business Analysts, Developers, Testers, etc,) to participate actively. It requires increased collaboration between Development and Test Teams. It doesn’t require the users to be acquainted with a programming language. We use non-technical, natural language to create test specifications. Some of the tools available in the market for Behavior Driven Development is JBehave , Cucumber , etc.,
The frameworks stated above are some of the most popular Test Automation Frameworks used by the automation testers.
- Even though we have seen different types of test automation frameworks. Popular test automation frameworks out of all are Data driven framework, Keyword driven framework, and Hybrid framework.
- In the Data-Driven Framework, we keep test data in excel sheets & use TestNG’s data provider to execute test cases.
- In Keyword driven framework, we define keywords in the excel sheet and the code will call this file to execute the test cases
- The hybrid framework is a combination of both Data-driven and Keyword driven frameworks.
- Selenium Architecture
- Why WebDriver driver = new FirefoxDriver();
- How Much Java Is Required To learn Selenium
- How To Explain Automation Framework In An Interview
- Selenium Interview Questions
- TestNG Interview Questions