top of page

How to build a Test Automation Framework step by step

Wait, what is a Test Automation framework?

A test automation framework is a comprehensive set of guidelines that is a combination of programs, compilers, features, tools, etc. which facilitates a consistent way for changing test scripts and functions. By doing this, it provides users with a streamlined environment that helps them develop, execute, and report on automated test scripts effectively and efficiently.

As Denis Kolesnikov, Expert Test Automation Engineer says:

“A good automated testing framework should focus on a specific problem(s) and be designed around your type of product. Before you start designing your architecture, you need to get your QA priorities straight. Put down your main testing requirements, select a series of tests you need, then look into different strategies for automating them”.

The major components that implement a test automation framework successfully are equipment, testing tools, scripts, procedures, and most importantly, test automation engineers.

Below are the key benefits of creating an automation framework:

· Coding standards will be well maintained across the framework, library and test cases.

· The code can be reused across the team members

· It can increase the quality, speed, workflow and accuracy of test cases.

Why Do We Need a Test Automation Framework?

In this era, the entire world is moving toward automation. With this, the need for test automation is rising. Proper planning and execution of test automation frameworks have a lot of perks to offer. Let us look at some of them.

1. Optimization of Resources

A test framework helps in the optimization of resources. It does this by facilitating the use of different resources according to organizational needs. For instance, to achieve established goals, test automation frameworks provide a set of processes. These processes have to match resources to requirements. The higher the flexibility of adoption, the better your resource optimization will be.

2. Increased Volume of Testing

Test automation frameworks increase the volume of testing. For instance, new mobile devices emerge every other day. It’s impossible to perform manual testing on all. Even if a firm managed to do so, it would take forever. But automated testing enables testers to run tests on thousands of mobile devices at the same time.

3. Simultaneous Testing

Test automation frameworks enable simultaneous testing of different types of devices. When the test scripts are automated, all testers need to do is run them on different devices. Since the parameters are same, testers can quickly generate comparative test reports.

4. Enhanced Speed and Reliability

Writing and running tests can be time-consuming for any software company. Test automation frameworks reduce the time to carry out these activities. How? Suppose you’re testing the logout functionality of a website. If there are multiple testing scenarios, for each scenario you have to manually test whether the log out feature is working properly. But if you’re using a framework, you can simultaneously run all the scenarios and get the test results in very little time.

Moreover, automated testing is more reliable due to the use of automated tools. This reduces the chances of making mistakes.

5. More Output in Less Time

Test automation reduces challenges in synchronization, local configuration, error management, and report generation. An automation script minimizes the time taken to prepare and run tests. With increased efficiency and speed, a firm can gain more output in less time.

6. Fixing Bugs at an Early Stage

A test automation framework helps in fixing bugs at an early stage. You don’t need much manpower to carry it out for you, which means the working hours and expenses involved are also reduced. A test automation engineer can write scripts and automate tests. By using the right test automation frameworks, an organization can implement the concept of shift-left testing. That refers to the idea that you should move testing to as early in the software development lifecycle as possible. The earlier you can get is actually creating automated testing before the writing the production code. That’s exactly the modus operandi of techniques such as TDD (test-driven development) and BDD (behavior-driven development.)

7. Remote Testing

With a test automation framework, it’s not necessary to stay at the office premises 24/7. For instance, you can start running a test before leaving. When you come back after a few hours, the test results will be ready. Moreover, you don’t need to buy a lot of devices since you can test remotely.

8. Reusable Automation Code

You can reuse test automation scripts in a different application. Suppose the testers of your organization wrote some scripts for testing the login functionality. You can use the same script for another application that has a login functionality.

9. Increased ROI

The initial investment involved in test automation frameworks is off-putting for many. But the long-term return on investment is high. As discussed earlier, a test automation framework saves time and facilitates speedy delivery. It also reduces the need for more staff. For instance, a company doesn’t have to hire multiple testers if the testing framework is automated. A test automation engineer can carry out most of the tasks like configuring the framework or running the scripts.

10. Continuous Testing

The importance of continuous integration and continuous delivery/deployment can’t be overstated. Having a fully automated software pipeline is the surest way to ensure your code reaches production as fast as possible. However, it’s no use to ship broken code super-fast. That’s why an essential piece of the CI/CD puzzle is continuous testing. What is continuous testing? In a nutshell, it’s the practice of running your suite of automated tests continuously. Test automation frameworks are key in achieving continuous testing, since they enable not only the creation of the tests, but also their automatic execution.

Important Things to Remember Before creating an Automation Framework

Before writing the framework, people should understand the test automation’s basic requirements and flows. This requirement is significant because it can prevent designers from designing a defective architecture for the framework.

It's important that your test automation framework provides scalability, reliability, and reusability while decreasing the effort needed to conduct constant code maintenance. The name of the game is to reduce repeated manual work and the time for running tests while gaining a faster response and ensuring your tests are consistent with your expected outcomes. This goes for whether you're testing application programming interfaces (APIs) for websites, mobile apps, or any other type of software

1. Ease of use - Test automation frameworks should function like plug-and-play devices. There should be no learning curve dependent on their automation experience or technical skills. It should be so user-friendly that writing, inserting, compiling, and running a test script should be seamless without needing to dive into the underlying mechanics.

2. Scalability - Test automation can encapsulate a wide variety of tests; load testing, unit testing, and functional testing name just a few. Depending on changing requirements and scenarios, some of these tests have to be scaled up and down.

To address this, a great test automation framework should minimize the effort of development needed down the line. If a software was only built to test specific elements, it does not accommodate anything else outside of that specific scope. Every time you need to add new testing capabilities, a developer will most likely have to add extra code.

In contrast, a test automation framework is already equipped with the capabilities to cover most test cases. So, you can add extra scenarios without any extra development needed.

3. Traceability - Every test automation framework should have a robust and transparent reporting mechanism. Reports display information such as how many test cases executed, how many failed, and how many passed. They're useful for QA engineers and managers to quickly find out what's going on. Users should consult the log if more information is needed. This shows technical details that allow users to trace failures to their root cause.

4. Maintainability - Backward compatibility is key to great maintainability. Whenever changes are made, whether it be adding a new feature or revamping an existing one, it should be ensured it is backward-compatible with previous iterations.

5. Reusability - Reusability is one of the primary benefits of a successful test automation framework. By building automation frameworks and test scripts that can be implemented across numerous functions, you optimize their value. Not only does reusability make testing quicker, but it also lowers maintenance costs.

6. Compatibility - An ideal test automation framework will generally support a host of major applications, platforms, and operating systems. When contemplating this factor, you must try to anticipate what types of platforms and OS your organization may use in the future. Technology stacks and digital ecosystems are everchanging, so it's prudent to select automation testing tools that are compatible with a variety of options.

7. Minimal Manual Intervention - As we mentioned before, reducing manual work is a big reason why many organizations choose to employ a test automation framework. Basically, this means that even if you only run automated tests once in a while, they should be able to operate unattended. Otherwise, they cannot support Continuous Testing. By having the necessary utilities in place already, anytime you add a new test, you only have to think about what you need to do instead of "reinventing the wheel" every time.

8. A dedicated team - This final factor on our list is undoubtedly the most important one. Only a team of talented techies can make a successful test automation framework. Without the appropriate knowledge required, you can't get the other ingredients on this list -- you'll only have a recipe for disaster.

Steps to build the Test Automation Framework

Over 95 percent of organizations agree that test automation patterns, principles, and practices are critical for them. But far less made progress with test automation framework design and implementation.

Indeed, QA automation is a complex process, but a systematic one. Meaning you need to complete several core steps to transition from largely manual to mostly automated testing. Some of the best practices are unpacked below

1. Determine the Optimal Test Automation Framework Architecture

Quality assurance is a multi-facet activity. You can probe newly-built software from different angles to ensure it works like it was meant to and has no critical bugs or vulnerabilities.

For that reason, there are plenty of different types of tests:

Functional testing

  • Unit tests

  • Component tests

  • Smoke tests

  • Regression tests

  • API tests

  • UI tests

Non-functional testing

  • Performance tests

  • Load tests

  • Pentesting (security tests)

  • Stress tests

  • Volume tests

  • Recovery tests

We cannot incorporate all of them into automation.

Various test automation frameworks exist, each with a different logic from which we can derive the one that best fits in for us based on the kind of testing and different other factors that needs to be performed. Let us have a look at them.

  • Keyword-driven framework

A keyword-driven test framework separates script logic from test data. Then, it stores the data externally. After that, it stores the keywords in a different location. The keywords associated with actions testing GUI are a part of the test script. A keyword associates itself with an object or an action. Since testers can use the same keyword across different test scripts, it promotes reusability.


  • Reusable

  • Scalable

  • Less Maintenance


  • High development time

  • Complexity increases over time

  • High automation knowledge required

· Modular-driven framework

Modular-based test frameworks break down test cases into small modules. Then, it follows a non-incremental and incremental approach. There, the modules are independently tested first and then the application is tested as a whole. This makes each test independent.

Moreover, once a tester is done writing a function library, you can also store a script in it. Since you can easily make changes in a single script, adjusting the entire application is not necessary. Thus, testing requires less time and efforts.


  • Reusable

  • Modular approach

  • Efficient

  • Scalable


  • Less flexible

  • Requires technical knowledge

  • Complex

· Behavior-driven framework

All application behaviors are defined through human-readable test commands (e.g. registering an account). Then these are codified into test cases using BDD tools. It mainly focuses on the behavior of the product and user acceptance criteria. Cucumber is one of the best tools used to develop tests in the BDD framework.


  • Easier and safer changes

  • Faster releases

  • Reduces cost

  • Reduces waste


  • Requires high communication and collaboration

  • Works best in Agile context

  • Does not work well in an enclosed environment

  • Poorly written tests ca lead to high maintenance costs

· Data-driven framework.

A Data driven framework segregates test script logic and test data. After that, it stores the data externally. Here, the aim is to create reusable test scripts for testing different data sets. Testers can vary the data to change testing scenarios. This ensures reusability of code.


  • Scalable

  • Faster testing

  • Fewer scripts required

  • Flexible


  • High setup time

  • Excellent technical knowledge required

  • Troubleshooting is difficult

· Linear Automation Test Framework

A linear automation test framework involves introductory level testing. Testers sequentially create test scripts and individually run them. There is no need to write custom code. So, testers don’t have to be automation experts. It’s a one-at-a-time to the point testing approach. Pick one functionality, write a script, and test. Also, a speedy workflow is the biggest perk of linear automation framework.


  • Simple

  • Fast

  • Flexible


  • Single-use

  • High Maintenance

  • Redundant

· Library Architecture Test Framework

With a library architecture test framework, the framework identifies tasks holding similarities within the test script. After that, testers carry out the grouping of similar tasks by function. Then, a library stores all the sorted functions. Hence, it facilitates reusability of code across different test scripts. This framework is useful when the application has similar functionalities across different parts of the application.


  • High reusability

  • Cost-effective

  • Scalable

  • High long time ROI


  • More development time

  • High technical knowledge required

  • Complicated

· Hybrid Test Framework

A hybrid test framework is any combination of the above frameworks which mitigates the weaknesses of different test frameworks. It provides flexibility by combining parts of different frameworks to harness the advantages. Hence, the efficiency of testing also improves.

Each framework on the market is neither entirely good nor bad — everything depends on your particular project, solution, and software development methodology.

Which Testing Framework Is Best?

Now that you know the benefits of different test automation frameworks, it’s time to choose one.

With a plethora of different testing frameworks, it can become overwhelming to know which one is right for you. And to find the best solution, you need to understand the requirement first. Before looking for which testing framework suits you best, learn the basics about your testing process:

  • Code or no code: Understand how your testers test the application. Do they write codes for testing or they use something like record and playback testing? If testers using coding, then you would want something that’s flexible. You must seek one that supports different languages and applications, something like Selenium. If testing is codeless, you can choose from a wide range of smart tools that don’t need coding, something like Testim.

  • Platform: What platform does the application run on? Is it a web application, an Android app, an iOS app? Different frameworks special in different platforms. So, you have to choose one that offers the most for the platform of your choice. You also have to consider which platform your testers use – Windows, Mac, or Linux? You should choose a framework that works on the platform being used.

  • Budget: There’s so much we’d have if money was out of the question. When deciding which testing framework, you would finally use, consider your budget. Budget can be flexible at times but not out of the league. So, you can use the budget as one of the filters.

You can also start with a tool offering out-of-the-box solutions. Above all, you need to do what it takes to improve the testing process.

2. Design a Reference Test Automation Framework

Conceptually, all QA automation frameworks have four layers:

  • Test generation

  • Test definition

  • Test execution

  • Test adaptation

Jointly, these govern the relationships between a TAS – test automation solution – and a SUT (system under test). Or, to put it another way, these four layers create the rules and guidelines for testing automation.

Test Generation Layer

The test generation layer sets the baseline for subsequent QA automation. Your goal here is to formalize your main test types, design manual tests, and set up test data capture and generation to support the selected QA scenarios.

The components of this layer are used to:

  • Edit and navigate test suite structures

  • Align test cases to test objectives (or SUT requirements)

  • Document the test design

Test Definition Layer

At this stage, you need to analyze the available test data and match it to the planned test cases. Then begin designing test scripts for the approved use cases.

The components of this layer are used to:

  • Partition (constrain), parameterize, or instantiate test data

  • Document the test data, test cases, and/or test procedures

Test Execution Layer

This part of a test framework includes all the tools you need to run, log, and report on automated test case execution.

A robust test execution layer provides the following capabilities:

  • Auto-set up and tear down of the SUT for test execution (i.e. set of test cases including test data)

  • Rapid configuration and parameterization of the test setup

  • Interpretation of both test data and test cases and subsequent transformation of them into executable scripts

  • SUT responses validation (i.e. comparison of expected and actual results) for reporting

  • Precise control and proper timing for automated test execution

Don’t rush with implementing a definite architecture. Instead, start with several proof-of-concept (POC) scenarios.

Test Adaptation layer

The test adaptation layer provides the necessary code to adapt the automated tests for the various components or interfaces of the SUT. Many different means of communication allow your systems to talk with each other. At the software application level, a communication type is identified by a set of services provided by specific functions.

3. Decide on Your Test Automation Tech Stack

The previous section described the process layout. Now let’s focus on the QA automation tools.

QA automation testing tools can be:

  • Open-source – community-developed and supported software you can use without any license purchases. There are no constraints for customization.

  • Proprietary tools – licensed software, offering access to a rich set of native functionalities out of the box.

  • Custom solutions – any combination of the above two options within your framework.

When deciding on your QA automation stack, you should always take into account:

  • Programming languages (most QA tools are language-specific)

  • Operating systems (your testers are using)

  • Platform support (web, mobile, tablet,etc)

Some of the automated testing tools recommended are:

  • Selenium Webdriver – cross-browser web testing framework

  • Cypress – end-to-end JavaScript testing framework

  • WinAppDriver – open-source desktop automation testing framework

4. Decide on Your Path to Implementation

After you’ve selected your test framework, you need to decide on the implementation approach. To better illustrate different paths to implementation, we’ll use Selenium.

Similar to other QA automation tools, Selenium supports several test design patterns:

  • Wrapper methods: In software engineering, a wrapper is a method of encapsulation. Essentially, you create a custom variant of executing a certain function because the original one doesn’t meet all your requirements. Then add this wrapper into your framework.

  • Abstraction methods: Abstraction is a technique software engineers use to hide unnecessary details from the users. In test frameworks, abstracting certain functionalities promotes better code structure and maintainability.

  • Page Object method: This is the most commonly used method for organizing test cases. Here you denote each web page of an app as a class file — such that contains only all corresponding web page elements. Then perform tests on these elements. Doing so reduces code duplication and improves test maintenance.

Advantages of POM are given below

· If any locator makes changes in the project, it is easy to change it in one place.

· Reusability of locators

· Duplicate locators can be avoided

Implement Custom Logger

While running the test cases; activity information has to be logged into the file. This added information can be used as a reference for future audits and test runs. Therefore, the logging framework needs to be implemented and customized for this requirement. The popular logging framework for java is log4j and python is Custom Logger.

Separate Tests from Automation Framework

Always separating the Test script logic from the automation framework is recommended. It increases code readability and makes the code readable.

5. Create a Proper Folder Structure for The Code

Always defining the folder structure makes the code readable and makes it easy to understand. The folder can be structured as below,

· Testcases

· Utilities

· Libraries

· Logs

· Test Data

· Constants

· Page Objects

· Locators

6. Separates UI, Web Services, Databases

The most important principle in framework design is the separation of concerns. Therefore, creating an additional layer for web services, API, databases and UI in the framework will avoid the clutter. Sometimes the testing design pattern may not cover the extra layer in framework architecture; thus, it is good to create one more layer. The best example is separation Soap UI with selenium web driver integration.

7. Develop Test Data

Automated testing is heavily-reliant on data. The more data you have — the better outcomes you’ll gain. However, when you are doing QA at the pre-production stages, you may be lacking meaningful first-hand data to cover all testing scenarios.

Therefore, consider extra test data generations strategies such as:

  • Synthetic data from automated data generation tools

  • Mass copy of data from production to testing environment

  • Mass copy of test data from legacy systems

  • Manual test data creation

Next, you should group all available data by test cases and securely store it in a test data management tool.

Finally, remember that QA automation is a continuous process. You’ll have to work in increments and progressively extend automated test coverage to new test scenarios. It always makes sense to start with several testing scenarios — and then add extra ones to your framework.

8. Build & Continuous Integration:

Continuous Integration is a development practice that integrates with a build automation tool like Maven to ensure whether the software is running without any breaks after making a commit decision.

Again, no method is inherently better or worse — they are just better suited for different use cases.

Summing It Up

Boosting a testing team’s velocity is no child’s play. Enterprises keep struggling to find a way to maximize efficiency. Testing is one of the most important phases in the software development process. Automation test frameworks are the way to go to increase test precision and make the product better.

When you choose the best testing framework for you, the testing process becomes better, the quality of the application increases, optimum testing speed is achieved, and most importantly, your testers are happy. Hunting for the right testing framework would take some time and effort. But it’s worth it.

The choice of a software testing framework is something that remains the same in the organization through time. And shifting from one framework to another mid-way is difficult for testers to adapt to, and it also slows down the application development process. The smart move is to spend enough time right in the beginning and choose the best possible framework for you.

1,191 views1 comment

Recent Posts

See All

Exception Handling in Selenium Webdriver

What is an exception? An exception is an error that occurs during the execution of a program. However, while running a program, programming languages generate an exception that must be handled to prev

1 Comment

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Jul 24, 2023


bottom of page