Why Build an Automation Framework?

Building an Automation Framework serves two important purposes.

1. Interview Preparation

One of the most common SDET interview questions is:

"Explain your Automation Framework."

Advertisement

Interviewers expect you to understand every layer of the framework rather than simply using Selenium scripts.

2. Professional Portfolio

A complete framework hosted on GitHub demonstrates practical automation skills far better than certifications alone.

Before beginning this roadmap, you should have a working understanding of:

If required, complete the Java for Testers Guide and Complete Selenium Guide before continuing.


Stage 0 — Plan Before You Code

Make These Decisions First

Planning your framework architecture early prevents unnecessary restructuring later.

Decision Recommended Choice
Framework Type Hybrid (Page Object Model + Data-Driven + Keyword-Driven)
Programming Language Java
Automation Tool Selenium WebDriver
Test Runner TestNG
Build Tool Maven
Reporting Extent Reports
Logging Log4j
Test Data Excel (Apache POI), Properties, JSON
CI/CD Jenkins

Continue Learning: How to Explain Your Automation Framework


Stage 1 — Project Skeleton (Days 1–2)

Create the Maven Project

Begin by creating the project structure.

src/main/java
├── base/
│   └── BaseTest.java
├── config/
│   └── ConfigReader.java
├── pages/
│   └── LoginPage.java
└── utils/
    ├── BrowserFactory.java
    ├── WaitUtils.java
    ├── ScreenshotUtil.java
    └── ExcelUtil.java

src/test/java
└── tests/
    └── LoginTest.java

src/test/resources
├── config.properties
├── log4j2.xml
└── testng.xml

pom.xml

Required Maven Dependencies

Include dependencies for:

  • Selenium WebDriver
  • TestNG
  • WebDriverManager
  • Extent Reports
  • Log4j
  • Apache POI
  • Commons IO

Continue Learning: E-Commerce Framework: Step-by-Step Build


Stage 2 — Base Layer & Configuration (Days 3–4)

Externalize Configuration

Create a configuration file.

url=https://demo.opencart.com
browser=chrome
username=testuser@email.com
password=Test@123

Build the Base Layer

BaseTest should manage:

  • Browser initialization
  • Driver creation
  • Configuration loading
  • Application launch
  • Driver cleanup

Every test class should inherit from BaseTest.

This is an excellent example of Inheritance, one of the core Object-Oriented Programming concepts frequently discussed during interviews.

Continue Learning: OOP Concepts in Your Framework


Stage 3 — Page Object Model (Days 5–8) ⭐

Build One Page Class Per Screen

The Page Object Model is the foundation of a maintainable Selenium Framework.

public class LoginPage {

    private WebDriver driver;

    private By username = By.id("user");
    private By password = By.id("pass");
    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();

    }

}

Build Page Objects For

  • Login
  • Home
  • Search
  • Cart
  • Checkout
  • Order Confirmation

Continue Learning: Frameworks & Page Object Model


Stage 4 — Utilities (Days 9–11)

Develop reusable utility classes to eliminate duplicate code.

Utility Purpose
BrowserFactory Cross-browser initialization
WaitUtils Explicit Wait wrappers
ScreenshotUtil Capture screenshots on failures
ExcelUtil Read test data using Apache POI
ConfigReader Load application configuration

Best Practice: Avoid using Thread.sleep(). Implement reusable Explicit Wait methods instead.

Continue Learning: Waits & SynchronizationJava Collections in Your Framework


Stage 5 — TestNG Integration (Days 12–14)

Create test classes that interact only with Page Objects.

Business logic and Selenium code should remain inside the framework—not inside the test classes.

Add TestNG Features

  • Annotations
  • Assertions
  • Groups
  • Priorities
  • Data Providers
  • testng.xml

Continue Learning: TestNG EssentialsTestNG Cheat Sheet


Stage 6 — Data-Driven Testing (Days 15–17)

Move all test data outside your automation code.

Typical sources include:

  • Excel
  • JSON
  • Properties Files
  • TestNG @DataProvider

A common data structure:

List<Map<String, String>> testData;

Each map represents one complete test record.

Continue Learning: Data-Driven Testing


Stage 7 — Reporting, Logging & Screenshots (Days 18–20)

Add reporting and debugging capabilities.

Feature Implementation
Extent Reports Generate execution reports
Log4j Record framework activity
Screenshots Capture failures automatically

Screenshot Strategy

Capture screenshots during:

  • @AfterMethod
  • ITestListener.onTestFailure()

Attach screenshots directly to Extent Reports.

Continue Learning: Reporting, Parallel & CI/CD


Stage 8 — Parallel Execution (Days 21–22)

Configure TestNG for parallel execution.

<suite
    name="RegressionSuite"
    parallel="tests"
    thread-count="3">

Important Interview Topic

Parallel execution requires a ThreadLocal WebDriver implementation so that every execution thread owns its own browser instance.

Without ThreadLocal, parallel execution becomes unstable.

Continue Learning: Parallel, Grid & Cross-Browser


Stage 9 — Git & Jenkins (Days 23–25)

Integrate your framework with version control and CI/CD.

  1. Push the project to GitHub.
  2. Configure Maven execution in Jenkins.
  3. Create a Jenkins Pipeline.
  4. Execute the framework automatically after every commit.
  5. Schedule nightly execution using CRON.

Pipeline stages typically include:

Checkout
     ↓
Build
     ↓
Execute Tests
     ↓
Generate Reports
     ↓
Archive Reports

Continue Learning: Complete Git GuideComplete Jenkins Guide


Stage 10 — Explain Your Framework (Day 26+)

The final stage is interview preparation.

Practice explaining your framework architecture confidently.

A typical summary includes:

  • Hybrid Framework
  • Selenium WebDriver
  • Java
  • TestNG
  • Maven
  • Page Object Model
  • Base Layer
  • Utility Layer
  • Test Layer
  • Excel & Properties
  • Extent Reports
  • Log4j
  • Jenkins Integration

Prepare to answer follow-up questions on:

  • Inheritance
  • Encapsulation
  • Parallel Execution
  • Test Data Management
  • Framework Challenges
  • Design Decisions

Continue Learning: How to Explain Your FrameworkComplete SDET Interview Guide


Framework Snapshot

Stage Timeline Deliverable
Stage 0 Planning Technology Stack
Stage 1 Days 1–2 Maven Project Structure
Stage 2 Days 3–4 Base Layer & Configuration
Stage 3 Days 5–8 Page Object Model
Stage 4 Days 9–11 Utility Classes
Stage 5 Days 12–14 TestNG Test Suite
Stage 6 Days 15–17 Data-Driven Framework
Stage 7 Days 18–20 Reporting & Logging
Stage 8 Days 21–22 Parallel Execution
Stage 9 Days 23–25 GitHub & Jenkins Pipeline
Stage 10 Day 26+ Interview-Ready Framework

Five Common Mistakes to Avoid

1. Selenium Code Inside Test Classes

Keep Selenium implementation inside Page Objects.

2. Hardcoded Configuration

Store URLs, credentials, and browser settings externally.

3. Using Thread.sleep()

Prefer reusable Explicit Wait utilities.

4. Ignoring ThreadLocal

Parallel execution requires isolated WebDriver instances.

5. Building Without Explaining

Understanding and explaining the framework architecture is just as important as writing the code.


Next Steps

Continue learning with:

  • Complete Automation Framework Guide
  • E-Commerce Framework Build
  • BDD Hybrid Framework
  • REST Assured Framework Design