</>

Technology

Page Object Model

Difficulty

Beginner

Interview Question

What are the different types of test automation frameworks?

Answer

Types of Test Automation Frameworks

1. Linear (Record & Playback)

Tests are recorded and played back. No reuse, no abstraction.

Java
// 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
Use when: Quick POC, small one-time scripts

2. Modular Framework

Tests broken into reusable modules (login module, checkout module).

Java
// 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");
Use when: Medium projects, small teams

3. Data-Driven Framework

Test logic is fixed; test data comes from external source (Excel, CSV, JSON, DB).

Java
// 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
Use when: Multiple data combinations (login, registration, payment)

4. Keyword-Driven Framework

Actions are defined as keywords in a spreadsheet. Non-technical staff can write tests.

CODE
| Keyword        | Object        | Value             |
|----------------|--------------|-------------------|
| OpenBrowser    | Chrome        |                   |
| NavigateTo     |               | https://example.com|
| EnterText      | emailField    | alice@test.com    |
| EnterText      | passwordField | pass123           |
| Click          | loginButton   |                   |
| VerifyText     | welcomeMsg    | Welcome Alice     |
Java
// 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;
}
Use when: Business analysts/manual testers write test cases

5. Hybrid Framework (Most Common in Industry)

Combines Data-Driven + Keyword-Driven + POM. Most enterprise frameworks are hybrid.

CODE
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.

Gherkin
# 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
Java
// 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);
}
Use when: Cross-functional teams, living documentation needed

Framework Comparison

FrameworkMaintenanceSkill RequiredReusability
LinearVery HardLowNone
ModularMediumMediumMedium
Data-DrivenEasyMediumHigh
Keyword-DrivenEasyLow (users) / High (builders)High
HybridEasyHighVery High
BDDMediumMediumHigh

Follow AutomateQA

Related Topics