Answer
Types of Test Automation Frameworks
1. Linear (Record & Playback)
Tests are recorded and played back. No reuse, no abstraction.
// Everything hardcoded in one test — no structure
@Test
public void test() {
driver.get("https://example.com");
driver.findElement(By.id("user")).sendKeys("alice");
driver.findElement(By.id("pass")).sendKeys("pass123");
driver.findElement(By.id("btn")).click();
Assert.assertEquals(driver.getTitle(), "Dashboard");
}
// ❌ Not reusable, breaks on any UI change
2. Modular Framework
Tests broken into reusable modules (login module, checkout module).
// Modules are reusable methods
public class AuthModule {
public static void login(WebDriver d, String user, String pass) {
d.findElement(By.id("user")).sendKeys(user);
d.findElement(By.id("pass")).sendKeys(pass);
d.findElement(By.id("btn")).click();
}
}
// Tests call the module
AuthModule.login(driver, "alice", "pass123");
3. Data-Driven Framework
Test logic is fixed; test data comes from external source (Excel, CSV, JSON, DB).
// TestNG DataProvider reads from Excel
@DataProvider(name = "loginData")
public Object[][] getLoginData() throws IOException {
return ExcelUtil.readData("testdata/login.xlsx", "LoginSheet");
// Returns: [["alice","pass1","valid"], ["wrong","pass","invalid"], ...]
}
@Test(dataProvider = "loginData")
public void testLogin(String user, String pass, String expected) {
loginPage.login(user, pass);
Assert.assertEquals(loginPage.getResult(), expected);
}
// Same test code runs with 10 different data sets
4. Keyword-Driven Framework
Actions are defined as keywords in a spreadsheet. Non-technical staff can write tests.
| Keyword | Object | Value |
|----------------|--------------|-------------------|
| OpenBrowser | Chrome | |
| NavigateTo | | https://example.com|
| EnterText | emailField | alice@test.com |
| EnterText | passwordField | pass123 |
| Click | loginButton | |
| VerifyText | welcomeMsg | Welcome Alice |
// Framework reads keywords and executes them
switch (keyword) {
case "OpenBrowser": DriverManager.init(value); break;
case "EnterText": driver.findElement(OR.get(object)).sendKeys(value); break;
case "Click": driver.findElement(OR.get(object)).click(); break;
}
5. Hybrid Framework (Most Common in Industry)
Combines Data-Driven + Keyword-Driven + POM. Most enterprise frameworks are hybrid.
Hybrid Framework =
POM (page classes, locators separated)
+ Data-Driven (Excel/JSON test data)
+ Modular (reusable utilities)
+ Reporting (Extent/Allure)
+ Config (properties file for env/browser)
+ Logging (Log4j)
6. BDD Framework (Behaviour Driven Development)
Tests written in Gherkin (plain English). Business + Dev + QA collaborate.
# login.feature
Feature: User Login
Scenario: Valid login
Given user is on the login page
When user enters email "alice@test.com" and password "Pass@123"
And user clicks the login button
Then user should be redirected to dashboard
And welcome message should be displayed
// Step definitions — connects Gherkin to Selenium code
@Given("user is on the login page")
public void navigateToLogin() {
driver.get("https://example.com/login");
}
@When("user enters email {string} and password {string}")
public void enterCredentials(String email, String pass) {
loginPage.enterEmail(email);
loginPage.enterPassword(pass);
}
Framework Comparison
| Framework | Maintenance | Skill Required | Reusability |
|---|---|---|---|
| Linear | Very Hard | Low | None |
| Modular | Medium | Medium | Medium |
| Data-Driven | Easy | Medium | High |
| Keyword-Driven | Easy | Low (users) / High (builders) | High |
| Hybrid | Easy | High | Very High |
| BDD | Medium | Medium | High |
