Framework Types in Selenium
Selenium automation frameworks are structured approaches used to organize, develop, execute, maintain, and scale automated test cases. Different framework types solve different automation problems such as code reusability, test-data management, modularity, business-readable scenarios, and large-scale test execution.
In real Selenium projects, framework types are often combined. For example, a project may use Page Object Model (POM) + Data-Driven Testing + TestNG + Maven + reusable utilities + reporting + CI/CD as one hybrid automation architecture.
Course Resource: Selenium Training | Register for Course Demo
1. What Are Framework Types?
Framework types represent different ways of organizing automated test scripts and supporting components. Each type focuses on a particular requirement.
Automation Framework Types
|
+-- Linear Framework
+-- Modular Framework
+-- Library-Based Framework
+-- Data-Driven Framework
+-- Keyword-Driven Framework
+-- Hybrid Framework
+-- BDD Framework
+-- Page Object Model
+-- Layered Framework
These approaches are not always mutually exclusive. A modern Selenium framework may combine several of them according to project requirements.
2. Why Are Different Framework Types Required?
Different automation projects have different requirements. A small application may need only simple scripts, while a large enterprise application may require hundreds or thousands of automated tests.
For example:
- A small proof-of-concept may use a simple linear approach.
- A medium project may benefit from modular design.
- An application with many input combinations may require data-driven testing.
- A project with business-readable test scenarios may use BDD.
- A large enterprise project may combine multiple approaches into a hybrid framework.
3. Major Selenium Framework Types
| Framework Type | Main Purpose |
| Linear Framework | Execute test steps sequentially. |
| Modular Framework | Divide tests into reusable modules. |
| Library-Based Framework | Create reusable libraries and functions. |
| Data-Driven Framework | Separate test data from test logic. |
| Keyword-Driven Framework | Represent actions using keywords. |
| Hybrid Framework | Combine multiple framework approaches. |
| BDD Framework | Describe application behavior in business-readable language. |
| Page Object Model | Separate page-specific UI code from test logic. |
| Layered Framework | Separate automation responsibilities into logical layers. |
4. Linear Automation Framework
A Linear Automation Framework is the simplest approach to automation. Test steps are written sequentially in a single script or test method.
The script generally follows the same order as a manual test case.
Open Browser
↓
Open Application
↓
Enter Username
↓
Enter Password
↓
Click Login
↓
Verify Dashboard
↓
Logout
↓
Close Browser
Example
WebDriver driver = new ChromeDriver();
driver.get("https://example.com");
driver.findElement(By.id("username"))
.sendKeys("admin");
driver.findElement(By.id("password"))
.sendKeys("admin123");
driver.findElement(By.id("login"))
.click();
Assert.assertTrue(
driver.getTitle().contains("Dashboard")
);
driver.quit();
5. Advantages of Linear Framework
- Very easy to understand.
- Simple to create.
- Requires less initial framework design.
- Useful for learning Selenium.
- Useful for small proof-of-concept automation.
- Easy for beginners to follow.
6. Disadvantages of Linear Framework
- Limited code reusability.
- Duplicate code is common.
- Maintenance becomes difficult as tests increase.
- Locators may be repeated across scripts.
- Test data may become hard-coded.
- Changes in common functionality may require many updates.
- Not suitable for large automation suites without further structure.
7. When to Use Linear Framework?
A linear approach can be useful for:
- Learning Selenium basics.
- Small automation tasks.
- Proof-of-concept projects.
- Quick demonstrations.
- Very small test suites.
8. Modular-Based Framework
A Modular Framework divides an application or test suite into smaller functional modules.
For an e-commerce application, modules might include:
Login Module
Search Module
Product Module
Cart Module
Checkout Module
Payment Module
Order Module
Logout Module
Each module can contain reusable methods related to a particular functionality.
9. Example of Modular Framework
public class LoginModule {
public void login(
WebDriver driver,
String username,
String password) {
driver.findElement(By.id("username"))
.sendKeys(username);
driver.findElement(By.id("password"))
.sendKeys(password);
driver.findElement(By.id("login"))
.click();
}
}
The same login() method can be reused by multiple test scenarios.
10. Modular Framework Flow
Test Case
|
+-- Login Module
|
+-- Search Module
|
+-- Cart Module
|
+-- Checkout Module
|
+-- Logout Module
11. Advantages of Modular Framework
- Improves code reusability.
- Reduces duplicate code.
- Makes functionality easier to manage.
- Improves maintainability.
- Allows teams to work on separate modules.
- Makes debugging easier.
12. Disadvantages of Modular Framework
- Requires additional design effort.
- Modules need to be maintained properly.
- Shared dependencies must be managed carefully.
- Complex workflows may require additional framework layers.
13. Library-Based Framework
A Library-Based Framework creates reusable libraries or utility methods for common automation operations.
Instead of writing the same Selenium operation repeatedly, a reusable method is created once and called whenever required.
Common Utility Operations
- Click element
- Enter text
- Select dropdown
- Wait for element
- Take screenshot
- Switch window
- Switch frame
- Scroll page
- Read configuration
- Read test data
14. Library Framework Example
public class BrowserUtils {
public static void click(
WebDriver driver,
By locator) {
driver.findElement(locator).click();
}
public static void enterText(
WebDriver driver,
By locator,
String text) {
driver.findElement(locator).clear();
driver.findElement(locator).sendKeys(text);
}
}
Test code can then use:
BrowserUtils.enterText(
driver,
By.id("username"),
"admin"
);
BrowserUtils.click(
driver,
By.id("login")
);
15. Advantages of Library-Based Framework
- High code reusability.
- Reduces repetitive Selenium code.
- Improves consistency.
- Centralizes common operations.
- Makes test classes shorter.
- Can be combined with other framework approaches.
16. Data-Driven Framework
A Data-Driven Framework separates test data from test logic. The same automation script can execute multiple times using different input data.
Test Script
|
+----------------+
| |
Data 1 Data 2
| |
User A User B
| |
+--------+-------+
|
Same Test Logic
17. Why Data-Driven Framework Is Required?
Consider a login test that must be executed with 100 different username and password combinations.
Without data-driven testing, the test code may need to be duplicated or manually changed.
With a data-driven framework:
One Login Test
+
100 Data Sets
=
100 Executions
The test logic remains the same while the input data changes.
18. Data Sources
Test data can come from different sources:
- Excel
- CSV
- JSON
- XML
- Database
- TestNG DataProvider
- Properties files
- API responses
19. TestNG DataProvider Example
@DataProvider(name = "loginData")
public Object[][] loginData() {
return new Object[][] {
{"admin", "admin123"},
{"tester", "test123"},
{"manager", "manager123"}
};
}
@Test(dataProvider = "loginData")
public void loginTest(
String username,
String password) {
System.out.println(username);
System.out.println(password);
}
20. Data-Driven Framework Flow
External Test Data
|
↓
Data Reader
|
↓
TestNG DataProvider
|
↓
Test Method
|
↓
Selenium WebDriver
|
↓
Application
|
↓
Assertion
|
↓
Report
21. Advantages of Data-Driven Framework
- Separates data from test logic.
- Allows multiple datasets.
- Reduces duplicate test code.
- Improves test coverage.
- Makes test data easier to update.
- Useful for form validation.
- Useful for boundary and negative testing.
- Works well with TestNG DataProvider.
22. Disadvantages of Data-Driven Framework
- Test data must be maintained carefully.
- External data files can become large.
- Data-to-test mapping must be clear.
- Failure analysis can become difficult if data is poorly organized.
- Additional utilities may be required to read external data.
23. Keyword-Driven Framework
A Keyword-Driven Framework represents automation actions using predefined keywords.
Instead of directly writing Selenium commands for every test step, a keyword identifies the operation that the framework should perform.
| Keyword | Action |
| OPEN | Open application |
| TYPE | Enter text |
| CLICK | Click element |
| SELECT | Select option |
| VERIFY | Validate result |
| WAIT | Wait for condition |
| SCREENSHOT | Capture screenshot |
| CLOSE | Close browser |
24. Keyword-Driven Example
Action Object Value
OPEN Browser Chrome
NAVIGATE URL https://example.com
TYPE Username admin
TYPE Password admin123
CLICK LoginButton
VERIFY Dashboard Displayed
CLOSE Browser
The framework contains the implementation of each keyword.
25. Keyword Execution Flow
Test Data / Keyword File
|
↓
Keyword Reader
|
↓
Keyword Mapping
|
↓
Action Library
|
↓
Selenium WebDriver
|
↓
Browser
|
↓
Result
26. Advantages of Keyword-Driven Framework
- Actions are represented consistently.
- Test definitions can be easier to read.
- Reusable keywords can be used across many tests.
- Test logic can be separated from implementation.
- Can help teams where multiple contributors need a common action vocabulary.
27. Disadvantages of Keyword-Driven Framework
- Initial development can be complex.
- Keyword libraries require maintenance.
- Too many keywords can make the framework difficult to understand.
- Complex business workflows may be difficult to represent using simple keywords.
- Debugging may require tracing from the keyword to its implementation.
28. Hybrid Framework
A Hybrid Framework combines two or more automation approaches to create a flexible automation architecture.
A Selenium hybrid framework may combine:
- Modular Framework
- Data-Driven Framework
- Keyword-Driven Framework
- Page Object Model
- TestNG
- Maven
- Reusable utilities
- Configuration management
- Reporting
- Logging
- CI/CD
29. Hybrid Framework Architecture
Hybrid Framework
|
+-------------------+-------------------+
| | |
Test Layer Page Object Layer Data Layer
| | |
TestNG POM Classes Excel / JSON
| | |
+-------------------+-------------------+
|
Utility Layer
|
+----------------+----------------+
| | |
Waits Screenshots Config
| | |
+----------------+----------------+
|
Driver Factory
|
WebDriver
|
Browser
30. Example Hybrid Framework Structure
selenium-framework/
|
+-- pom.xml
|
+-- src/
| |
| +-- main/java/
| | |
| | +-- pages/
| | +-- utilities/
| | +-- factory/
| | +-- config/
| |
| +-- test/java/
| |
| +-- tests/
| +-- base/
| |
| +-- resources/
| +-- config.properties
| +-- testdata/
| +-- testng.xml
|
+-- reports/
+-- screenshots/
+-- logs/
31. Advantages of Hybrid Framework
- Combines multiple useful approaches.
- Highly reusable.
- Can support large test suites.
- Supports data-driven testing.
- Supports Page Object Model.
- Supports modular architecture.
- Can support parallel execution.
- Can integrate with CI/CD.
- Provides flexibility for different test scenarios.
32. Disadvantages of Hybrid Framework
- Higher initial setup effort.
- Requires framework design knowledge.
- Can become over-engineered.
- More components need to be maintained.
- New team members need to understand the architecture.
33. Behavior-Driven Development Framework
Behavior-Driven Development (BDD) is an approach in which application behavior is described in a business-readable format.
Cucumber is a commonly used BDD tool with Selenium in Java projects.
BDD scenarios commonly use Given, When, Then terminology.
34. BDD Example
Feature: Login
Scenario: Valid Login
Given user opens the login page
When user enters valid username and password
And user clicks the login button
Then user should see the dashboard
35. BDD Architecture
Feature File
|
↓
Step Definitions
|
↓
Page Objects
|
↓
Selenium WebDriver
|
↓
Browser
|
↓
Application
36. Advantages of BDD Framework
- Scenarios can be readable by technical and non-technical stakeholders.
- Encourages collaboration around expected behavior.
- Feature files can provide business-readable documentation.
- Helps connect requirements with automated scenarios.
- Works well with Agile development when the team actually uses the scenarios collaboratively.
37. Disadvantages of BDD Framework
- Introduces additional feature files and step definitions.
- Step definitions require maintenance.
- Duplicated or poorly designed steps can increase complexity.
- Not every technical test requires BDD.
- BDD adds value primarily when business-readable behavior is genuinely useful.
38. Page Object Model (POM)
Page Object Model is a design pattern commonly used in Selenium automation. It represents application pages or meaningful UI components as objects and keeps page-specific locators and operations in dedicated classes.
POM is often used together with other framework types rather than being treated as a completely separate execution framework.
Login Page
|
+-- username locator
+-- password locator
+-- login button
|
+-- enterUsername()
+-- enterPassword()
+-- clickLogin()
39. POM Example
public class LoginPage {
private WebDriver driver;
private By username =
By.id("username");
private By password =
By.id("password");
private By loginButton =
By.id("login");
public LoginPage(WebDriver driver) {
this.driver = driver;
}
public void login(
String user,
String pass) {
driver.findElement(username)
.sendKeys(user);
driver.findElement(password)
.sendKeys(pass);
driver.findElement(loginButton)
.click();
}
}
With POM, page-specific implementation is separated from test scenarios, which helps reduce duplicated UI interaction code and centralize UI changes.
40. Advantages of POM
- Improves code organization.
- Reduces locator duplication.
- Improves maintainability.
- Improves test readability.
- Separates test intent from page interaction details.
- Makes UI changes easier to manage.
- Encourages reusable page operations.
41. Layered Automation Framework
A Layered Framework divides automation responsibilities into separate layers.
Test Layer
↓
Business / Workflow Layer
↓
Page Object Layer
↓
Utility Layer
↓
Driver Layer
↓
Browser / Application
Typical Responsibilities
| Layer | Responsibility |
| Test Layer | Defines test scenarios and assertions. |
| Business Layer | Represents reusable business workflows. |
| Page Layer | Handles UI elements and page interactions. |
| Utility Layer | Provides reusable technical operations. |
| Driver Layer | Creates and manages WebDriver. |
42. Linear vs Modular Framework
| Feature | Linear | Modular |
| Structure | Sequential | Module-based |
| Reusability | Low | Higher |
| Duplicate Code | More likely | Reduced |
| Maintenance | Becomes difficult as suite grows | Easier |
| Complexity | Low | Medium |
43. Modular vs Data-Driven Framework
| Feature | Modular | Data-Driven |
| Main Focus | Functional modules | Test data separation |
| Reusability | High | High |
| Data Separation | Not the primary purpose | Core purpose |
| Useful For | Reusable workflows | Multiple input combinations |
44. Data-Driven vs Keyword-Driven Framework
| Feature | Data-Driven | Keyword-Driven |
| Primary Focus | Test data | Test actions |
| Data Separation | Strong | Usually present |
| Action Representation | Normal test code | Keywords |
| Example | Excel/CSV + TestNG | CLICK/TYPE/VERIFY |
| Main Benefit | Multiple datasets | Reusable action vocabulary |
45. Keyword-Driven vs BDD Framework
| Feature | Keyword-Driven | BDD |
| Focus | Actions/keywords | Application behavior |
| Typical Format | Keyword tables or definitions | Given/When/Then |
| Main Goal | Separate action definitions from test execution | Improve shared understanding of behavior |
| Common Tool | Custom keyword engine or automation tool | Cucumber |
46. Hybrid vs Other Framework Types
| Framework | Primary Strength | Typical Challenge |
| Linear | Simplicity | Low reusability |
| Modular | Reusable modules | Requires design |
| Library-Based | Reusable utilities | Library maintenance |
| Data-Driven | Multiple datasets | Data management |
| Keyword-Driven | Reusable actions | Keyword complexity |
| BDD | Business-readable behavior | Feature/step maintenance |
| Hybrid | Combines multiple approaches | Higher architecture complexity |
47. Framework Types Are Often Combined
It is important to understand that these framework types are not always completely separate.
A real Selenium project can have:
Hybrid Framework
|
+-- Modular Design
|
+-- Page Object Model
|
+-- Data-Driven Testing
|
+-- Reusable Libraries
|
+-- TestNG
|
+-- Maven
|
+-- Configuration
|
+-- Reporting
|
+-- Logging
|
+-- CI/CD
48. Example of a Real Selenium Hybrid Framework
Consider an e-commerce application.
The framework may contain:
- LoginPage: Login page interactions.
- HomePage: Home page interactions.
- ProductPage: Product selection.
- CartPage: Cart operations.
- CheckoutPage: Checkout operations.
- TestNG: Test execution.
- DataProvider: Multiple datasets.
- Utilities: Waits, screenshots, configuration.
- Reports: Execution results.
- CI/CD: Automated execution.
49. Real-World Execution Flow
TestNG Test
|
↓
Load Configuration
|
↓
Create WebDriver
|
↓
Initialize Page Objects
|
↓
Read Test Data
|
↓
Execute Business Flow
|
↓
Selenium WebDriver
|
↓
Browser
|
↓
Application
|
↓
Assertion
|
+------→ Screenshot
|
+------→ Logs
|
+------→ Report
|
↓
Test Result
50. Choosing a Framework Type
Framework selection should be based on actual project requirements rather than simply choosing the most complicated architecture.
| Requirement | Useful Approach |
| Very small automation | Linear |
| Reusable functionality | Modular / Library-Based |
| Many input combinations | Data-Driven |
| Reusable action vocabulary | Keyword-Driven |
| Business-readable scenarios | BDD |
| Page-level UI abstraction | POM |
| Multiple requirements together | Hybrid |
51. Common Mistake: Calling Every Tool a Framework
TestNG, Maven, Selenium, Cucumber, POM, and reporting libraries do not all represent the same kind of thing.
| Technology / Concept | Role |
| Selenium WebDriver | Browser automation |
| TestNG | Test execution and organization |
| Maven | Build and dependency management |
| POM | Design pattern |
| Cucumber | BDD tool |
| DataProvider | Test data parameterization mechanism in TestNG |
| Reporting Library | Test result reporting |
Understanding these distinctions is important for Selenium interviews and real framework design.
52. Framework Evolution
An automation project may evolve gradually as requirements increase.
Linear Scripts
↓
Modular Design
↓
Reusable Libraries
↓
Data-Driven Testing
↓
Page Object Model
↓
Hybrid Architecture
↓
CI/CD + Parallel + Grid
This does not mean every project must follow every stage. Framework architecture should evolve according to actual needs.
53. Common Mistakes in Framework Selection
- Choosing a complex framework for a tiny project.
- Adding tools without a clear purpose.
- Creating too many abstraction layers.
- Using BDD without meaningful business collaboration.
- Creating a huge keyword library that becomes difficult to maintain.
- Ignoring test data requirements.
- Ignoring application architecture.
- Not considering team skills.
- Not planning for maintenance.
- Hard-coding configuration values throughout the framework.
54. Best Practices for Framework Types
- Choose the framework according to project requirements.
- Keep the architecture understandable.
- Use reusable components.
- Separate test data from test logic when appropriate.
- Use Page Object Model for UI abstraction where useful.
- Centralize WebDriver creation.
- Use explicit synchronization.
- Keep tests independent where practical.
- Use meaningful naming conventions.
- Integrate reporting and logging.
- Use version control.
- Support CI/CD when required.
- Avoid unnecessary complexity.
- Document framework usage for the team.
55. Interview Question: What Are the Types of Selenium Frameworks?
Answer: Common Selenium automation framework approaches include Linear, Modular, Library-Based, Data-Driven, Keyword-Driven, Hybrid, and BDD frameworks. Page Object Model is commonly used as a design pattern within these architectures.
56. Interview Question: What Is a Linear Framework?
Answer: A Linear Framework executes automation steps sequentially in a test script. It is simple to create and understand but provides limited reusability and can become difficult to maintain as the test suite grows.
57. Interview Question: What Is a Modular Framework?
Answer: A Modular Framework divides an application or test suite into independent reusable modules such as login, search, cart, checkout, and payment. Test cases can combine these modules to create complete workflows.
58. Interview Question: What Is a Data-Driven Framework?
Answer: A Data-Driven Framework separates test data from test logic so that the same test can execute with multiple datasets. Data may come from Excel, CSV, JSON, databases, or TestNG DataProvider.
59. Interview Question: What Is a Keyword-Driven Framework?
Answer: A Keyword-Driven Framework represents test actions using predefined keywords such as CLICK, TYPE, SELECT, WAIT, and VERIFY. The framework maps each keyword to its corresponding automation implementation.
60. Interview Question: What Is a Hybrid Framework?
Answer: A Hybrid Framework combines two or more automation approaches. A Selenium hybrid framework may combine POM, modular design, data-driven testing, reusable utilities, TestNG, Maven, configuration management, reporting, logging, and CI/CD.
61. Interview Question: What Is BDD Framework?
Answer: A BDD framework focuses on describing application behavior in a readable format. Tools such as Cucumber use Gherkin syntax with keywords such as Given, When, Then, And, and But to connect readable scenarios with automation code.
62. Interview Question: Is POM a Framework Type?
Answer: Page Object Model is more accurately described as a design pattern. It is commonly incorporated into Selenium automation frameworks to organize page-specific locators and actions and to reduce duplication.
63. Interview Question: Which Framework Is Suitable for Multiple Test Data?
Answer: A Data-Driven Framework is designed specifically for scenarios where the same test logic needs to run against multiple input datasets.
64. Interview Question: Which Framework Combines Multiple Approaches?
Answer: A Hybrid Framework combines multiple approaches such as modular, data-driven, keyword-driven, POM, and reusable library techniques according to project requirements.
65. Quick Revision Table
| Framework | Remember |
| Linear | Sequential scripts |
| Modular | Reusable functional modules |
| Library-Based | Reusable helper functions |
| Data-Driven | Separate test data from logic |
| Keyword-Driven | Actions represented by keywords |
| BDD | Business-readable behavior |
| POM | Page-level UI abstraction/design pattern |
| Hybrid | Combination of multiple approaches |
| Layered | Responsibilities divided into layers |
66. Complete Framework Type Comparison
| Type | Reusability | Data Separation | Complexity | Typical Use |
| Linear | Low | Low | Low | Small scripts |
| Modular | Medium/High | Optional | Medium | Reusable workflows |
| Library-Based | High | Optional | Medium | Common operations |
| Data-Driven | High | High | Medium | Multiple datasets |
| Keyword-Driven | High | Usually | High | Action abstraction |
| BDD | High | Optional | Medium/High | Behavior collaboration |
| Hybrid | Very High | High | High | Large automation projects |
67. Practical Project Example
Suppose a company wants to automate an online shopping application.
Application Modules
Login
Search
Product Details
Cart
Checkout
Payment
Order History
Framework Design
Hybrid Framework
|
+-- POM
+-- Modular Workflows
+-- Data-Driven Testing
+-- TestNG
+-- Maven
+-- Utilities
+-- Configuration
+-- Reporting
+-- Logging
+-- CI/CD
Sample Test Cases
TC01 - Valid Login
TC02 - Invalid Login
TC03 - Search Product
TC04 - Add Product to Cart
TC05 - Remove Product
TC06 - Checkout
TC07 - Place Order
TC08 - Verify Order History
68. Practical Login Test Using Hybrid Concepts
@Test(dataProvider = "loginData")
public void validLoginTest(
String username,
String password) {
LoginPage loginPage =
new LoginPage(driver);
loginPage.login(
username,
password
);
Assert.assertTrue(
driver.getTitle().contains("Dashboard")
);
}
This small example demonstrates how Page Object Model and Data-Driven Testing can work together inside a larger hybrid architecture.
69. Framework Type Selection Checklist
- How large is the application?
- How many tests need to be automated?
- How many testers will maintain the framework?
- How much test data is required?
- Are business stakeholders involved in reviewing scenarios?
- Are multiple browsers required?
- Are multiple environments required?
- Is parallel execution required?
- Is CI/CD integration required?
- Does the project require remote execution?
- How frequently does the UI change?
- What level of reporting is required?
70. Final Summary
Framework types provide different approaches for organizing Selenium automation. Linear Frameworks focus on sequential execution, Modular Frameworks divide functionality into reusable modules, Library-Based Frameworks provide reusable operations, Data-Driven Frameworks separate test data from logic, Keyword-Driven Frameworks represent actions through keywords, and BDD Frameworks describe behavior in a business-readable form.
Page Object Model is an important design pattern for separating page-specific UI implementation from test logic. A Hybrid Framework combines multiple approaches and is commonly used when a project needs reusable page objects, test data management, modular workflows, reporting, configuration, and CI/CD support.
Linear
↓
Modular
↓
Reusable Libraries
↓
Data-Driven
↓
Page Object Model
↓
Hybrid Architecture
↓
CI/CD + Parallel + Remote Execution
The most important point is that framework selection should be based on project size, test complexity, data requirements, team skills, maintainability, scalability, and business needs. A framework should solve real automation problems without introducing unnecessary complexity.
71. Selenium Training Resources
For detailed learning of Selenium WebDriver, framework design, TestNG, Page Object Model, data-driven testing, hybrid frameworks, and practical automation projects, explore:
72. One-Line Revision
Linear executes steps sequentially, Modular divides functionality, Library-Based creates reusable functions, Data-Driven separates data, Keyword-Driven uses action keywords, BDD focuses on behavior, POM organizes page interactions, and Hybrid combines multiple approaches into one automation architecture.