Before how to design an automation framework, we should first know what automatic framework is, what needs to be paid attention to when designing, and then how to do it?

What is a framework? It refers to a support structure with certain constraints designed to solve an open problem. In this structure, more components can be expanded and inserted according to the specific problem, so as to build a complete solution to the problem more quickly and easily. A framework is a reusable design of a whole or part of a system, represented by a set of abstract artifacts and the way in which instances of those artifacts interact. That is to say, the framework itself does not solve a specific problem, it is through the extension of various components or tools to solve the problem, and it can easily add or modify the functionality of some components.

2. What is an automated testing framework?

What is a test automation framework, we break up, is actually three aspects, automation, testing, framework, what is a framework for the above said, still have even if he can perform tests, and automated, so the framework of the main functions of the various components is around how to automate how to execute the test. Here we can call the various functions of the framework modules, so let’s see which modules are needed. We need a basic module, mainly how to implement scripting, management module, the main behavior is continuous integration, timing execution, case management, statistics module, mainly send test reports, statistical analysis. To summarize the definition of an automated testing framework: To use in the process of automated testing in some of the features or tools, repackaging into various modules, including how to automate scripting and layered function module, the basis of continuous integration, timing, task management module, send the test report, the test results of statistical analysis module, the module of a reusable framework.

Versatility: can be used in a variety of systems and platforms

Maintainability: we can independently maintain our data, use cases and the implementation of the framework, and quickly define the point of maintenance in the process of achieving perfection, without affecting other functions of the framework

Timed processing: Can be executed at a specified time

Continuous integration: automatic execution of updates to the program under test and test code

Debugging: adjustable test strength

Test results: test report, statistical analysis of test data

Can be divided into two parts, the test automation framework subject is an internal framework, one is the external framework, the internal framework is our own testing framework implementation code, the external frame is put aside our implementation of the core code, to achieve automation test framework design some content of the original use of some third party tools.

Outer frame

It mainly refers to webDriver as the core, supplemented by external third-party frameworks and tools. Some peripheral components that are used to implement continuous integration, automatic deployment, script execution, remote invocation, report optimization, mail delivery, and other functional frameworks to implement the design principles of the automation framework.

Within the framework

Also known as the layered framework, the purpose is to better optimize and manage test cases, easier maintenance of data, elements, scripts and faster creation of new scripts

1. General external framework implementation logic

Maven or tox- auto-compile, perform TestNG or junit, integrate mail sending, etc

TestNG, Junit, and PyTest invoke webDriver or request methods, execute automated test cases, and standardize automated test scripts

Selenium scripts or interface use case scripts

ReportNG or Allure report optimization templates

Main automatically sends HTML email notifications or Jenkins emails

2, the internal framework layer frame – that is, the code structure optimization, according to the specific business and needs can be roughly divided into the following layers, sometimes do not need all the following layers, select the right business test on the line.

TestCase layer: Use case scripts executed

Task layer: Public services are repackaged, which are not required by other projects and are only related to the current project, such as public login and search services

Utils layer: business-neutral methods such as data-driven – that is, encapsulation of data file reads and writes, browser operations, element location methods, and so on

Page layer or Po layer: The page layer maintains all the elements of a page, operations on the page, operations on the elements, and interactions with other pages. The business is essentially one element to another or one page to another. This is a bit similar to the Task layer.

Element layer: Maintenance of common elements or components, or encapsulation of custom components

Data layer: data store properties layer: configuration files, global variables

From the above content can know where to start to design a framework, I hope to give you good advice.