In today’s newsletter we are going to discuss
What is Selenium Framework ?
Data Driven Test Framework
Keyword Driven Test Framework
Hybrid Test Framework
GitHub Repo
What is Selenium Framework?
A Selenium framework is a set of best practices, coding standards, guidelines, and tools that help QA engineers design and develop efficient, robust, and maintainable automated test scripts using Selenium, a popular open-source tool for web automation.
Without frameworks, we will place the “code” and “data” in the same place which is neither re-usable nor readable.
There are mainly three types of frameworks created by Selenium WebDriver to automate manual test cases:
Data-Driven Test Framework
Keyword Driven Test Framework
Hybrid Test Framework
Data Driven Framework
Data-Driven Testing is a test automation framework where test data is separated from the test script.
Instead of hardcoding the test data directly into the script, the data is stored in external sources like Excel sheets, CSV files, XML files, or databases.
During the test execution, the testing framework retrieves this data and uses it to feed the test script.
Apache POI is a popular Java library for reading and writing Excel, Word, and PowerPoint. It allows developers to create, modify, and read documents in various formats.
Here is the excel we want to read:
Here are the steps we need to follow to read the above excel
Step 1: Add Apache POI Dependency
Step 2: Data-Driven Test Class to read excel file
Create a utility class for reading data from Excel using XSSF.
Step 3: TestNG Data Provider
Create a TestNG data provider method to provide data to your test methods:
Step 4: Use Data in Test Methods
Use the data retrieved from Excel in your test methods
Keyword Driven Framework
In this framework, test cases are designed in Excel sheet where column representing different keywords such as keywords, action and data.
Here is the excel we want to read:And here is the sample code:
Hybrid Driven Framework
A Hybrid Selenium Framework combines the features and advantages of different types of automation frameworks, typically Data-Driven and Keyword-Driven frameworks.
This approach provides the flexibility to utilize both data-driven testing, where test data is kept separate from the test script, and keyword-driven testing, where test steps are represented as keywords and stored in an external repository.
Here is the sample code
Step 1: Create Keyword file
Here we have created keyword file and added two keywords.
1. Login
2. Logout
Step 2: Create Login Page
Step 3: Create Hybrid Test
A TestNG test class that uses both data-driven and keyword-driven approaches. Here, data from the Excel file is passed to the test case, and keywords are used to perform actions.
Advantages of a Hybrid Framework:
Modularity: Separation of concerns allows changes in test data or keywords without affecting the test scripts, enhancing maintainability.
Reusability: Reusable components and keywords reduce redundancy and promote efficient use of code.
Readability: Test cases are written in a natural language style using keywords, making them easy to understand for non-technical stakeholders.
Scalability: Easily scalable for complex applications with a large number of test cases due to its modular and organized structure.
Flexibility: Supports various types of testing, including regression, functional, and integration testing, offering flexibility in test case design.
GitHub Repository
You can find code of this newsletter issue at this GitHub Repository
"Success is the sum of small efforts, repeated day in and day out." —Robert Collier
Let’s Connect on Social Media
Connect with me on LinkedIn (7.3K+ Followers) and Twitter.
Well Structured organized way of creating different frameworks with clean code. Thank you so much Dhara for sharing and helping many become aware of different frameworks with examples.
Wonderful explanation about selenium framework-what is selenium, with and without it what could be the scenarios and all.
Also like the part that covered the types of framework-data driver, keyword & hybrid and with examples, advantages and it's explanation.
Perfectly explained with all the possible examples and the most importantly it's easy to understand and you made it more simpler for beginners and for everyone...
Always liked the way you present and explain the things with examples.... I am happy to get such newsletter.....Thank you so much for such amazing newsletter 🙌🙌🙌💯