CN115658529A - Automatic testing method for user page and related equipment - Google Patents

Automatic testing method for user page and related equipment Download PDF

Info

Publication number
CN115658529A
CN115658529A CN202211371081.7A CN202211371081A CN115658529A CN 115658529 A CN115658529 A CN 115658529A CN 202211371081 A CN202211371081 A CN 202211371081A CN 115658529 A CN115658529 A CN 115658529A
Authority
CN
China
Prior art keywords
test
page
automatic
user
script file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211371081.7A
Other languages
Chinese (zh)
Inventor
陈世岳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202211371081.7A priority Critical patent/CN115658529A/en
Publication of CN115658529A publication Critical patent/CN115658529A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application discloses an automatic test method and related equipment for a user page, which can acquire an automatic script file recorded by a client, wherein the automatic script file is obtained by recording a script of the user page through a Playright script recording command by a user at the client; generating and storing a target test case according to the automatic script file; according to page element identification in the user page aimed at by the test operation, positioning a page element corresponding to the page element identification in the user page; building an automatic testing frame; and when a test instruction aiming at the user page is received, based on the automatic test framework and the target test case, calling an automatic script file to carry out automatic test on the service function of the page element positioned in the user page, and obtaining a test result. The method and the device can reduce the test cost of the whole user interface, have less code redundancy and are beneficial to improving the test efficiency and the quality of software products.

Description

Automatic testing method for user page and related equipment
Technical Field
The application relates to the technical field of computers, in particular to an automatic testing method for a user page and related equipment.
Background
With the rapid development of network technology, software products are almost ubiquitous in daily life, the software products need to rely on a User Interface (UI) to complete human-computer interaction, user pages are directly related to the use experience of users on the software products, and the advantages and the disadvantages of the User interfaces concern the use value of the whole software products. Therefore, user interface testing is an essential stage in software development.
At present, when the user interface is tested, an open-source automation framework is mostly adopted to test the user interface, and a test case is maintained by compiling a test script or inputting a test step, so that manual testing is required for each updating, the workload of testers is large, and the software testing efficiency is low.
Disclosure of Invention
The embodiment of the application provides an automatic testing method of a user page and related equipment, wherein the related equipment can comprise an automatic testing device of the user page, electronic equipment, a computer readable storage medium and a computer program product, the testing cost of the whole user interface can be reduced, the code redundancy is less, and the testing efficiency and the software product quality are favorably improved.
The embodiment of the application provides an automatic testing method for a user page, which comprises the following steps:
acquiring an automatic script file recorded by a client, wherein the automatic script file is obtained by performing script recording on a user page through a Playright script recording command by a user at the client;
generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client;
according to the page element identifier in the user page aimed at by the test operation, positioning a page element corresponding to the page element identifier in the user page;
building an automatic testing frame;
and when a test instruction aiming at the user page is received, based on the automatic test framework and the target test case, calling the automatic script file to carry out automatic test on the service function of the page element positioned in the user page, and obtaining a test result.
Correspondingly, the embodiment of the present application provides an automatic testing apparatus for a user page, including:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring an automatic script file recorded by a client, and the automatic script file is obtained by carrying out script recording on a user page through a Playright script recording command by a user at the client;
the generating unit is used for generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client;
the positioning unit is used for positioning a page element corresponding to the page element identifier in the user page according to the page element identifier in the user page aimed at by the test operation;
the building unit is used for building an automatic test frame;
and the testing unit is used for calling the automatic script file to carry out automatic testing on the service function of the positioned page element in the user page based on the automatic testing frame and the target testing case when a testing instruction aiming at the user page is received, so as to obtain a testing result.
The electronic device provided by the embodiment of the application comprises a processor and a memory, wherein the memory stores a plurality of instructions, and the processor loads the instructions to execute the steps in the method for automatically testing the user page provided by the embodiment of the application.
The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps in the method for automatically testing a user page provided in the embodiment of the present application.
In addition, a computer program product is further provided in the embodiments of the present application, and includes a computer program or instructions, where the computer program or instructions, when executed by a processor, implement the steps in the method for automatically testing a user page provided in the embodiments of the present application.
The embodiment of the application provides an automatic test method and related equipment for a user page, which can acquire an automatic script file recorded by a client, wherein the automatic script file is obtained by recording a script of the user page through a Playwright script recording command at the client by a user; generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client; according to page element identification in the user page aimed at by the test operation, positioning a page element corresponding to the page element identification in the user page; building an automatic test frame; and when a test instruction aiming at the user page is received, calling the automatic script file to carry out automatic test on the service function of the page element positioned in the user page based on the automatic test framework and the target test case to obtain a test result. The method and the device can reduce the test cost of the whole user interface, have less code redundancy, and are beneficial to improving the test efficiency and the quality of software products.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1a is a scene schematic diagram of an automated testing method for a user page provided in an embodiment of the present application;
FIG. 1b is a flowchart of a method for automated testing of a user page according to an embodiment of the present application;
FIG. 1c is a block diagram of a method for automated testing of a user page provided by an embodiment of the present application;
FIG. 1d is a table of contents structure diagram of an automated testing method for a user page according to an embodiment of the present application;
FIG. 1e is an illustration of a method for automated testing of a user page provided by an embodiment of the present application;
FIG. 1f is another illustration of a method for automated testing of a user page provided by an embodiment of the present application;
FIG. 2 is another flowchart of a method for automated testing of a user page provided by an embodiment of the present application;
FIG. 3 is a schematic structural diagram of an apparatus for automated testing of a user page according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides an automatic testing method of a user page and related equipment. The automatic testing device for the user page may be specifically integrated in an electronic device, and the electronic device may be a terminal or a server.
It can be understood that the method for automatically testing the user page in this embodiment may be executed on the terminal, may also be executed on the server, and may also be executed by both the terminal and the server. The above examples should not be construed as limiting the present application.
As shown in fig. 1a, an example of the method for performing an automated test on a user page by a terminal and a server is taken. The automatic test system for the user page provided by the embodiment of the application comprises a terminal 10, a server 11 and the like; the terminal 10 and the server 11 are connected via a network, for example, a wired or wireless network connection, etc., wherein the automated testing device for user pages can be integrated in the server.
The server 11 may be configured to: acquiring an automatic script file recorded by a client, wherein the automatic script file is obtained by performing script recording on a user page through a Playwright script recording command by a user at the client; generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client; according to the page element identifier in the user page aimed at by the test operation, positioning a page element corresponding to the page element identifier in the user page; building an automatic testing frame; and when a test instruction aiming at the user page is received, based on the automatic test framework and the target test case, calling the automatic script file to carry out automatic test on the service function of the page element positioned in the user page, and obtaining a test result. The server 11 may be a single server, or may be a server cluster or a cloud server composed of a plurality of servers.
The terminal 10 may be configured to: recording an automatic script file aiming at a user page through a Playright script recording command, and sending the automatic script file to the server 11 so that the server 11 can automatically test the user page based on the automatic script file; the terminal 10 may also receive the test results sent by the server 11. The terminal 10 may include a mobile phone, a smart television, a tablet Computer, a notebook Computer, or a Personal Computer (PC). A client, which may be an application client or a browser client or the like, may also be provided on the terminal 10.
The following are detailed below. It should be noted that the following description of the embodiments is not intended to limit the preferred order of the embodiments.
The present embodiment will be described in terms of an automatic testing apparatus for a user page, where the automatic testing apparatus for a user page may be specifically integrated in an electronic device, and the electronic device may be a server or a terminal.
As shown in fig. 1b, the specific process of the automated testing method for the user page may be as follows:
101. and acquiring an automatic script file recorded by the client, wherein the automatic script file is obtained by performing script recording on a user page through a Playright script recording command by the user at the client.
The client may specifically be a browser client. The playright script recording command may specifically be the command codegen.
Playright is a kind of Web UI (User Interface) open source automatic testing tool, which can drive browser to perform various automatic operations, support multiple languages such as Python, java, C # and node. Furthermore, the playright can be used in combination with the unittest framework, and supports functions of automatic script recording at the browser end and the like.
The unit test is a unit test framework, has a complete test structure, supports the execution of automatic test, can organize a test case set, provides rich assertion methods, can judge whether the test case passes or not, and finally generates a test result.
In a specific scene, a user can initiate a script recording instruction at the front end, the back end executes a splicing playright script recording command, and a browser is opened; and the user operates in the newly opened browser window, and closes the browser window after the operation is finished, so that the script file can be generated.
102. And generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client.
Optionally, in this embodiment, the type of the test operation includes: clicking, dereferencing and assigning the page elements.
The clicking on the page element may specifically be clicking on a link, a button, a radio box, a multi-box or other page elements. The value of the page element may be, specifically, an attribute value of the page element, for example, a color of an edit box is read. The page elements are assigned, specifically, the character strings are assigned to the page elements, for example, a user name and a password are assigned, an edit box is assigned, and the like.
Specifically, under the condition that the test operation is the assignment operation, the target test case further includes test data corresponding to the assignment operation, the test framework can additionally store the test data corresponding to the assignment operation, which is input by the user, as a test data file, and establish a correspondence between the test file of the assignment operation and the test data file corresponding to the assignment operation, that is, an assignment data correspondence.
Optionally, in this embodiment, the step "generating and storing a target test case according to the automation script file" may include:
executing the automation script file at the client;
generating a target test case based on the test operation in the client;
and receiving the target test case returned by the client, and storing the target test case.
The method comprises the steps of generating a target test case by testing page elements in a user page on a client according to the test operation performed on the page elements in the execution process of an automatic script file, wherein the generated target test case comprises the test operation performed on the page elements.
Specifically, when the automation script file is executed, a browser in playright can be called, and a target test case is generated according to a test operation of a user in the browser.
In some scenarios, such as iteration of a software version or when updating is needed, related fields in the target test case can be modified to obtain an updated target test case; it can be understood that the updated target test case records the corresponding updated test operation.
103. And positioning the page elements corresponding to the page element identification in the user page according to the page element identification in the user page aimed at by the test operation.
The identification of the page element comprises a name and/or a locator of the page element, and the locator can record the position information of the page element on the user page to be tested;
the page elements may include links, buttons, radio boxes, multiple selection boxes, and edit boxes, which is not limited in this embodiment. The page element may specifically be a business component to be tested.
104. And (5) building an automatic testing framework.
The automatic testing framework is used for testing automation. The method can provide basic functions of compiling the automatic test case, executing the automatic test case, generating the automatic test report and the like. According to the embodiment, an automatic test frame corresponding to the user page to be tested can be set up, and the automatic test frame is deployed in an automatic test environment.
Specifically, as shown in fig. 1c, the automated test framework may include a page driver, a test tool class, a system page, a test suite, a test executor, and the like.
The page driver may include a browser driver, playright, and the like, among others. The test tool classes may include a log class, a test data class, a configuration file read, a common operations package class, and the like. The system page can comprise each test component, and specifically can comprise a common component and a business component taking a business module as a unit. The test suite (TestSuite) may include a business process that implements test cases in a test scenario. The test executor can be used for controlling the execution flow of the test case and can also be used for generating a test report.
In one embodiment, as shown in FIG. 1c, a UI automation test framework based on secondary development of Playwright and unittest; specifically, the test data (specifically, test cases) and the page elements in the user page to be tested can be determined by recording the playright script, the test data and the page elements acquired by the data layer are input into the automatic test frame, and the test cases are executed by the test executor test runner in the automatic test frame to perform service function tests on the page elements in the user page to be tested, so that test results are obtained and output, and the test results can be written into the test report of the test cases.
The test runner is a test executor, is an important component in the unitest, and is used for executing the test case and returning the execution result of the test case, such as the total number of the running cases, the pass number of the case, and the fail number of the case. Specifically, the test runner can present the final running result graphically, textually, or by returning some special value.
Optionally, in this embodiment, the step "building an automated testing framework" may include:
packaging the client driver into a preset automatic test frame;
packaging the positioned page elements in the user page into a page object of a preset automatic test frame;
and packaging a target tool into a preset automatic test frame to obtain the automatic test frame, wherein the target tool comprises any one or any combination of a drive read-write data tool, a log recording tool and a configuration tool.
In some embodiments, the directory structure of the automated test framework may include a configuration file layer, a test data file layer, an initialization layer, a log file layer, a log layer, a page layer, a picture layer, a test report layer, a use case implementation layer, and a generic layer, as shown in FIG. 1 d.
The configuration file layer, denoted as config, may be used to store an ini type configuration file. The configuration file layer can be mainly used for configuring a browser object, an initial access address, a browser driver and the like. It should be noted that more attributes may be configured in the configuration file layer.
And the test data file layer is marked as data and mainly can store test data and identity card image data.
And the initialization layer is marked as frame and can be used for reading the configuration file, opening the browser object and accessing the initial address. In addition, some initialization operations are typically placed below this layer.
And the log file layer is recorded as log and used for storing the generated log file of the log.
And the log layer is recorded as logs and used for storing a layer for writing log classes.
The page layer, which is also called page class, is used for storing page class elements. The page layer usually stores attributes such as an Identity document (id) of the page, and then calls the attributes by a restructured method.
And the picture layer is marked as screenshots and used for storing screenshots when the test execution fails, and the subdirectories are divided according to the names of the test cases.
And the test report layer is recorded as test _ report and used for storing the generated test report.
And the case implementation layer is marked as testproperties and used for implementing the test case execution flow.
And the common layer is marked as unit, also called as common class or common method class, and is used for encapsulating common operation methods and the like.
Optionally, in this embodiment, the test data file layer mainly stores test data used by each test case, the test cases correspond to the test data one to one, and the data format may be defined according to specific service requirements; specific example is shown in fig. 1e, where test case 01 is a test case logged in by a member, test case 02 is a test case of a second class user, and test case 03 is a test case of a new member system. Specifically, the test data used by the test case may include a case number, a case script name, a case name, a name, an identification number, a mobile phone number, a binding card number, a transaction password, a job, a work unit, a recommender, and a monitoring point.
Specifically, the page layer is mainly used for basic packaging of the page, which may be a BasePage class among units (test units). This class mainly secondarily encapsulates some methods in Playwright, such as: clicking on an element, entering text, and the like. Some of the methods in playright may be packaged secondarily at BasePage and then used. The page class is used to make calls in the page class elements, as some specific operations in the page class pageobjects: click, enter text, etc.
The BasePage is a self-defined page base class and encapsulates a basic page operation method.
In a specific embodiment, the use case implementation layer may include a test implementation class for executing a test case using unittest (e.g., a use case of setting setUp, disassembling tearDown, and testing test _ xxxx). Each def test _ xxx corresponds to a test case. The main task under the test implementation class is to call the packaged page class, execute the page class according to the test operation steps of the case pages, and then return a check result. The test cases are usually matched with TestSuite in the unit test to perform batch testing, and then a test report is generated.
105. And when a test instruction aiming at the user page is received, calling the automatic script file to carry out automatic test on the service function of the page element positioned in the user page based on the automatic test framework and the target test case to obtain a test result.
Specifically, in this embodiment, the test operation indicated in the target test case may be executed on the located page element through the automated test framework, so as to obtain a test result.
Optionally, in this embodiment, the step of invoking the automated script file to perform an automated test on a service function carried by a page element located in the user page based on the automated test framework and the target test case to obtain a test result may include:
acquiring each page element operation method and page elements to be operated in the target test case;
and calling corresponding page object classes based on the automatic test framework and the operation methods of the page elements, and calling the automatic script file to drive the corresponding page elements to be operated so as to simulate user operation behaviors and execute automatic test of service functions borne by the page elements to obtain test results.
The automatic script file can be called to drive the corresponding page element to be operated to execute the test operation indicated in the target test case.
Optionally, in this embodiment, the method for automatically testing a user page may further include:
when the test passes, writing the test result into the test report of the target test case;
and when the test process is abnormal, triggering an automatic screenshot function, and writing the intercepted image into the test report of the target test case.
Specifically, in the test process, when the page operation is overtime or the case execution is blocked under the abnormal condition of error reporting, a page snapshot method is called to capture a screenshot of an error interface, the captured picture is stored in a set folder, and when a test report is generated, the corresponding picture is pulled from the folder and inserted into the test report.
In this embodiment, the test failure part in the test report may include an operation screenshot when the test fails, so that the test report is more intuitive.
In addition, in some embodiments, the test report may further record an execution process of invoking the automation script file to execute the automation test on the user page to be tested.
In a specific scenario, after the test cases are executed in batch, an HTML (Hyper Text Markup Language) test report may be generated. The generated test report may include the execution result of the test case, such as the total number of the run cases, the pass number of the use cases, and the fail number of the use cases, as shown in fig. 1 f. Specifically, the test report may include a pass rate, an error rate, a correct rate, an overview, and details of the test case, and in addition, for the test case with a screenshot, the screenshot may be viewed, and a function of downloading all the screenshots and the operation log may be provided.
Since the scripts recorded and automatically generated by the playscript are all stream scripts, are not robust and have portability, and corresponding modification and debugging are usually required in the actual use process, a large amount of labor and time are consumed for maintaining the scripts, and the method is not friendly to the version test of rapid iteration. Because the requirements on the test tool are light, fast, easy to use and low in learning cost, the test case can be played back quickly and a test report can be generated, and the delivery efficiency can be improved while the quality is ensured. These requirements cannot be satisfied by using the playright kit as it is. The UI automation test framework based on secondary development of playright and unittest provided in this embodiment is very suitable for a page composed of components, and can quickly verify the updated and page layout after iteration. According to the automatic testing method for the user page, the whole testing process can be finished in Playwright by recording, storing the testing case, replaying and generating the testing report; the method is based on browser operation, is convenient for maintaining scripts, can quickly play back test cases and generate test reports, and can effectively guarantee quality and improve delivery efficiency for users.
As can be seen from the above, the present embodiment may obtain an automatic script file recorded by a client, where the automatic script file is obtained by performing script recording on a user page by a playright script recording command at the client by a user; generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client; according to the page element identifier in the user page aimed at by the test operation, positioning a page element corresponding to the page element identifier in the user page; building an automatic testing frame; and when a test instruction aiming at the user page is received, based on the automatic test framework and the target test case, calling the automatic script file to carry out automatic test on the service function of the page element positioned in the user page, and obtaining a test result. The method and the device can reduce the test cost of the whole user interface, have less code redundancy and are beneficial to improving the test efficiency and the quality of software products.
The following description will be further detailed by way of example in which the automated testing device for the user page is specifically integrated in the server according to the method described in the previous embodiment.
An embodiment of the present application provides an automated testing method for a user page, and as shown in fig. 2, a specific flow of the automated testing method for a user page may be as follows:
201. and the server acquires an automatic script file recorded by the client, wherein the automatic script file is obtained by recording a script on a user page through a Playwright script recording command by the user at the client.
The client may specifically be a browser client. The playright script recording command may specifically be the command codegen.
Playright is a kind of Web UI (User Interface) open source automatic testing tool, which can drive browser to perform various automatic operations, support multiple languages such as Python, java, C # and node. Furthermore, the playright can be used in combination with the unittest framework, and supports functions of automatic script recording at the browser end and the like.
202. And the server generates and stores a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client.
Optionally, in this embodiment, the type of the test operation includes: clicking, dereferencing and assigning the page elements.
The page element is clicked, and specifically, the page element such as a link, a button, a radio frame or a multi-box is clicked. The value of the page element may be specifically an attribute value of the page element, for example, a color of an edit box is read. The assignment of the page element may specifically be to assign a character string to the page element, for example, to assign a username and password, to assign an edit box, and so on.
Optionally, in this embodiment, the step "generating and storing a target test case according to the automation script file" may include:
executing the automation script file at the client;
generating a target test case based on the test operation in the client;
and receiving the target test case returned by the client, and storing the target test case.
The method comprises the steps of generating a target test case by testing page elements in a user page on a client according to the test operation performed on the page elements in the execution process of an automatic script file, wherein the generated target test case comprises the test operation performed on the page elements.
203. And the server positions the page elements corresponding to the page element identification in the user page according to the page element identification in the user page aimed at by the test operation.
The identification of the page element comprises the name and/or a locator of the page element, and the locator can record the position information of the page element on the user page to be tested;
204. and (5) the server builds an automatic testing framework.
The automatic testing framework is used for testing automation. The method can provide basic functions of compiling the automatic test case, executing the automatic test case, generating the automatic test report and the like. According to the embodiment, an automatic test frame corresponding to the user page to be tested can be set up, and the automatic test frame is deployed in an automatic test environment.
205. And when a test instruction aiming at the user page is received, the server acquires each page element operation method and the page elements to be operated in the target test case.
206. And the server calls the corresponding page object class based on the automatic test framework and the operation method of each page element and calls the automatic script file to drive the corresponding page element to be operated so as to simulate the operation behavior of a user and execute the automatic test of the service function borne by the page element to obtain a test result.
The automatic script file can be called to drive the corresponding page element to be operated to execute the test operation indicated in the target test case.
Optionally, in this embodiment, the method for automatically testing a user page may further include:
when the test is passed, writing the test result into the test report of the target test case;
and when the test process is abnormal, triggering an automatic screenshot function, and writing the intercepted image into the test report of the target test case.
In this embodiment, the test failure part in the test report may include an operation screenshot when the test fails, so that the test report is more intuitive.
As can be seen from the above, in this embodiment, an automatic script file recorded by a client may be obtained by a server, where the automatic script file is obtained by a user performing script recording on a user page at the client through a playright script recording command; generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client; according to the page element identifier in the user page aimed at by the test operation, positioning a page element corresponding to the page element identifier in the user page; building an automatic test frame; when a test instruction for the user page is received, acquiring each page element operation method and page elements to be operated in the target test case; and calling corresponding page object classes based on the automatic test framework and the operation methods of the page elements, and calling the automatic script file to drive the corresponding page elements to be operated so as to simulate user operation behaviors and execute automatic test of service functions borne by the page elements to obtain test results. The method and the device can reduce the test cost of the whole user interface, have less code redundancy and are beneficial to improving the test efficiency and the quality of software products.
In order to better implement the above method, an embodiment of the present application further provides an automatic testing apparatus for a user page, as shown in fig. 3, the automatic testing apparatus for a user page may include an obtaining unit 301, a generating unit 302, a positioning unit 303, a building unit 304, and a testing unit 305, as follows:
(1) An acquisition unit 301;
and the acquisition unit is used for acquiring an automatic script file recorded by the client, wherein the automatic script file is obtained by recording a script on a user page by a user through a Playwright script recording command at the client.
(2) A generation unit 302;
and the generating unit is used for generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client.
Optionally, in some embodiments of the present application, the generating unit may include an executing subunit, a generating subunit, and a saving subunit, as follows:
the execution subunit is used for executing the automation script file at the client;
a generating subunit, configured to generate a target test case based on a test operation in the client;
and the storage subunit is used for receiving the target test case returned by the client and storing the target test case.
(3) A positioning unit 303;
and the positioning unit is used for positioning the page element corresponding to the page element identifier in the user page according to the page element identifier in the user page aimed at by the test operation.
(4) A construction unit 304;
and the building unit is used for building an automatic test frame.
Optionally, in some embodiments of the present application, the building unit may include a first packaging subunit, a second packaging subunit, and a third packaging subunit, as follows:
the first packaging subunit is used for packaging the client driver into a preset automatic test frame;
the second packaging subunit is used for packaging the page elements positioned in the user page into a page object of a preset automatic test frame;
and the third packaging subunit is used for packaging a target tool into a preset automatic test frame to obtain the automatic test frame, wherein the target tool comprises any one or any combination of a drive data reading and writing tool, a log recording tool and a configuration tool.
(5) A test unit 305;
and the test unit is used for calling the automatic script file to carry out automatic test on the service function of the page element positioned in the user page based on the automatic test frame and the target test case when receiving a test instruction aiming at the user page, so as to obtain a test result.
Optionally, in some embodiments of the present application, the test unit may include an obtaining subunit and a testing subunit, as follows:
the acquiring subunit is configured to acquire each page element operation method and a page element to be operated in the target test case;
and the testing subunit is used for calling the corresponding page object class based on the automatic testing framework and the operation method of each page element, calling the automatic script file to drive the corresponding page element to be operated so as to simulate the operation behavior of a user, and executing the automatic testing of the service function borne by the page element to obtain a testing result.
Optionally, in some embodiments of the present application, the automatic testing apparatus for a user page may further include a result writing unit and a screenshot unit, as follows:
the result writing unit is used for writing the test result into the test report of the target test case when the test passes;
and the screenshot unit is used for triggering an automatic screenshot function when an abnormality occurs in the test process, and writing the captured image into the test report of the target test case.
Optionally, in some embodiments of the present application, the types of the test operation include: clicking, dereferencing and assigning the page elements.
As can be seen from the above, in this embodiment, the obtaining unit 301 may obtain an automatic script file recorded by a client, where the automatic script file is obtained by performing script recording on a user page by a playright script recording command at the client by a user; generating and storing a target test case according to the automatic script file through a generating unit 302, wherein the target test case records at least one test operation on a user page to be tested in the client; positioning, by a positioning unit 303, a page element corresponding to the page element identifier in the user page according to the page element identifier in the user page to which the test operation is directed; building an automated testing framework by the building unit 304; when a test instruction for the user page is received, the test unit 305 calls the automated script file to perform an automated test on a service function carried by a page element located in the user page based on the automated test framework and the target test case, so as to obtain a test result. The method and the device can reduce the test cost of the whole user interface, have less code redundancy and are beneficial to improving the test efficiency and the quality of software products.
An electronic device according to an embodiment of the present application is further provided, as shown in fig. 4, and shows a schematic structural diagram of the electronic device according to the embodiment of the present application, where the electronic device may be a terminal or a server, and specifically:
the electronic device may include components such as a processor 401 of one or more processing cores, memory 402 of one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that the electronic device configuration shown in fig. 4 does not constitute a limitation of the electronic device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the processor 401 is a control center of the electronic device, connects various parts of the entire electronic device using various interfaces and lines, performs various functions of the electronic device and processes data by operating or executing software programs and/or modules stored in the memory 402 and calling data stored in the memory 402. Optionally, processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 401.
The memory 402 may be used to store software programs and modules, and the processor 401 executes automated testing of various functional applications and user pages by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to use of the electronic device, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 access to the memory 402.
The electronic device further comprises a power supply 403 for supplying power to the various components, and preferably, the power supply 403 is logically connected to the processor 401 through a power management system, so that the functions of charging, discharging, and power consumption management are managed through the power management system. The power supply 403 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
The electronic device may further include an input unit 404, and the input unit 404 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
Although not shown, the electronic device may further include a display unit and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable file corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and the processor 401 runs the application programs stored in the memory 402, thereby implementing various functions as follows:
acquiring an automatic script file recorded by a client, wherein the automatic script file is obtained by performing script recording on a user page through a Playright script recording command by a user at the client; generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client; according to the page element identifier in the user page aimed at by the test operation, positioning a page element corresponding to the page element identifier in the user page; building an automatic testing frame; and when a test instruction aiming at the user page is received, calling the automatic script file to carry out automatic test on the service function of the page element positioned in the user page based on the automatic test framework and the target test case to obtain a test result.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
As can be seen from the above, the present embodiment may obtain an automatic script file recorded by a client, where the automatic script file is obtained by performing script recording on a user page by a playright script recording command at the client by a user; generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client; according to page element identification in the user page aimed at by the test operation, positioning a page element corresponding to the page element identification in the user page; building an automatic testing frame; and when a test instruction aiming at the user page is received, based on the automatic test framework and the target test case, calling the automatic script file to carry out automatic test on the service function of the page element positioned in the user page, and obtaining a test result. The method and the device can reduce the test cost of the whole user interface, have less code redundancy and are beneficial to improving the test efficiency and the quality of software products.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions, or by instructions controlling associated hardware, which may be stored in a computer-readable storage medium and loaded and executed by a processor.
To this end, embodiments of the present application provide a computer-readable storage medium, in which a plurality of instructions are stored, where the instructions can be loaded by a processor to perform steps in any one of the methods for automatically testing a user page provided in embodiments of the present application. For example, the instructions may perform the steps of:
acquiring an automatic script file recorded by a client, wherein the automatic script file is obtained by performing script recording on a user page through a Playwright script recording command by a user at the client; generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client; according to the page element identifier in the user page aimed at by the test operation, positioning a page element corresponding to the page element identifier in the user page; building an automatic test frame; and when a test instruction aiming at the user page is received, calling the automatic script file to carry out automatic test on the service function of the page element positioned in the user page based on the automatic test framework and the target test case to obtain a test result.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Wherein the computer-readable storage medium may include: read Only Memory (ROM), random Access Memory (RAM), magnetic or optical disks, and the like.
Since the instructions stored in the computer-readable storage medium may execute the steps in the method for automatically testing any user page provided in the embodiment of the present application, the beneficial effects that can be achieved by the method for automatically testing any user page provided in the embodiment of the present application may be achieved, for which details are given in the foregoing embodiments and are not described herein again.
According to an aspect of the application, a computer program product or computer program is provided, comprising computer instructions, the computer instructions being stored in a computer readable storage medium. The computer instructions are read by a processor of the computer device from the computer-readable storage medium, and the computer instructions are executed by the processor to cause the computer device to perform the methods provided in the various alternative implementations of the automated testing aspect of the user page described above.
The above detailed description is provided for the automated testing method for the user page and the related devices provided in the embodiment of the present application, and a specific example is applied in the present application to explain the principle and the implementation manner of the present application, and the description of the above embodiment is only used to help understanding the method and the core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. An automated testing method for a user page is characterized by comprising the following steps:
acquiring an automatic script file recorded by a client, wherein the automatic script file is obtained by performing script recording on a user page through a Playright script recording command by a user at the client;
generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client;
according to the page element identifier in the user page aimed at by the test operation, positioning a page element corresponding to the page element identifier in the user page;
building an automatic testing frame;
and when a test instruction aiming at the user page is received, calling the automatic script file to carry out automatic test on the service function of the page element positioned in the user page based on the automatic test framework and the target test case to obtain a test result.
2. The method of claim 1, wherein the building an automated testing framework comprises:
packaging the client driver into a preset automatic test frame;
packaging the positioned page elements in the user page into a page object of a preset automatic test frame;
and packaging a target tool into a preset automatic test frame to obtain the automatic test frame, wherein the target tool comprises any one or any combination of a drive data reading and writing tool, a log recording tool and a configuration tool.
3. The method according to claim 1, wherein the invoking the automated script file to perform an automated test of a service function carried by a page element located in the user page based on the automated test framework and the target test case to obtain a test result comprises:
acquiring each page element operation method and page elements to be operated in the target test case;
and calling corresponding page object classes based on the automatic test framework and the operation methods of the page elements, and calling the automatic script file to drive the corresponding page elements to be operated so as to simulate user operation behaviors and execute automatic test of service functions borne by the page elements to obtain test results.
4. The method of claim 1, further comprising:
when the test is passed, writing the test result into the test report of the target test case;
and when an abnormality occurs in the test process, triggering an automatic screenshot function, and writing the captured image into a test report of the target test case.
5. The method of claim 1, wherein the type of test operation comprises: clicking, dereferencing and assigning the page elements.
6. The method of claim 1, wherein generating and storing target test cases according to the automation script file comprises:
executing the automation script file at the client;
generating a target test case based on the test operation in the client;
and receiving the target test case returned by the client, and storing the target test case.
7. An automated testing device for user pages, comprising:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring an automatic script file recorded by a client, and the automatic script file is obtained by carrying out script recording on a user page through a Playright script recording command by a user at the client;
the generating unit is used for generating and storing a target test case according to the automatic script file, wherein the target test case records at least one test operation on a user page to be tested in the client;
the positioning unit is used for positioning a page element corresponding to the page element identifier in the user page according to the page element identifier in the user page aimed at by the test operation;
the building unit is used for building an automatic testing frame;
and the testing unit is used for calling the automatic script file to carry out automatic testing on the service function of the positioned page element in the user page based on the automatic testing frame and the target testing case when a testing instruction aiming at the user page is received, so as to obtain a testing result.
8. An electronic device comprising a memory and a processor; the memory stores an application program, and the processor is used for running the application program in the memory to execute the operation in the automatic test method of the user page according to any one of claims 1 to 6.
9. A computer readable storage medium storing instructions adapted to be loaded by a processor to perform the steps of the method for automated testing of user pages of any of claims 1 to 6.
10. A computer program product comprising a computer program or instructions, characterized in that the computer program or instructions, when executed by a processor, implement the steps in the method for automated testing of user pages of any of claims 1 to 6.
CN202211371081.7A 2022-11-03 2022-11-03 Automatic testing method for user page and related equipment Pending CN115658529A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211371081.7A CN115658529A (en) 2022-11-03 2022-11-03 Automatic testing method for user page and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211371081.7A CN115658529A (en) 2022-11-03 2022-11-03 Automatic testing method for user page and related equipment

Publications (1)

Publication Number Publication Date
CN115658529A true CN115658529A (en) 2023-01-31

Family

ID=84995892

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211371081.7A Pending CN115658529A (en) 2022-11-03 2022-11-03 Automatic testing method for user page and related equipment

Country Status (1)

Country Link
CN (1) CN115658529A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115858397A (en) * 2023-02-03 2023-03-28 江苏银承网络科技股份有限公司 APP automatic test method and device and automatic test system
CN116521572A (en) * 2023-07-03 2023-08-01 天津金城银行股份有限公司 Webpage script visual verification method, system, terminal equipment and storage medium
CN117234946A (en) * 2023-11-10 2023-12-15 深圳市金政软件技术有限公司 Automatic test method and related equipment for project library system
CN117539773A (en) * 2023-11-22 2024-02-09 东风本田发动机有限公司 Vehicle-mounted data acquisition method and device

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115858397A (en) * 2023-02-03 2023-03-28 江苏银承网络科技股份有限公司 APP automatic test method and device and automatic test system
CN116521572A (en) * 2023-07-03 2023-08-01 天津金城银行股份有限公司 Webpage script visual verification method, system, terminal equipment and storage medium
CN116521572B (en) * 2023-07-03 2023-09-19 天津金城银行股份有限公司 Webpage script visual verification method, system, terminal equipment and storage medium
CN117234946A (en) * 2023-11-10 2023-12-15 深圳市金政软件技术有限公司 Automatic test method and related equipment for project library system
CN117234946B (en) * 2023-11-10 2024-02-02 深圳市金政软件技术有限公司 Automatic test method and related equipment for project library system
CN117539773A (en) * 2023-11-22 2024-02-09 东风本田发动机有限公司 Vehicle-mounted data acquisition method and device

Similar Documents

Publication Publication Date Title
US9846638B2 (en) Exposing method related data calls during testing in an event driven, multichannel architecture
CN115658529A (en) Automatic testing method for user page and related equipment
CN105094783B (en) method and device for testing stability of android application
CN110013672B (en) Method, device, apparatus and computer-readable storage medium for automated testing of machine-run games
CN110825619A (en) Automatic generation method and device of interface test case and storage medium
CA2508196A1 (en) Smart ui recording and playback framework
US11138097B2 (en) Automated web testing framework for generating and maintaining test scripts
CN110362490B (en) Automatic testing method and system for integrating iOS and Android mobile applications
US20200327043A1 (en) System and a method for automated script generation for application testing
CN113505082B (en) Application program testing method and device
US20220229769A1 (en) Test automation systems and methods using logical identifiers
CN109933521A (en) Automated testing method, device, computer equipment and storage medium based on BDD
US8819631B2 (en) System and method for self dependent web automation
CN112231206A (en) Script editing method for application program test, computer readable storage medium and test platform
CN102479152A (en) Method and device for obtaining tool automatic test results on basis of Android platform
CN114297056A (en) Automatic testing method and system
CN111444109B (en) Mobile terminal UI automatic test method and system
CN111078529A (en) Client write-in module testing method and device and electronic equipment
CN115509925A (en) Automatic interface testing method and related device
Carino et al. BlackHorse: creating smart test cases from brittle recorded tests
CN109669868A (en) The method and system of software test
JP7319516B2 (en) Program, information processing device, and control method thereof
CN115543807A (en) Automatic regression testing method and device, computer equipment and storage medium
WO2024001594A1 (en) Operator development method and apparatus, operator processing method and apparatus, and electronic device, system and storage medium
CN117762802A (en) Automatic test method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination