CN113704110B - Automatic testing method and device for user interface - Google Patents
Automatic testing method and device for user interface Download PDFInfo
- Publication number
- CN113704110B CN113704110B CN202111003625.XA CN202111003625A CN113704110B CN 113704110 B CN113704110 B CN 113704110B CN 202111003625 A CN202111003625 A CN 202111003625A CN 113704110 B CN113704110 B CN 113704110B
- Authority
- CN
- China
- Prior art keywords
- page
- preset
- test
- mobile terminal
- target control
- 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.)
- Active
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 307
- 238000000034 method Methods 0.000 claims abstract description 35
- 238000013515 script Methods 0.000 claims abstract description 23
- 230000009191 jumping Effects 0.000 claims abstract description 19
- 238000009877 rendering Methods 0.000 claims abstract description 7
- 238000004088 simulation Methods 0.000 claims abstract description 7
- 230000006870 function Effects 0.000 claims description 13
- 238000004590 computer program Methods 0.000 claims description 9
- 238000004422 calculation algorithm Methods 0.000 claims description 5
- 230000008569 process Effects 0.000 description 9
- 230000004044 response Effects 0.000 description 8
- 238000010998 test method Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000008859 change Effects 0.000 description 2
- 238000012812 general test Methods 0.000 description 2
- 238000010295 mobile communication Methods 0.000 description 2
- 238000012544 monitoring process Methods 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000013135 deep learning Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000007613 environmental effect Effects 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
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
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/14—Network analysis or design
- H04L41/145—Network analysis or design involving simulating, designing, planning or modelling of a network
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)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Mobile Radio Communication Systems (AREA)
- Debugging And Monitoring (AREA)
Abstract
The application discloses an automatic testing method of a user interface. The method comprises the following steps: the method comprises the steps that a server device obtains a preset test case, and the test case is used for testing the function of jumping to a preset jumping page after clicking a target control; the server device executes an automatic test script corresponding to the test case through a preset user interface automatic test tool so as to send a test instruction aiming at the target control to the mobile terminal device; the mobile terminal equipment sends a network request to a preset server according to the test instruction so as to access a page to be displayed, wherein the page to be displayed comprises the target control; the mobile terminal equipment receives simulation page data returned by a preset proxy service based on the intercepted network request, and performs page rendering according to the simulation page data to obtain a simulation page; and the mobile terminal equipment acquires the jump page link according to the test instruction and jumps to the jump page according to the jump page link. The application can improve the test efficiency.
Description
Technical Field
The present application relates to the field of testing technologies, and in particular, to an automatic testing method and apparatus for a user interface.
Background
After developing a User Interface (UI) of an Application (App) of a mobile terminal device, a developer generally needs to test the UI to determine whether the UI can implement a preset function.
In the prior art, when testing the operation of the page corresponding to the jump after clicking the control by using the test case, the data returned by the server is often changed, so that when testing the function in the prior art, the jump page is different from the corresponding page in the case due to the change of the data, and the test case cannot pass the test failure.
Disclosure of Invention
In view of this, an automated testing method, apparatus, computer device and computer readable storage medium for a user interface are now provided to solve the problem that in the prior art, control elements of an App cannot be accurately identified when testing the UI of the App.
The application provides an automatic testing method of a user interface, which comprises the following steps:
the method comprises the steps that a server device obtains a preset test case, and the test case is used for testing the function of jumping to a preset jumping page after clicking a target control;
the server-side equipment executes an automatic test script corresponding to the test case through a preset user interface automatic test tool so as to send a test instruction aiming at the target control to the mobile-side equipment;
The mobile terminal equipment sends a network request to a preset server according to the test instruction so as to access a page to be displayed, wherein the page to be displayed comprises the target control;
The mobile terminal equipment receives simulated page data returned by a preset proxy service based on the intercepted network request, and performs page rendering according to the simulated page data to obtain a simulated page, wherein the proxy service intercepts the page data to be displayed returned by the server, modifies an original page link corresponding to the target control contained in the page data to be displayed into a preset jump page link, and generates the simulated page data;
and the mobile terminal equipment acquires the jump page link according to the test instruction and jumps to the jump page according to the jump page link.
Optionally, the proxy service intercepts page data to be displayed returned by the server, modifies an original page link corresponding to the target control included in the page data to be displayed into a preset skip page link, and generating the simulated page data includes:
The proxy service intercepts page data to be displayed returned by the server, and searches the original page link from the page data to be displayed according to field information corresponding to the target control;
The proxy service modifies the original page link into the jump page link, and takes the modified page data to be displayed as the simulated page data.
Optionally, the test instruction further includes parameter information of the proxy service, and before the step of accessing the page to be displayed, the mobile terminal device sends a network request to a preset server according to the test instruction, the method further includes:
and the mobile terminal equipment is connected with the proxy service according to the parameter information.
Optionally, the mobile terminal device obtains the jump page link according to the test instruction, and jumps to the jump page according to the jump page link includes:
the mobile terminal equipment identifies the target control from the simulation page according to the test instruction;
the mobile terminal equipment clicks the target control according to the test instruction;
the mobile terminal device constructs a route jump request according to clicking operation on the target control;
and the mobile terminal equipment jumps to the jump page according to the route jump request.
Optionally, the mobile terminal device identifying the target control from the simulated page according to the test instruction includes:
the mobile terminal equipment performs screenshot operation on the simulated page to obtain a screenshot image;
And the mobile terminal equipment adopts a preset image recognition algorithm to recognize the target control from the screenshot image.
Optionally, the automatic test tool is Appium, and the server device executes, through a preset user interface, an automatic test script corresponding to the test case by using the automatic test tool, so as to send a test instruction for the target control to the mobile terminal device, where the method includes:
The server device starts Appium;
The server-side equipment converts the automatic test script into the test instruction through Appium and sends the test instruction to the mobile-side equipment.
Optionally, the obtaining, by the server device, a preset test case includes:
The server equipment sequentially acquires test cases from a test case file of an application to be tested;
the server equipment judges whether the currently acquired test case is the preset test case or not;
If the test case currently acquired by the server device is not the preset test case, the server device continues to acquire the test case from the test case file until the preset test case is acquired.
The application also provides an automatic testing system of the user interface, which comprises a server device and a mobile terminal device, wherein:
The server device is used for acquiring a preset test case, and the test case is used for testing the function of jumping to a preset jump page after clicking the target control;
The server device is further configured to execute an automation test script corresponding to the test case through a preset user interface automation test tool, so as to send a test instruction for the target control to the mobile terminal device;
The mobile terminal equipment is used for sending a network request to a preset server according to the test instruction so as to access a page to be displayed, wherein the page to be displayed comprises the target control;
The mobile terminal device is further configured to receive simulated page data returned by a preset proxy service based on the intercepted network request, and perform page rendering according to the simulated page data to obtain a simulated page, where the proxy service intercepts page data to be displayed returned by the server, modifies an original page link corresponding to the target control included in the page data to be displayed into a preset skip page link, and generates the simulated page data;
The mobile terminal device is further configured to obtain the jump page link according to the test instruction, and jump to the jump page according to the jump page link.
The application also provides a computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the above method when executing the computer program.
The application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the above method.
According to the automatic testing method of the user interface, in the automatic testing process of the user interface, the mobile terminal equipment loads the simulated page according to the testing instruction, and page display is not needed according to page data returned by the server. Because the jump page bound by the target control in the simulated page is a stable page, when the target control is clicked, a stable jump page can be displayed, the follow-up test case execution failure caused by unstable elements in the jump page is avoided, and the test efficiency is improved.
Drawings
FIG. 1 is an environmental schematic diagram of an automated testing method for a user interface according to an embodiment of the present application;
FIG. 2 is a flow chart of one embodiment of an automated testing method for a user interface according to the present application;
FIG. 3 is a detailed flowchart of a step of a server device obtaining a predetermined test case according to an embodiment of the present application;
FIG. 4 is a detailed flowchart of a step of the server device executing an automated test script corresponding to the test case through a preset user interface automated test tool to send a test instruction for the target control to the mobile device in an embodiment of the present application;
FIG. 5 is a detailed flowchart of a step of intercepting page data to be displayed returned by the server and modifying an original page link corresponding to the target control included in the page data to be displayed into a preset skip page link by a proxy service in an embodiment of the present application, so as to generate the simulated page data;
FIG. 6 is a detailed flowchart of a step of the mobile terminal device loading a preset simulated page according to the test instruction and jumping to the jumping page after completing the loading of the simulated page in an embodiment of the present application;
FIG. 7 is a detailed flowchart of a step of the mobile terminal device identifying the target control from the simulated page according to the test instruction in an embodiment of the present application;
FIG. 8 is a block diagram of one embodiment of an automated testing system for user interfaces according to the present application;
fig. 9 is a schematic hardware structure of a computer device for executing an automated testing method of a user interface according to an embodiment of the present application.
Detailed Description
Advantages of the application are further illustrated in the following description, taken in conjunction with the accompanying drawings and detailed description.
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
The terminology used in the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used in this disclosure and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in this disclosure to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present disclosure. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "in response to a determination" depending on the context.
In the description of the present application, it should be understood that the numerical references before the steps do not identify the order in which the steps are performed, but are merely used to facilitate description of the present application and to distinguish between each step, and thus should not be construed as limiting the present application.
FIG. 1 schematically illustrates an application environment schematic of an automated test method for a user interface according to an embodiment of the application. In an exemplary embodiment, the system of the application environment may include a mobile end device 10, a server end device 20. Wherein the mobile end device 10 forms a wireless or wired connection with the server end device 20. The mobile terminal device 10 may be a mobile phone, an iPAD, a tablet computer, etc. of an android system, or may be a mobile phone, an iPAD, a tablet computer, etc. of an IOS system. The server device 20 may be a computer, a server cluster formed by one or more servers, a cloud computing center, or the like, which is not limited herein. It should be noted that the automated testing method of the user interface in this embodiment may be applied to automated testing.
The automatic test of the User Interface (UI) refers to an automatic test means for simulating a User to manually operate the User interface in a code manner, realizing automatic operation and verifying whether the layout of the User interface functions is reasonable, whether the overall style is consistent and the placement position of each control accords with the use habit of a client, whether the operation is convenient and fast, whether the navigation is simple and easy to understand, whether the characters in the interface are correct, whether the naming is uniform, whether the page is attractive, whether the combination of the characters and the pictures is perfect, and the like.
Referring to fig. 2, a flow chart of an automated testing method of a user interface according to an embodiment of the application is shown. The automatic test method is applied to a user interface test system comprising a server device and a mobile terminal device, and it is understood that the flow chart in the embodiment of the method is not used for limiting the sequence of executing steps. As can be seen from the figure, the automated testing method for the user interface provided in the present embodiment includes:
Step S20, the server side equipment acquires a preset test case, wherein the test case is used for testing the function of jumping to a preset jumping page after clicking the target control.
Specifically, a Test Case refers to a description of a Test task performed on a specific software product, and represents a Test scheme, a method, a technology and a strategy. The content of the method comprises a test target, a test environment, input data, a test step, an expected result, a test script and the like, and finally a document is formed. Briefly, a test case is a set of test inputs, execution conditions, and expected results tailored for a particular goal to verify that a particular software requirement is met.
In this embodiment, in order to distinguish a general test case from the preset test case, a preset mark may be used to mark the preset test case, for example, a mark "1" may be used to represent the preset test case, and a mark "0" may be used to represent the general test case.
In this embodiment, the preset test case includes at least one test step, and each test step may be described by a test operation and a target control targeted by the test operation. By way of example, assume that there is a preset test case for testing the page B jump function of the application a, the test case including the following information:
Test case identification: application a_01;
Test function: testing the page jump function of the page A;
The testing steps are as follows: 1. sliding the refresh page to request the server to acquire page B; 2. click on target control C in page B.
Test results corresponding to the test steps: 1. displaying a page B; 2. the jump page D is displayed.
In this test case, "2, clicking on target control C in page B" is described by the test operations "clicking" and "target control C".
It should be noted that, each test step is preconfigured with a corresponding test result, where the test result is used to describe a user interface that is expected to be displayed after the corresponding test operation is performed. In this embodiment, the test result includes information of the simulated page and information of the jumped page.
It should be noted that, the server device in this embodiment is a device installed with a user interface automation test tool.
In an exemplary embodiment, referring to fig. 3, the obtaining, by the server device, a preset test case includes:
step S31, the server equipment sequentially acquires test cases from the test case files of the application to be tested.
Specifically, the application to be tested is an application requiring user interface automation test. In practical application, a tester can write a plurality of test cases for an application to be tested, store the plurality of test cases into one test case file, and then store the written test case file and the application identifier of the application to be tested in a pre-built test case library in an associated manner. In this way, when the UI automation test is performed on the application to be tested, the server device may first obtain a test case file from the test case library according to the application identifier of the application to be tested, and then sequentially obtain test cases from the test case file.
Step S31, the server device judges whether the currently acquired test case is the preset test case.
Specifically, preset identification information may be configured for the preset test case in advance, and whether the currently acquired test case is the preset test case is distinguished by the preset identification information.
Step S32, if the test case currently acquired by the server device is not the preset test case, the server device continues to acquire the test case from the test case file until the preset test case is acquired.
Specifically, when the server side device judges that the currently acquired test case does not contain preset identification information, the server side device can judge that the current test case is not the preset test case, and can continuously acquire the test case from the test case file until the preset test case is acquired; when the server side equipment judges that the currently acquired test case contains preset identification information, the current test case can be judged to be the preset test case.
Step S21, the server device executes the automatic test script corresponding to the test case through a preset user interface automatic test tool so as to send the test instruction aiming at the target control to the mobile terminal device.
Specifically, the user interface automation test tool is a tool for implementing the user interface automation test, and the user interface automation test tool may be UIAutomation, appium or the like, which is not limited in this embodiment.
Wherein UIAutomation is a UI automation framework provided by Microsoft, of course, its original purpose is not just to produce for automation test, its task is to call up UI control of windows to more development or application, but can also be used for automation test; since microsoft had similar tools before, this is a redesigned UI operation class framework, the purpose of which is to be compatible with UI automation operations [ xp, vista, server2003 ] supporting windows-series operating systems, and also to support WPF natively. Of course, the design is different from that of a common automatic tool, such as: the method supported by the control is not bound to the control object, no special mouse/keyboard event is provided, but the customization of the event response monitoring and processing method of the specific control object is provided. The workflow is approximately as follows:
a. there are various methods for acquiring a specific element object, such as: handle, attribute value, etc.
B. the schema of this element object is obtained.
C. specific method calls, attribute value acquisition, etc. are performed through this mode.
D. monitoring specific events of the specified object, and executing the specified event processing function once the specific events occur.
The method comprises the steps of enabling Appium to be a mobile terminal automatic test open source tool, supporting an iOS and an Android platform, supporting languages such as Python and Java, namely the same set of Java or Python scripts can be run on the iOS and the Android platform at the same time, enabling Appium to be a C/S framework, enabling a Web server to be a core, and providing an interface of a set of REST. After receiving the connection of the client, the client monitors the commands, executes the commands on the mobile device, and finally returns the execution result to the client after the execution result is put in the HTTP response.
In this embodiment, after the test case is compiled by the tester, the tester may compile an automation test script for automatically executing the test case according to the test case, so as to implement an automation test of the user interface through the automation test script.
It should be noted that, the automatic test in this embodiment refers to a test method in which a written automatic test script automatically runs a system or an application program under a preset condition, and evaluates a running result.
In this embodiment, after executing the automated test script, the automated test tool converts the automated test script into a test instruction that can be recognized by the mobile terminal device.
It should be noted that, the mobile terminal device in this embodiment is a mobile phone, an iPAD, a tablet computer, etc. of the android system to be subjected to the user interface test, or is a mobile phone, an iPAD, a tablet computer, etc. of the IOS system.
It will be appreciated that the automated test tool needs to establish a connection with the mobile device before the test instructions are sent to the mobile device. In this embodiment, in order to establish a connection with a mobile terminal device, the test instruction needs to include device information of the mobile terminal device, so that an automated test tool can find the mobile terminal device according to the device information, and establish a connection with the mobile terminal device.
In an exemplary embodiment, referring to fig. 4, the automatic test tool is Appium, and the server device executing, by using a preset user interface automatic test tool, an automatic test script corresponding to the test case, so as to send a test instruction for the target control to the mobile terminal device includes: step S40, the server device starts up Appium; and step S41, the server-side equipment converts the automatic test script into the test instruction through the Appium and sends the test instruction to the mobile-side equipment.
Specifically, appium is installed on the server device, when an automatic test of a user interface is required, a user can trigger a start instruction, the server can start Appium after receiving the start instruction, then the automatic test script can be converted into the test instruction through Appium, and the test instruction is sent to the mobile terminal device.
Step S22, the mobile terminal device sends a network request to a preset server according to the test instruction so as to access a page to be displayed, wherein the page to be displayed comprises the target control.
Specifically, the server provides services for the application to be tested, such as a server providing services of resources, data storage and the like. After receiving the test instruction of the server side equipment, the mobile side equipment firstly sends a network request to the server so as to acquire page data of a page to be displayed through the network request.
It should be noted that, the page to be displayed is a page containing the target control in the application program to be tested.
Step S23, the mobile terminal device receives simulated page data returned by a preset proxy service based on the intercepted network request, and performs page rendering according to the simulated page data to obtain a simulated page, wherein the proxy service intercepts page data to be displayed returned by the server, modifies an original page link corresponding to the target control contained in the page data to be displayed into a preset skip page link, and generates the simulated page data.
Specifically, when the mobile terminal device sends a network request to acquire page data to be displayed, the proxy service intercepts the network request, so that the acquired page data to be displayed of the network request can be modified into simulated page data, specifically, after the proxy service intercepts the network request, the proxy service forwards the network request to a corresponding server, after the server returns response data (page data to be displayed) based on the network request, the proxy service continues to intercept the response data, but does not return the response data to the mobile terminal device, and the original page link corresponding to the target control contained in the page data to be displayed is modified into a preset skip page link, so that simulated page data is obtained, and then the simulated page data is returned to the mobile terminal device, so that the simulated page data is used as the response data of the network request.
The proxy service is a software running on a computer, and when the computer using the proxy service exchanges information with the Internet, the information is sent to the proxy service, and the proxy service forwards the information, and the received response is returned to the computer.
In this embodiment, the analog page may also be referred to as a mock page, and is used to replace the page returned by the original server. The simulation page contains information of the target control.
As an example, the information of the target control included in the simulated page is as follows:
“id":87174,
"1ink":"https://www.bi1ibi1i.com/blackboard/dynamic/133628",
"pic":"https://10.hdslb.com/bfs/1ive/562d8f25d657e22aaf4da2fbe4f74a9f5ec267c7.Jpg",
"title": "MSI event predicts participation in interactive awards".
In this embodiment, the id field represents identification information of the target control; the link field represents that the target control has been bound to a jump page with an address link of "https:// www.bilibili.com/blackboard/dynamic/133628"; pic field represents the picture address information of the target control; the title field represents the title of the target control.
In an exemplary embodiment, referring to fig. 5, the proxy service intercepts page data to be displayed returned by the server, modifies an original page link corresponding to the target control included in the page data to be displayed into a preset skip page link, and generating the simulated page data includes:
And S50, the proxy service intercepts page data to be displayed returned by the server and searches the original page link from the page data to be displayed according to field information corresponding to the target control.
Specifically, the field information of the target control may be stored in advance in the proxy service, where the field information is used to obtain code data corresponding to the target control from the page data to be displayed. Thus, after the proxy service obtains the page data to be displayed, the code data corresponding to the target control can be found from the page data to be displayed according to the field information. Thereafter, the original page links for the target control may be obtained from the code data.
For example, the field information corresponding to the target control is a "link" field, and the found code data of the "link" field is as follows:
link :https://www.bilibili.com/blackboard/dynamic/12452。
In step S51, the proxy service modifies the original page link into the skip page link, and uses the modified page data to be displayed as the simulated page data.
Specifically, the jump page link is a URL (Uniform Resource Locator ) of a specified page, the URL being a uniform and unique address that locates the resource on the network. The jump page is accessible through the jump page link.
Step S24, the mobile terminal equipment acquires the jump page link according to the test instruction, and jumps to the jump page according to the jump page link.
Specifically, the test instruction is an instruction for operating a user interface in an application to be tested in the mobile terminal device.
In this embodiment, after receiving the test instruction, the mobile terminal device may load the simulated page first, and after completing loading of the simulated page, the simulated user clicks the target control in the simulated page, so that after clicking the target control, the mobile terminal device may request, from the server, page data of the skipped page according to the URL address (skipped page link) of the skipped page bound with the target control, and after obtaining the page data, render the page according to the page data, thereby displaying the skipped page, and implementing the skip from the simulated page to the skipped page.
According to the automatic testing method of the user interface, in the automatic testing process of the user interface, the mobile terminal equipment loads the simulated page according to the testing instruction, and page display is not needed according to page data returned by the server. Because the jump page bound by the target control in the simulated page is a stable page, when the target control is clicked, a stable jump page can be displayed, the follow-up test case execution failure caused by unstable elements in the jump page is avoided, and the test efficiency is improved.
In an exemplary embodiment, the test instruction further includes parameter information of the proxy service, and before the step of sending, by the mobile terminal device, a network request to a preset server according to the test instruction to access the page to be displayed, the method further includes:
and the mobile terminal equipment is connected with the proxy service according to the parameter information.
Specifically, the parameter information may include port information, address information, etc. of the proxy service.
In this embodiment, before loading the analog page, the mobile terminal device first establishes a connection with the proxy service according to the parameter information, so that after receiving a network request sent by the mobile terminal, the network request can be intercepted.
In an exemplary embodiment, referring to fig. 6, the mobile terminal device obtaining the jump page link according to the test instruction, and jumping to the jump page according to the jump page link includes: step S60, the mobile terminal equipment identifies the target control from the simulation page according to the test instruction; step S61, the mobile terminal equipment clicks the target control according to the test instruction; step S62, the mobile terminal device constructs a route jump request according to clicking operation on the target control; step S63, the mobile terminal device jumps to the jump page according to the route jump request.
In this embodiment, after receiving the test instruction, the mobile terminal device may implement an automatic test operation on the user interface according to the test instruction. Specifically, the mobile terminal device loads a preset simulated page, and clicks a target control in the simulated page after the simulated page is loaded, so that the current simulated page is jumped to a jumped page.
The route jump refers to a process of directional forwarding according to the address of the data packet. In APP, the process of jumping to the corresponding page according to the URL included in the page is specifically referred to.
In this embodiment, the target control is associated with a link, for example, the target control is associated with the following link: "https:// www.bilibili.com/blackboard/dynamic/133628". After clicking the target control, an APP (application program) installed in the mobile terminal device analyzes the content of a link associated with the target control, constructs a route jump request RouteRequest by combining url corresponding to the link and necessary parameters, and jumps to a page designated by the url through router.
In this embodiment, a route jump request is constructed according to a link in a target control after mock, and jumps to the jump page, and because the jump page is a fixed page, elements in the page will not or rarely change, so that in the process of performing an automated test, further test operations can be performed, thereby reducing the influence of element changes on the stability of the automated test.
In an exemplary embodiment, referring to fig. 7, the mobile terminal device identifying the target control from the simulated page according to the test instruction includes: step S70, the mobile terminal equipment performs screenshot operation on the simulated page to obtain a screenshot image; step S71, the mobile terminal device adopts a preset image recognition algorithm to recognize the target control from the screenshot image.
Specifically, the image recognition algorithm may be a conventional image recognition method, for example, an image recognition method based on a template matching model. In another embodiment, the image recognition technology based on the deep learning technology may be used, which is not limited in this embodiment.
Referring to FIG. 8, a block diagram of an embodiment of an automated testing system 80 for a user interface in accordance with the present application is shown.
In this embodiment, the automated testing system 80 of the user interface includes a server device 81 and a mobile device 82, where:
The server device 81 is configured to obtain a preset test case, where the test case is used to test a function of jumping to a preset jump page after clicking a target control;
the server device 81 is further configured to execute an automation test script corresponding to the test case through a preset user interface automation test tool, so as to send a test instruction for the target control to the mobile terminal device;
The mobile terminal device 82 is configured to send a network request to a preset server according to the test instruction, so as to access a page to be displayed, where the page to be displayed includes the target control;
The mobile terminal device 82 is further configured to receive simulated page data returned by a preset proxy service based on the intercepted network request, and perform page rendering according to the simulated page data to obtain a simulated page, where the proxy service intercepts page data to be displayed returned by the server, modifies an original page link corresponding to the target control included in the page data to be displayed into a preset skip page link, and generates the simulated page data;
the mobile terminal device 82 is further configured to obtain the jump page link according to the test instruction, and jump to the jump page according to the jump page link.
In an exemplary embodiment, the proxy service intercepts page data to be displayed returned by the server, modifies an original page link corresponding to the target control included in the page data to be displayed into a preset skip page link, and generating the simulated page data includes:
The proxy service intercepts page data to be displayed returned by the server, and searches the original page link from the page data to be displayed according to field information corresponding to the target control;
The proxy service modifies the original page link into the jump page link, and takes the modified page data to be displayed as the simulated page data.
In an exemplary embodiment, the test instruction includes parameter information of the proxy service, and the mobile terminal device 82 is further configured to connect to the proxy service according to the parameter information.
In an exemplary embodiment, the mobile terminal device 82 is further configured to identify the target control from the simulated page according to the test instruction; clicking the target control according to the test instruction; constructing a route jump request according to clicking operation on the target control; and jumping to the jumping page according to the route jumping request.
In an exemplary embodiment, the mobile terminal device 82 is further configured to perform a screenshot operation on the simulated page to obtain a screenshot image; and identifying the target control from the screenshot image by adopting a preset image identification algorithm.
In an exemplary embodiment, the automated test tool is Appium, and the server device 81 is further configured to initiate the Appium; the automated test script is converted to the test instructions by the Appium and the test instructions are issued to the mobile-end device 82.
In an exemplary embodiment, the server device 81 is further configured to sequentially obtain test cases from a test case file of an application to be tested; judging whether the currently acquired test case is the preset test case or not; if the test case currently acquired by the server device is not the preset test case, continuing to acquire the test case from the test case file until the preset test case is acquired.
According to the automatic testing method of the user interface, in the automatic testing process of the user interface, the mobile terminal equipment loads the simulated page according to the testing instruction, and page display is not needed according to page data returned by the server. Because the jump page bound by the target control in the simulated page is a stable page, when the target control is clicked, a stable jump page can be displayed, the follow-up test case execution failure caused by unstable elements in the jump page is avoided, and the test efficiency is improved.
Fig. 9 schematically shows a hardware architecture diagram of a computer device 9 adapted to implement an automated test method of a user interface according to an embodiment of the application. In the present embodiment, the computer device 9 is a device capable of automatically performing numerical calculation and/or information processing in accordance with instructions set or stored in advance. For example, the server may be a tablet computer, a notebook computer, a desktop computer, a rack-mounted server, a blade server, a tower server, or a rack server (including a stand-alone server or a server cluster formed by a plurality of servers), etc. As shown in fig. 9, the computer device 9 includes at least, but is not limited to: memory 120, processor 121, and network interface 122 may be communicatively linked to each other by a system bus. Wherein:
Memory 120 includes at least one type of computer-readable storage medium that may be volatile or nonvolatile, and specifically, readable storage media include flash memory, hard disk, multimedia card, card memory (e.g., SD or DX memory, etc.), random Access Memory (RAM), static Random Access Memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 120 may be an internal storage module of the computer device 9, such as a hard disk or memory of the computer device 9. In other embodiments, the memory 120 may also be an external storage device of the computer device 9, such as a plug-in hard disk, a smart memory card (SMART MEDIA CARD, abbreviated as SMC), a Secure Digital (SD) card, a flash memory card (FLASH CARD) or the like, which are provided on the computer device 9. Of course, the memory 120 may also include both internal memory modules of the computer device 9 and external memory devices. In this embodiment, the memory 120 is typically used to store an operating system installed on the computer device 9 and various types of application software, such as program codes of an automated test method of a user interface, and the like. In addition, the memory 120 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 121 may be, in some embodiments, an automated test chip of a central processing unit (Central Processing Unit, abbreviated as CPU), controller, microcontroller, microprocessor, or other user interface. The processor 121 is typically used to control the overall operation of the computer device 9, such as performing control and processing related to data interaction or communication with the computer device 9, and the like. In this embodiment, the processor 121 is configured to execute program codes or process data stored in the memory 120.
The network interface 122 may comprise a wireless network interface or a wired network interface, which network interface 122 is typically used to establish a communication link between the computer device 9 and other computer devices. For example, the network interface 122 is used to connect the computer device 9 to an external terminal through a network, establish a data transmission channel and a communication link between the computer device 9 and the external terminal, and the like. The network may be a wireless or wired network such as an Intranet (Intranet), the Internet (Internet), a global system for mobile communications (Global System of Mobile communication, abbreviated as GSM), wideband code division multiple access (Wideband Code Division Multiple Access, abbreviated as WCDMA), a 4G network, a 5G network, bluetooth (Bluetooth), wi-Fi, etc.
It should be noted that fig. 9 only shows a computer device having components 120-122, but it should be understood that not all of the illustrated components are required to be implemented, and more or fewer 9 may alternatively be implemented.
In this embodiment, the automated testing method of the user interface stored in the memory 120 may be divided into one or more program modules and executed by one or more processors (the processor 121 in this embodiment) to complete the present application.
Embodiments of the present application provide a computer readable storage medium having a computer program stored thereon, which when executed by a processor, implements the steps of the automated testing method of a user interface in embodiments.
In this embodiment, the computer-readable storage medium includes a flash memory, a hard disk, a multimedia card, a card memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the computer readable storage medium may be an internal storage unit of a computer device, such as a hard disk or a memory of the computer device. In other embodiments, the computer readable storage medium may also be an external storage device of a computer device, such as a plug-in hard disk, a smart memory card (SMART MEDIA CARD, abbreviated as SMC), a Secure Digital (abbreviated as SD) card, a flash memory card (FLASH CARD), or the like, which are provided on the computer device. Of course, the computer-readable storage medium may also include both internal storage units of a computer device and external storage devices. In this embodiment, the computer readable storage medium is typically used to store an operating system installed on a computer device and various types of application software, such as program code for an automated test method for a user interface in an embodiment, and the like. Furthermore, the computer-readable storage medium may also be used to temporarily store various types of data that have been output or are to be output.
The apparatus embodiments described above are merely illustrative, wherein elements illustrated as separate elements may or may not be physically separate, and elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over at least two network elements. Some or all modules in the system can be screened out according to actual needs to realize the purpose of the scheme of the embodiment of the application. Those of ordinary skill in the art will understand and implement the present application without undue burden.
From the above description of embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus a general purpose hardware platform, or may be implemented by hardware. Those skilled in the art will appreciate that all or part of the processes implementing the methods of the above embodiments may be implemented by a computer program for instructing relevant hardware, where the program may be stored in a computer readable storage medium, and where the program may include processes implementing the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-only memory (ROM), a random access memory (RandomAccessMemory, RAM), or the like.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application 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 scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the application.
Claims (10)
1. An automatic testing method of a user interface, applied to a user interface testing system comprising a server device and a mobile terminal device, is characterized by comprising the following steps:
the method comprises the steps that a server device obtains a preset test case, wherein the preset test case is used for testing a function of jumping to a preset jumping page after clicking a target control;
The server-side equipment executes an automatic test script corresponding to the preset test case through a preset user interface automatic test tool so as to send a test instruction aiming at the target control to the mobile-side equipment;
The mobile terminal equipment sends a network request to a preset server according to the test instruction so as to access a page to be displayed, wherein the page to be displayed comprises the target control;
The mobile terminal equipment receives simulated page data returned by a preset proxy service based on the intercepted network request, and performs page rendering according to the simulated page data to obtain a simulated page, wherein the proxy service intercepts the page data to be displayed returned by the server, modifies an original page link corresponding to the target control contained in the page data to be displayed into a preset jump page link, and generates the simulated page data;
and the mobile terminal equipment acquires the jump page link according to the test instruction and jumps to the jump page according to the jump page link.
2. The method for automatically testing a user interface according to claim 1, wherein the proxy service intercepts page data to be displayed returned by the server and modifies an original page link corresponding to the target control included in the page data to be displayed into a preset skip page link, and generating the simulated page data includes:
The proxy service intercepts page data to be displayed returned by the server, and searches the original page link from the page data to be displayed according to field information corresponding to the target control;
The proxy service modifies the original page link into the jump page link, and takes the modified page data to be displayed as the simulated page data.
3. The automated testing method of a user interface according to claim 2, wherein the testing instruction further includes parameter information of the proxy service, and the mobile terminal device sends a network request to a preset server according to the testing instruction, so as to access the page to be displayed, before the step of accessing the page to be displayed, further includes:
and the mobile terminal equipment is connected with the proxy service according to the parameter information.
4. The automated testing method of a user interface according to claim 1, wherein the mobile terminal device obtaining the jump page link according to the test instruction, and jumping to the jump page according to the jump page link comprises:
the mobile terminal equipment identifies the target control from the simulation page according to the test instruction;
the mobile terminal equipment clicks the target control according to the test instruction;
the mobile terminal device constructs a route jump request according to clicking operation on the target control;
and the mobile terminal equipment jumps to the jump page according to the route jump request.
5. The automated testing method of a user interface of claim 4, wherein the mobile end device identifying the target control from the simulated page according to the test instruction comprises:
the mobile terminal equipment performs screenshot operation on the simulated page to obtain a screenshot image;
And the mobile terminal equipment adopts a preset image recognition algorithm to recognize the target control from the screenshot image.
6. The automated testing method of a user interface according to claim 5, wherein the automated testing tool is Appium, the server device executing, by using a preset user interface automated testing tool, an automated testing script corresponding to the preset test case, so as to send a testing instruction for the target control to the mobile terminal device, and the method comprises:
The server device starts Appium;
The server-side equipment converts the automatic test script into the test instruction through Appium and sends the test instruction to the mobile-side equipment.
7. The method for automatically testing a user interface according to any one of claims 1 to 6, wherein the server device obtaining a preset test case includes:
The server equipment sequentially acquires test cases from a test case file of an application to be tested;
the server equipment judges whether the currently acquired test case is the preset test case or not;
If the test case currently acquired by the server device is not the preset test case, the server device continues to acquire the test case from the test case file until the preset test case is acquired.
8. An automated testing system for a user interface, comprising a server device and a mobile device, wherein:
the server device is used for acquiring a preset test case, and the preset test case is used for testing the function of jumping to a preset jump page after clicking the target control;
the server device is further configured to execute an automation test script corresponding to the preset test case through a preset user interface automation test tool, so as to send a test instruction for the target control to the mobile terminal device;
The mobile terminal equipment is used for sending a network request to a preset server according to the test instruction so as to access a page to be displayed, wherein the page to be displayed comprises the target control;
The mobile terminal device is further configured to receive simulated page data returned by a preset proxy service based on the intercepted network request, and perform page rendering according to the simulated page data to obtain a simulated page, where the proxy service intercepts page data to be displayed returned by the server, modifies an original page link corresponding to the target control included in the page data to be displayed into a preset skip page link, and generates the simulated page data;
The mobile terminal device is further configured to obtain the jump page link according to the test instruction, and jump to the jump page according to the jump page link.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the method of any one of claims 1 to 7 when the computer program is executed.
10. A computer-readable storage medium having stored thereon a computer program, characterized by: the computer program implementing the steps of the method of any of claims 1 to 7 when executed by a processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111003625.XA CN113704110B (en) | 2021-08-30 | 2021-08-30 | Automatic testing method and device for user interface |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111003625.XA CN113704110B (en) | 2021-08-30 | 2021-08-30 | Automatic testing method and device for user interface |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113704110A CN113704110A (en) | 2021-11-26 |
CN113704110B true CN113704110B (en) | 2024-09-06 |
Family
ID=78656758
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111003625.XA Active CN113704110B (en) | 2021-08-30 | 2021-08-30 | Automatic testing method and device for user interface |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113704110B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114489448B (en) * | 2021-12-17 | 2024-03-19 | 北京达佳互联信息技术有限公司 | Page test display method, device, equipment and storage medium |
CN115567564B (en) * | 2022-12-06 | 2023-09-08 | 东方空间(西安)宇航技术有限公司 | Method, device, system and equipment for testing aerospace equipment |
CN117762305B (en) * | 2023-11-07 | 2024-08-16 | 上海艾门韦思网络科技有限公司 | Page interaction method and device based on intelligent drawing, electronic equipment and medium |
CN117310458B (en) * | 2023-11-29 | 2024-01-30 | 北京飘石科技有限公司 | Final testing method and device for FPGA chip |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106790593A (en) * | 2016-12-28 | 2017-05-31 | 北京奇虎科技有限公司 | A kind of page processing method and device |
CN107133180A (en) * | 2017-06-07 | 2017-09-05 | 腾讯科技(深圳)有限公司 | Method of testing, test device and the storage medium of dynamic page |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20060064399A1 (en) * | 2004-09-21 | 2006-03-23 | Giuseppe De Sio | Method and system for testing distributed software applications |
US9262311B1 (en) * | 2013-12-03 | 2016-02-16 | Amazon Technologies, Inc. | Network page test system and methods |
CN108255701B (en) * | 2017-06-27 | 2022-07-22 | 平安普惠企业管理有限公司 | Scene testing method and mobile terminal |
CN108170611B (en) * | 2018-01-23 | 2019-07-16 | 网易(杭州)网络有限公司 | Automated testing method and device, storage medium, electronic equipment |
CN113050923B (en) * | 2021-04-21 | 2024-06-14 | 中国工商银行股份有限公司 | Front-end interface data simulation method, device and system |
-
2021
- 2021-08-30 CN CN202111003625.XA patent/CN113704110B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106790593A (en) * | 2016-12-28 | 2017-05-31 | 北京奇虎科技有限公司 | A kind of page processing method and device |
CN107133180A (en) * | 2017-06-07 | 2017-09-05 | 腾讯科技(深圳)有限公司 | Method of testing, test device and the storage medium of dynamic page |
Also Published As
Publication number | Publication date |
---|---|
CN113704110A (en) | 2021-11-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113704110B (en) | Automatic testing method and device for user interface | |
US11074087B2 (en) | System and method for identifying, indexing, and navigating to deep states of mobile applications | |
CN108293081B (en) | Deep linking of program playback to mobile application state through user interface events | |
CN111061526B (en) | Automatic test method, device, computer equipment and storage medium | |
CN109901834B (en) | Document page generation method, device, computer equipment and storage medium | |
US20140380281A1 (en) | Automated software testing | |
CN110955409B (en) | Method and device for creating resources on cloud platform | |
CN110196809B (en) | Interface testing method and device | |
US9026997B2 (en) | Systems and methods for executing object-oriented programming code invoking pre-existing objects | |
CN111930629A (en) | Page testing method and device, electronic equipment and storage medium | |
CN112068879A (en) | Method and device for constructing client application development framework based on configuration | |
CN112416384A (en) | Software upgrading method and device and computer equipment | |
US8615751B2 (en) | Seeding product information | |
CN110717992A (en) | Method, device, computer system and readable storage medium for scheduling model | |
CN114063958B (en) | Page split screen display method and device | |
CN115048082A (en) | Micro front-end system construction method and device, server and readable storage medium | |
CN114741294A (en) | Page debugging method, device, equipment and storage medium | |
CN111752559B (en) | Front-end and back-end separation system, method, device and storage medium | |
CN109814839B (en) | Internationalization information generation method, internationalization information generation device and computer readable storage medium | |
WO2012174033A1 (en) | System and method to in-line script dependencies | |
CN110196803B (en) | Software defect training method and system | |
CN110704483A (en) | User routing process positioning method, device, storage medium and device | |
CN110618934A (en) | Front-end automatic test debugging method and device and computer readable storage medium | |
CN113608996B (en) | Mirror image compiling test method, system, device and readable storage medium | |
CN112765040B (en) | Page test method, system, computer 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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |