CN113791968A - UI automation test method, system, electronic equipment and storage medium - Google Patents
UI automation test method, system, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN113791968A CN113791968A CN202110916229.XA CN202110916229A CN113791968A CN 113791968 A CN113791968 A CN 113791968A CN 202110916229 A CN202110916229 A CN 202110916229A CN 113791968 A CN113791968 A CN 113791968A
- Authority
- CN
- China
- Prior art keywords
- page
- test
- resource file
- creating
- pretest
- 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
Links
- 238000010998 test method Methods 0.000 title claims abstract description 8
- 238000012360 testing method Methods 0.000 claims abstract description 76
- 238000000034 method Methods 0.000 claims abstract description 70
- 238000013515 script Methods 0.000 claims description 11
- 238000004590 computer program Methods 0.000 claims description 10
- 238000004088 simulation Methods 0.000 claims description 6
- 238000000605 extraction Methods 0.000 claims description 4
- 238000012423 maintenance Methods 0.000 abstract description 2
- 230000008569 process Effects 0.000 description 12
- 230000006870 function Effects 0.000 description 9
- 238000010586 diagram Methods 0.000 description 4
- 238000001545 Page's trend test Methods 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000008676 import Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000013522 software testing Methods 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention provides a UI automation test method, a system, electronic equipment and a storage medium, wherein the method comprises the following steps: creating a page resource file corresponding to the pretest page as an object, and defining an element locator and an operation method in the page object; extracting element locators and operation methods shared by a plurality of pretest pages into corresponding universal component resource files; and importing the universal component resource file into the test suite, and calling an operation method of the page object corresponding to the universal component resource file to simulate user operation so as to realize UI (user interface) element test. Therefore, the automatic test efficiency of the UI page can be improved, the test code repetition is reduced, and the maintenance cost is reduced.
Description
Technical Field
The invention belongs to the field of software testing, and particularly relates to a UI automatic testing method, a UI automatic testing system, electronic equipment and a storage medium.
Background
The UI (user interface) automatic test plays an increasingly important role in guaranteeing the quality of Web products, and how to establish a simple, ordered and easy-to-use UI automatic frame constitutes a crucial step. The front end of the Web product generally comprises a webpage, functional components are presented in the webpage, and the components are communicated with each other or with the back end, so that the requirements of users are met.
At the present stage, the Web automation usually uses a function module as a dimension to write an automation script, so that the characteristic of mutual independence between Web pages is not utilized, and the Web automation conforms to the traditional testing thinking. As product functions increase, test scripts become increasingly burdensome, and the same page elements or functions are always reused by different processes, resulting in a large amount of test code duplication.
Disclosure of Invention
In view of this, embodiments of the present invention provide a UI automation testing method, system, electronic device, and storage medium, which are used to solve the problem of a large amount of code duplication in the existing page test.
In a first aspect of the embodiments of the present invention, a method for UI automation test is provided, including:
creating a page resource file corresponding to the pretest page as an object, and defining an element locator and an operation method in the page object;
extracting element locators and operation methods shared by a plurality of pretest pages into corresponding universal component resource files;
and importing the universal component resource file into the test suite, and calling an operation method of the page object corresponding to the universal component resource file to simulate user operation so as to realize UI (user interface) element test.
In a second aspect of the embodiments of the present invention, there is provided a UI automation test system, including:
the creating module is used for creating a page resource file corresponding to the pretest page as an object and defining an element locator and an operation method in the page object;
the resource extraction module is used for extracting the element locators and the operation methods which are shared in the plurality of pre-test pages into the corresponding universal component resource files;
and the simulation test module is used for importing the universal component resource file into the test suite and calling the operation method of the page object corresponding to the universal component resource file to simulate user operation so as to realize UI (user interface) element test.
In a third aspect of the embodiments of the present invention, there is provided an apparatus, including a memory, a processor, and a computer program stored in the memory and executable by the processor, where the processor executes the computer program to implement the steps of the method according to the first aspect of the embodiments of the present invention.
In a fourth aspect of the embodiments of the present invention, a computer-readable storage medium is provided, which stores a computer program, which when executed by a processor implements the steps of the method provided by the first aspect of the embodiments of the present invention.
In the embodiment of the invention, the page object corresponding to the test page is created, the element locator and the operation method are defined in the page object, and the operation method of the page object is called to simulate the user operation, so that the test code reuse rate can be improved, the test code compiling and maintaining efficiency can be improved, the automatic code maintaining cost can be reduced, and the code and the product can keep high consistency.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings described below are only some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a UI automation testing method according to an embodiment of the present invention;
FIG. 2 is another schematic flow chart of a UI automation test method according to an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of a UI automation test system according to an embodiment of the invention;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the embodiments described below are only a part of the embodiments of the present invention, 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 invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification or claims and in the accompanying drawings, are intended to cover a non-exclusive inclusion, such that a process, method or system, or apparatus that comprises a list of steps or elements is not limited to the listed steps or elements. In addition, "first" and "second" are used to distinguish different objects, and are not used to describe a specific order.
Referring to fig. 1, a flow chart of a UI automation testing method according to an embodiment of the present invention is schematically illustrated, including:
s101, establishing a page resource file corresponding to a pretest page as an object, and defining an element locator and an operation method in the page object;
the page resource file refers to a resource file in a page to be tested (such as HTML), and comprises pictures, texts, tags, dialog boxes, JavaScript and the like. The page object is to define the test page as a class, the class can position the page element object to be tested, and define the operation method of the corresponding element. The test code can be separated from the page elements and the operation method of the page to be tested based on the page object, and the influence of the page elements on the test code is reduced.
As shown in fig. 2, before creating the page object, the method includes: and creating a test suite corresponding to the test module, and compiling a test script corresponding to the test case in the test suite. The Test module is used for testing a single subprogram or a single process of the program, respectively creating a Test Suite (Test Suite) corresponding to the Test module, and creating a Test case corresponding to the Test script, so that page elements can be tested based on the script.
Wherein, the operation of the page element by the element locator is defined in the operation method. The same element of the page can be tested by the element operation method.
S102, extracting element locators and operation methods shared by a plurality of pretest pages into corresponding universal component resource files;
specifically, resources (including locators and methods) shared by multiple pages are extracted into corresponding universal resource files. For resources shared in multiple pages, i.e. the same page element object, the shared resources are extracted into a component resource file so as to test the page elements by calling operation methods in the object.
S103, importing the universal component resource file into the test suite, and calling an operation method of the page object corresponding to the universal component resource file to simulate user operation so as to realize UI (user interface) element test.
Specifically, the operation method created in the page object is called by using the use case script, so that the simulation of the user operation is realized. The operation method of the page object comprises operation logic of the element, for example, clicking a button to enter a new page or judging whether the input content of a user is correct, and calling the operation method can trigger the page response logic of the element, so that the user operation can be simulated, and errors in the test can be found.
And traversing to obtain the pages to be tested with the same elements, and marking the corresponding pages to be tested.
In the embodiment, the test method of the POM architecture is adopted, the test codes are separated from the page elements and the method, the logic of the test page codes is effectively organized, the page test efficiency can be improved, and the maintenance cost is reduced.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Fig. 3 is a schematic structural diagram of a UI automation test system according to an embodiment of the present invention, where the system includes:
a creating module 310, configured to create a page resource file corresponding to the pretest page as an object, and define an element locator and an operation method in the page object;
and creating a test suite corresponding to the test module, and writing a test script corresponding to the test case in the test suite.
Wherein, the operation of the page element by the element locator is defined in the operation method.
A resource extraction module 320, configured to extract the element locator and the operation method that are shared in the multiple pretest pages into the corresponding universal component resource file;
the simulation test module 330 is configured to import a universal component resource file into the test suite, and invoke an operation method of a page object corresponding to the universal component resource file to simulate a user operation, so as to implement a UI interface element test.
Specifically, the operation method created in the page object is called by using the use case script, so that the simulation of the user operation is realized.
And traversing to obtain the pages to be tested with the same elements, and marking the corresponding pages to be tested.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the apparatus and the modules described above may refer to corresponding processes in the foregoing method embodiments, and are not described herein again.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. The electronic equipment is used for the automatic test of U I pages. As shown in fig. 4, the electronic apparatus 4 of this embodiment includes: a memory 410, a processor 420, and a system bus 430, the memory 410 including an executable program 4101 stored thereon, it being understood by those skilled in the art that the electronic device configuration shown in fig. 4 does not constitute a limitation of electronic devices and may include more or fewer components than shown, or some components in combination, or a different arrangement of components.
The following describes each component of the electronic device in detail with reference to fig. 4:
the memory 410 may be used to store software programs and modules, and the processor 420 executes various functional applications and data processing of the electronic device by operating the software programs and modules stored in the memory 410. The memory 410 may mainly include a storage program area and a storage data area, wherein the storage program 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 (such as cache data) created according to the use of the electronic device, and the like. Further, the memory 410 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.
The executable program 4101 of the network request method is contained on the memory 410, the executable program 4101 may be divided into one or more modules/units, the one or more modules/units are stored in the memory 410 and executed by the processor 420 to implement the driving data consistency check and the like, and the one or more modules/units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used for describing the execution process of the computer program 4101 in the electronic device 4. For example, the computer program 4101 may be divided into a creation module, a resource extraction module, and a simulation test module.
The processor 420 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 410 and calling data stored in the memory 410, thereby performing overall status monitoring of the electronic device. Alternatively, processor 420 may include one or more processing units; preferably, the processor 420 may integrate an application processor, which mainly handles operating systems, 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 processor 420.
The system bus 430 is used to connect various functional units in the computer, and can transmit data information, address information, and control information, and may be, for example, a PC I bus, an isa bus, a VESA bus, etc. The instructions of the processor 420 are transmitted to the memory 410 through the bus, the memory 410 feeds data back to the processor 420, and the system bus 430 is responsible for data and instruction interaction between the processor 420 and the memory 410. Of course, the system bus 430 may also access other devices such as network interfaces, display devices, and the like.
In this embodiment of the present invention, the executable program executed by the process 420 included in the electronic device includes:
creating a page resource file corresponding to the pretest page as an object, and defining an element locator and an operation method in the page object;
extracting element locators and operation methods shared by a plurality of pretest pages into corresponding universal component resource files;
and importing the universal component resource file into the test suite, and calling an operation method of the page object corresponding to the universal component resource file to simulate user operation so as to realize UI (user interface) element test.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.
Claims (10)
1. A UI automation test method is characterized by comprising the following steps:
creating a page resource file corresponding to the pretest page as an object, and defining an element locator and an operation method in the page object;
extracting element locators and operation methods shared by a plurality of pretest pages into corresponding universal component resource files;
and importing the universal component resource file into the test suite, and calling an operation method of the page object corresponding to the universal component resource file to simulate user operation so as to realize UI (user interface) element test.
2. The method of claim 1, wherein creating the page resource file corresponding to the pretest page as the object further comprises:
and creating a test suite corresponding to the test module, and compiling a test script corresponding to the test case in the test suite.
3. The method of claim 1, wherein defining element locators and operation methods in a page object comprises:
the operation method defines the operation of the page element realized by the element locator.
4. The method of claim 1, wherein the invoking of the operation method of the page object corresponding to the universal component resource file simulates user operation comprising:
and calling the operation method created in the page object by using the use case script to simulate the user operation.
5. The method of claim 1, wherein extracting the element locator and the operation method common to the plurality of pretest pages into the corresponding generic component resource file further comprises:
and traversing to obtain the pages to be tested with the same elements, and marking the corresponding pages to be tested.
6. An automated UI testing system, comprising:
the creating module is used for creating a page resource file corresponding to the pretest page as an object and defining an element locator and an operation method in the page object;
the resource extraction module is used for extracting the element locators and the operation methods which are shared in the plurality of pre-test pages into the corresponding universal component resource files;
and the simulation test module is used for importing the universal component resource file into the test suite and calling the operation method of the page object corresponding to the universal component resource file to simulate user operation so as to realize UI (user interface) element test.
7. The system of claim 6, wherein creating the page resource file corresponding to the pretest page as the object further comprises:
and creating a test suite corresponding to the test module, and compiling a test script corresponding to the test case in the test suite.
8. The system according to claim 6, wherein the defining element locators and operation methods in page objects comprises:
the operation method defines the operation of the page element realized by the element locator.
9. A terminal device comprising a memory, a processor and a computer program stored in said memory and executable on said processor, characterized in that said processor, when executing said computer program, implements the steps of the UI automation test method according to any one of claims 1 to 5.
10. A computer-readable storage medium, storing a computer program, wherein the computer program, when executed, implements the steps of the UI automation test method according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110916229.XA CN113791968A (en) | 2021-08-10 | 2021-08-10 | UI automation test method, system, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110916229.XA CN113791968A (en) | 2021-08-10 | 2021-08-10 | UI automation test method, system, electronic equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113791968A true CN113791968A (en) | 2021-12-14 |
Family
ID=78875815
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110916229.XA Pending CN113791968A (en) | 2021-08-10 | 2021-08-10 | UI automation test method, system, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113791968A (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107678943A (en) * | 2017-09-01 | 2018-02-09 | 千寻位置网络有限公司 | The page automated testing method of abstract page object |
WO2019196274A1 (en) * | 2018-04-10 | 2019-10-17 | 平安科技(深圳)有限公司 | Web page testing method and apparatus, electronic device, and medium |
CN110941556A (en) * | 2019-11-27 | 2020-03-31 | 厦门市美亚柏科信息股份有限公司 | Method for rapidly compiling test cases on Android platform |
-
2021
- 2021-08-10 CN CN202110916229.XA patent/CN113791968A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107678943A (en) * | 2017-09-01 | 2018-02-09 | 千寻位置网络有限公司 | The page automated testing method of abstract page object |
WO2019196274A1 (en) * | 2018-04-10 | 2019-10-17 | 平安科技(深圳)有限公司 | Web page testing method and apparatus, electronic device, and medium |
CN110941556A (en) * | 2019-11-27 | 2020-03-31 | 厦门市美亚柏科信息股份有限公司 | Method for rapidly compiling test cases on Android platform |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108628741B (en) | Webpage testing method and device, electronic equipment and medium | |
US10613971B1 (en) | Autonomous testing of web-based applications | |
CN106326104B (en) | Terminal control testing method and device | |
CN107526676B (en) | Cross-system test method and device | |
US20170192877A1 (en) | Mobile application development and deployment | |
CN107688529B (en) | Component debugging method and device | |
US9053241B2 (en) | Scripting application with role identification | |
CN105320589B (en) | The automatic resolution system of test script and its implementation in cloud test environment | |
KR20080053293A (en) | Initial server-side content rendering for client-script web pages | |
CN105630524B (en) | Web page text analytic method, device and mobile terminal | |
JP2006323812A (en) | Method and device for evaluating various phases of web page | |
CN104102578A (en) | Test method and system and operation terminal | |
CN108614762A (en) | A kind of browser testing method and device | |
CN110727429A (en) | Front-end page generation method, device and equipment | |
EP3457274A1 (en) | System and method for creating domain specific language | |
CN111290996A (en) | Document format conversion method, device, equipment and readable storage medium | |
CN113360379B (en) | Program test environment creation method and program test environment creation apparatus | |
JP6902814B1 (en) | Test support system, test support method and program | |
CN112231197A (en) | Page testing method and device and storage medium | |
US9104573B1 (en) | Providing relevant diagnostic information using ontology rules | |
CN109669799B (en) | Error reporting control method, device and storage medium | |
CN113791968A (en) | UI automation test method, system, electronic equipment and storage medium | |
CN111124924A (en) | API (application program interface) deployment method and device, electronic equipment and storage medium | |
CN105306928A (en) | Method and device for testing set top box browser | |
CN111324332A (en) | Big data task processing method and system, electronic device 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 |