QAPage – Software Testing Jobs, QA Resources & Careers

QAPage Navigation & Directory
Type any keyword to search live pages, tools, or press Search to query site-wide.

Automation Framework Development 

Automation Framework Development

Automation Framework Development means creating a proper structure for automation testing so that test scripts are easy to write, run, maintain, and reuse.
For example, instead of writing separate Selenium code for every login test, we can create reusable methods, store test data in Excel, capture screenshots when tests fail, and generate reports automatically.
Let’s understand all 20 topics in simple language.

1. What Is a Framework and Why Is It Needed?

An automation framework is a set of rules, folders, reusable code, tools, and libraries used to organize automation testing.
Without a framework, testers may write all their Selenium code in one file. As the project grows, the code becomes difficult to understand and maintain.
Why do we need a framework?
  • To reuse code instead of writing it repeatedly.
  • To make test scripts easier to maintain.
  • To manage test data separately.
  • To generate test reports.
  • To capture screenshots when tests fail.
  • To run multiple test cases in an organized way.
Example: In an e-commerce application, many test cases need to log in. Instead of writing login code in every test, we create one reusable login method.

2. Linear Framework

A Linear Framework is the simplest type of automation framework. In this approach, the tester writes all the test steps in a single script, one after another.
It is also commonly called a record-and-playback or basic scripting approach, although these terms are not exactly identical.
Example: A Selenium script performs these steps:
  1. Open the website.
  2. Enter the username.
  3. Enter the password.
  4. Click Login.
  5. Verify the dashboard.
All the steps are written directly in one script.
Advantages:
  • Easy for beginners to understand.
  • Simple to create for small tests.
  • Requires little framework setup.
Disadvantages:
  • Code gets repeated.
  • Maintenance becomes difficult.
  • Changes may need to be made in many scripts.

3. Modular Framework

In a Modular Framework, the application is divided into smaller modules, and separate scripts or methods are created for each module.
For example, an e-commerce website may have these modules:
  • Login
  • Registration
  • Search products
  • Add to cart
  • Payment
  • Logout
Each module has its own reusable automation code.
Example: If the login functionality changes, the tester can update the login module without rewriting the entire shopping test.
Advantages:
  • Code can be reused.
  • Easier to maintain.
  • Testing activities are better organized.
Disadvantage: Testers must design the modules properly and manage the dependencies between them.

4. Data-Driven Framework

A Data-Driven Framework separates test data from the test scripts. The same test script can run multiple times using different sets of data.
Test data can be stored in Excel, CSV, JSON, databases, or other supported sources.
Example: A login test uses different username and password combinations.
Username
Password
Expected result
valid_user
valid123
Login successful
invalid_user
wrong123
Error message
blank_user
blank
Validation message
Instead of creating three separate scripts, the tester creates one script and runs it with all three data sets.
Advantages:
  • Less duplicate code.
  • Easy to add test data.
  • Helps test multiple scenarios.
Important: Passwords shown here are examples only. Real credentials should be handled securely.

5. Keyword-Driven Framework

A Keyword-Driven Framework uses predefined keywords to represent testing actions.
Examples of keywords include:
  • OPEN_BROWSER
  • ENTER_TEXT
  • CLICK
  • VERIFY_TEXT
  • CLOSE_BROWSER
The framework reads these keywords and executes the corresponding actions.
Example:
Keyword
Test data
OPEN_BROWSER
Chrome
OPEN_URL
Website URL
ENTER_TEXT
Username field, testuser
CLICK
Login button
VERIFY_TEXT
Dashboard
CLOSE_BROWSER
—
The framework contains the actual code behind each keyword.
Advantages:
  • Test steps are easy to read.
  • Common actions can be reused.
  • Can help non-programmers understand test flows.
Disadvantages:
  • Requires additional setup.
  • Creating and maintaining keyword mappings can become complex.

6. Hybrid Framework

A Hybrid Framework combines two or more framework approaches to meet the project’s requirements.
For example, it may combine:
  • Modular framework
  • Data-driven framework
  • Keyword-driven framework
  • Page Object Model
Example: In an online shopping application:
  1. Page classes manage the web elements.
  2. Excel provides different product and login test data.
  3. Reusable methods perform common actions.
  4. TestNG executes the test cases.
  5. Extent Reports displays the results.
This combination creates an organized automation solution.
Advantages:
  • Flexible and reusable.
  • Suitable for larger projects.
  • Supports multiple testing needs.
Disadvantage: If too many unnecessary layers are added, the framework becomes difficult to understand and maintain.

7. Page Object Model (POM)

The Page Object Model is a design pattern used in Selenium automation. It separates webpage elements and actions from the test logic.
In simple words, each important webpage gets its own Java class.
For example, a login page has:
  • Username field
  • Password field
  • Login button
We create a LoginPage class containing these elements and methods such as enterUsername(), enterPassword(), and clickLogin().
The test class uses these methods instead of locating the elements repeatedly.
Why is POM useful?
  • Reduces repeated code.
  • Makes tests easier to read.
  • Simplifies maintenance.
  • Keeps webpage-related code separate from test logic.
Example: If the login button’s locator changes, the tester updates the LoginPage class instead of changing every test that uses the login page.

8. Page Factory Concept

Page Factory is a Selenium-supported mechanism that helps initialize page elements using annotations such as @FindBy.
Example:
@FindBy(id = "username")WebElement username;
The PageFactory.initElements() method initializes the page object’s element fields.
This can make page classes shorter and easier to organize.
How it works:
  1. Define the web elements using annotations.
  2. Initialize the elements.
  3. Use the elements in methods.
  4. Call those methods from test classes.
Important: Page Factory is optional. Modern Selenium frameworks can use regular By locators and findElement() methods with POM. Page Factory does not automatically make tests more reliable; waits and correct element handling are still necessary.

9. Page Classes and Test Classes

These classes have different responsibilities in an automation framework.
Page classes: Contain webpage locators and actions.
Example: LoginPage.java contains methods to enter a username, enter a password, and click Login.
Test classes: Contain the test scenarios, execute the steps, and verify the results.
Example: LoginTest.java calls the login methods and checks whether the dashboard appears.
A simple structure looks like this:
src/test/java    pages/        LoginPage.java    tests/        LoginTest.java
Why separate them?
If webpage elements change, page classes can be updated without unnecessarily changing the test logic.

10. Base Class and Reusable Utilities

A Base Class contains common setup and cleanup methods that multiple test classes can use.
For example, a base test class may:
  • Start the browser.
  • Open the application URL.
  • Configure common browser settings.
  • Close the browser after testing.
Reusable utilities are helper methods that perform common tasks.
Examples:
  • Screenshot utility
  • Wait utility
  • Excel reader
  • JSON reader
  • Date and file utilities
Example: Instead of writing browser setup code in 20 test classes, testers can place the common setup in a base class and reuse it.
Important: Do not put every function into the base class. Keep unrelated responsibilities in separate utility classes to avoid creating one oversized class.

11. Configuration Properties Files

A configuration properties file stores settings separately from the Java code.
It is commonly named config.properties.
Example:
browser=chromebaseUrl=https://example.comimplicitWait=10
The framework reads these values when it starts.
Why is it useful?
  • Settings can be changed without modifying test scripts.
  • The same framework can run against different application URLs.
  • Browser settings can be managed in one place.
Example: If the testing URL changes from the QA environment to the staging environment, the tester can update the configuration rather than editing every test script.
Do not store real passwords, API secrets, or sensitive credentials in a plain properties file committed to source control.

12. Reading Test Data from Excel

Excel is commonly used to store test data in rows and columns.
For example, an Excel sheet may contain usernames, passwords, product names, or expected messages.
In Java automation projects, testers commonly use Apache POI to read Excel files.
Basic process:
  1. Create an Excel file.
  2. Add test data to the rows and columns.
  3. Read the file using Apache POI.
  4. Pass the values into the Selenium test.
  5. Verify the actual result against the expected result.
Example:
Test case
Username
Expected result
TC01
valid_user
Dashboard displayed
TC02
invalid_user
Error displayed
The same login test can use both rows as separate test cases.
Advantages: Test data is easy to update, and the automation code stays separate from the data.

13. Reading Data from JSON Files

JSON stands for JavaScript Object Notation. It is a common format for storing structured data.
Example:
{  "username": "testuser",  "expectedMessage": "Welcome"}
A Java framework can read this file using libraries such as Jackson or Gson.
Why use JSON?
  • Data is stored in a structured format.
  • It supports objects, arrays, strings, numbers, and other data types.
  • It is useful for configuration and test data.
  • It can represent complex data more conveniently than a simple spreadsheet.
Example: A tester stores several user profiles in a JSON array and runs the same registration test using each profile.
Excel is useful for spreadsheet-style data, while JSON is often convenient for nested or structured data.

14. Logging with Log4j or an Equivalent Logging Library

Logging means recording important information about what happens during test execution.
For Java projects, testers may use Log4j2, SLF4J with a logging implementation, or another suitable logging library.
Example log messages:
INFO  - Browser opened successfullyINFO  - Login test startedINFO  - Login button clickedERROR - Dashboard was not displayed
Why is logging important?
  • Helps identify where a test failed.
  • Records the execution sequence.
  • Helps troubleshoot intermittent problems.
  • Provides information for debugging.
Example: If a test fails after clicking Login, the logs help the tester identify the last completed action.
Avoid logging passwords, authentication tokens, or other sensitive information.

15. Screenshot Capture on Test Failure

A screenshot captures the browser’s visible state when a test fails.
A framework can automatically take screenshots when an assertion fails or an unexpected exception occurs.
Typical process:
  1. Start the test.
  2. Perform the required actions.
  3. Check the expected result.
  4. If the test fails, capture a screenshot.
  5. Save it with a meaningful name.
  6. Attach it to the test report.
Example: A test expects the dashboard to appear after login, but an error message is displayed. The framework captures the screen so the tester can investigate the failure.
Screenshots provide useful evidence, but they should be stored securely if they contain personal or confidential information.

16. Extent Reports or Equivalent Reporting

Reporting tools present automation results in a readable format.
Extent Reports is a reporting library that has been used with Selenium and Java frameworks. Other options include Allure Report and built-in reports from test frameworks such as TestNG.
Reports commonly show:
  • Total tests executed.
  • Passed tests.
  • Failed tests.
  • Skipped tests.
  • Error details.
  • Execution time.
  • Screenshots or other attachments, when configured.
Example:
Test case
Result
Login with valid data
Pass
Login with invalid data
Pass
Password validation
Fail
Logout
Pass
A report helps the QA team and developers quickly understand the test results.
Important: Reporting tools display the results they receive from the framework. The framework must correctly record test outcomes and attach relevant evidence.

17. Exception Handling in Frameworks

Exception handling helps a framework respond appropriately when something unexpected happens during execution.
In Java, testers commonly use try, catch, and finally blocks.
  • try – contains code that may produce an exception.
  • catch – handles a specific exception.
  • finally – runs cleanup code in normal completion and exception scenarios, subject to JVM termination.
Example: If a test encounters an unexpected error, the framework may capture a screenshot, log the error, mark the test as failed, and close the browser.
Why is it useful?
  • Helps prevent resource leaks.
  • Improves debugging.
  • Supports cleanup after failures.
  • Makes error reporting more informative.
Important: Do not catch every exception and silently ignore it. That can cause failed tests to appear successful. Handle expected exceptions carefully and allow genuine failures to be reported.

18. Environment-Based Configuration

Software applications often have separate environments for different testing purposes.
Common environments include:
  • Development
  • QA or Testing
  • Staging
  • Production
An environment-based framework allows testers to change settings according to the environment in which they want to run tests.
For example:
Environment
Base URL
QA
https://qa.example.com
Staging
https://staging.example.com
Production
https://example.com
The framework selects the correct URL and settings based on a configuration parameter.
Example: The same login test runs against QA in the morning and staging before a release without requiring changes to the test script.
Production testing should be carefully controlled to avoid creating or modifying real customer data.

19. Maven Project Structure and Dependency Management

Maven is a build automation and dependency management tool commonly used in Java automation projects.
It uses a file called pom.xml to define project dependencies, build settings, and plugins.
Dependencies are external libraries required by the project, such as:
  • Selenium WebDriver
  • TestNG or JUnit
  • Apache POI
  • A logging library
  • A reporting library
Maven downloads the required libraries and helps manage their versions.
A typical Maven project looks like this:
AutomationFramework/├── pom.xml├── src/│  
 ├── main/│  
 │   └── java/│  
 │       ├── pages/│ 
  │  └── utilities/│   └── test/│       ├── java/│     
  │   ├── tests/│   
    │   └── base/│    
   └── resources/│      
     ├── config.properties│            └── testdata.json└── test-output/
Why is Maven useful?
  • Manages library dependencies.
  • Helps compile and execute tests.
  • Supports repeatable builds.
  • Integrates with CI/CD tools.
  • Makes project setup easier for team members.

20. Building a Maintainable Automation Framework

A maintainable framework is one that can be updated, expanded, and debugged without unnecessary effort.
The goal is not to add as many tools as possible. The goal is to build a framework that solves the project’s testing needs clearly and reliably.
Important practices:
  1. Use a clear folder and package structure.
  2. Follow Page Object Model where it fits.
  3. Keep test data separate from test logic.
  4. Store environment settings in configuration files.
  5. Create reusable methods for common actions.
  6. Use explicit waits for meaningful conditions.
  7. Capture screenshots and logs when tests fail.
  8. Generate understandable test reports.
  9. Manage dependencies using Maven.
  10. Avoid duplicate code and unnecessary complexity.
  11. Use version control, such as Git.
  12. Run tests regularly through CI/CD when appropriate.
Example: Suppose the login page changes its button locator. In a well-designed POM framework, the tester updates the locator in the login page class, and all tests that use that class can benefit from the change.

Quick Revision Table

Topic
Main purpose
Framework
Organizes automation code and processes
Linear
Executes steps in one script
Modular
Divides the application into modules
Data-driven
Runs tests with multiple data sets
Keyword-driven
Uses keywords to represent test actions
Hybrid
Combines framework approaches
POM
Separates webpage code from test logic
Page Factory
Initializes page elements using annotations
Page and test classes
Separate page actions from test scenarios
Base class and utilities
Reuse common setup and helper functions
Properties file
Stores configuration settings
Excel
Stores spreadsheet-based test data
JSON
Stores structured test data
Logging
Records execution details
Screenshots
Captures browser state for debugging
Reporting
Displays test execution results
Exception handling
Manages errors and cleanup
Environment configuration
Runs tests against different environments
Maven
Manages dependencies and builds
Maintainability
Keeps the framework reliable and easy to update

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top