Automated testing method and device for user interface
By using the proxy service on the mobile device to modify the page link of the target control and generate simulated page data, the problem of inaccurate recognition of control elements in the interface test in the existing technology is solved, and the stability and efficiency of the test are improved.
Patent Information
- Application Number
- CN202111003625.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-30
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-08-30
AI Technical Summary
When testing the human-computer interaction interface of a mobile device application, the existing technology cannot accurately identify control elements, causing the test case to fail.
By obtaining the preset test cases on the server side, using the user interface automated testing tool to execute the test script on the mobile device, using the proxy service to intercept network requests, modify the page link of the target control, and generate simulated page data, so that the mobile device can Stable jump to default page.
It avoids the instability of page elements caused by changes in data returned by the server, improves the accuracy and efficiency of testing, and ensures that test cases can be executed successfully.
Smart Images

Figure CN113704110B
Abstract
Description
Technical Field
[0001] The present application relates to the field of testing technology, and in particular to an automated testing method and device for a user interface. Background Art
[0002] After developers develop a human-computer interaction interface (UI) of an application (Application, App) for a mobile device, they usually need to test the UI to see if the UI can implement the preset functions.
[0003] In the prior art, when using a test case to test an operation that includes jumping to a corresponding page after clicking a control, since the data returned by the server often changes, when the prior art tests this function, the page jumped to will be different from the corresponding page in the test case due to the change in data, thereby causing the test case to fail. Summary of the invention
[0004] In view of this, a method, apparatus, computer device and computer-readable storage medium for automated testing of a user interface are now provided to solve the problem in the prior art that control elements of a UI cannot be accurately identified when testing the UI of an App.
[0005] The present application provides an automated testing method for a user interface, comprising:
[0006] The server device obtains 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;
[0007] The server device executes the 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;
[0008] The mobile terminal device sends a network request to a preset server according to the test instruction to access a page to be displayed, wherein the page to be displayed includes the target control;
[0009] The mobile terminal device receives the simulated page data returned by the 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 to-be-displayed page data returned by the server and modifies the original page link corresponding to the target control contained in the to-be-displayed page data into a preset jump page link, thereby generating the simulated page data;
[0010] 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.
[0011] Optionally, the proxy service intercepts the to-be-displayed page data returned by the server and modifies the original page link corresponding to the target control contained in the to-be-displayed page data into a preset jump page link, and generating the simulated page data includes:
[0012] The proxy service intercepts the to-be-displayed page data returned by the server, and searches for the original page link from the to-be-displayed page data according to the field information corresponding to the target control;
[0013] The proxy service modifies the original page link into the jump page link, and uses the modified page data to be displayed as the simulated page data.
[0014] Optionally, the test instruction further includes parameter information of the proxy service, and before the mobile terminal device sends a network request to a preset server according to the test instruction to access the page to be displayed, the method further includes:
[0015] The mobile terminal device connects to the proxy service according to the parameter information.
[0016] 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, including:
[0017] The mobile terminal device identifies the target control from the simulation page according to the test instruction;
[0018] The mobile terminal device clicks the target control according to the test instruction;
[0019] The mobile terminal device constructs a routing jump request according to a click operation on the target control;
[0020] The mobile terminal device jumps to the jump page according to the route jump request.
[0021] Optionally, the mobile terminal device identifying the target control from the simulation page according to the test instruction includes:
[0022] The mobile terminal device performs a screenshot operation on the simulated page to obtain a screenshot image;
[0023] The mobile terminal device uses a preset image recognition algorithm to identify the target control from the screenshot image.
[0024] Optionally, the automated testing tool is Appium, and the server device executes the automated testing script corresponding to the test case through a preset user interface automated testing tool to send the test instruction for the target control to the mobile device, including:
[0025] The server device starts the Appium;
[0026] The server-side device converts the automated test script into the test instruction through the Appium, and sends the test instruction to the mobile-side device.
[0027] Optionally, the server device obtains a preset test case including:
[0028] The server device sequentially obtains test cases from the test case file of the application to be tested;
[0029] The server device determines whether the currently acquired test case is the preset test case;
[0030] If the test case currently acquired by the server device is not the preset test case, the server device continues to acquire test cases from the test case file until the preset test case is acquired.
[0031] The present application also provides an automated testing system for a user interface, including a server device and a mobile device, wherein:
[0032] The server device is used to obtain a preset test case, and the test case is used to test the function of jumping to a preset jump page after clicking the target control;
[0033] The server device is further used to execute the automated test script corresponding to the test case through a preset user interface automated test tool to send the test instruction for the target control to the mobile device;
[0034] The mobile terminal device is used for sending a network request to a preset server according to the test instruction to access a page to be displayed, wherein the page to be displayed includes the target control;
[0035] The mobile terminal device is further used to receive the simulated page data returned by the preset proxy service based on the intercepted network request, and to render the page according to the simulated page data to obtain a simulated page, wherein the proxy service intercepts the to-be-displayed page data returned by the server and modifies the original page link corresponding to the target control contained in the to-be-displayed page data into a preset jump page link, thereby generating the simulated page data;
[0036] The mobile terminal device is further used to obtain the jump page link according to the test instruction, and jump to the jump page according to the jump page link.
[0037] The present application also provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0038] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented.
[0039] The user interface automated testing method of this embodiment loads a simulation page according to a test instruction through a mobile terminal device during the user interface automated testing process, without displaying the page according to the page data returned by the server. Since the jump page bound to the target control in the simulation page is a stable page, a stable jump page can be displayed when the target control is clicked, thereby avoiding the failure of subsequent test cases caused by unstable elements in the jump page and improving the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A schematic diagram of an environment for an automated testing method for a user interface according to an embodiment of the present application;
[0041] Figure 2 A flowchart of an embodiment of the method for automated testing of a user interface described in the present application;
[0042] Figure 3 A schematic diagram of a detailed flow chart of the steps for a server device to obtain a preset test case in one embodiment of the present application;
[0043] Figure 4 A schematic diagram of a detailed process of a server device executing an automated test script corresponding to the test case through a preset user interface automated test tool in one embodiment of the present application to send a test instruction for the target control to a mobile device;
[0044] Figure 5 A schematic diagram of a detailed process of generating the simulated page data by intercepting the page data to be displayed returned by the server and modifying the original page link corresponding to the target control contained in the page data to be displayed into a preset jump page link in an embodiment of the present application;
[0045] Figure 6A schematic diagram of a detailed flow chart of the steps of a mobile terminal device loading a preset simulation page according to the test instruction and jumping to the jump page after completing the loading of the simulation page in one embodiment of the present application;
[0046] Figure 7 A schematic diagram of a detailed flow chart of the steps of identifying the target control from the simulation page according to the test instruction by the mobile terminal device in an embodiment of the present application;
[0047] Figure 8 An architectural diagram of an embodiment of an automated testing system for a user interface described in the present application;
[0048] Fig. 9 A schematic diagram of the hardware structure of a computer device for executing an automated testing method for a user interface provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] The advantages of the present application are further described below in conjunction with the accompanying drawings and specific embodiments.
[0050] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0051] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0052] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0053] In the description of the present application, it should be understood that the numerical labels before the steps do not indicate the order in which the steps are executed, but are only used to facilitate the description of the present application and to distinguish each step, and therefore should not be understood as a limitation on the present application.
[0054] Figure 1 The schematic diagram of the application environment of the automated testing method for the user interface according to the embodiment of the present application is schematically shown. In an exemplary embodiment, the system of the application environment may include a mobile device 10 and a server device 20. Among them, the mobile device 10 forms a wireless or wired connection with the server device 20. The mobile device 10 can be an Android phone, iPAD, tablet computer, etc., or a mobile phone, iPAD, tablet computer, etc. of the IOS system. The server device 20 can be a computer, a server cluster or a cloud computing center composed of one or more servers, etc., which is not limited here. It should be noted that the automated testing method for the user interface in this embodiment can be applied to automated testing.
[0055] Among them, automated testing of the user interface (UI) refers to an automated testing method that simulates manual user operation of the user interface in a code manner, and realizes automatic operation and verification of whether the functional layout of the user interface is reasonable, whether the overall style is consistent, whether the placement of each control conforms to customer usage habits, whether the operation is convenient, whether the navigation is simple and easy to understand, whether the text in the interface is correct, whether the naming is unified, whether the page is beautiful, whether the combination of text and pictures is perfect, etc.
[0056] See also Figure 2 , which is a flowchart of an automated testing method for a user interface in an embodiment of the present application. The automated testing method in the present application is applied to a user interface testing system including a server device and a mobile device. It can be understood that the flowchart in the embodiment of the present method is not used to limit the order of executing the steps. As can be seen from the figure, the automated testing method for a user interface provided in the present embodiment includes:
[0057] Step S20: The server device obtains 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.
[0058] Specifically, a test case is a description of a test task for a specific software product, reflecting the test plan, method, technology and strategy. Its content includes test objectives, test environment, input data, test steps, expected results, test scripts, etc., and finally forms a document. Simply put, a test case is a set of test inputs, execution conditions and expected results compiled for a special goal, used to verify whether a specific software requirement is met.
[0059] Among them, the preset test case is a test case specified by the user, and the preset test case is used to test the interactive function of realizing page jump after clicking the target control in the test application. In this embodiment, in order to distinguish between general test cases and the preset test cases, the preset test cases can be marked with preset marks. For example, the mark "1" can be used to represent the preset test case, and the mark "0" can be used to represent the general test case.
[0060] In this embodiment, the preset test case includes at least one test step, and each test step can be described by a test operation and a target control for the test operation. Exemplarily, it is assumed that there is a preset test case as described below, which is used to test the page B jump function of application A, and the test case includes the following information:
[0061] Test case identification: Application A_01;
[0062] Test function: Test the page jump function of page A;
[0063] Test steps: 1. Slide and refresh the page to request page B from the server; 2. Click the target control C in page B.
[0064] The test results corresponding to the test steps are: 1. Display page B; 2. Display jump page D.
[0065] In this test case, “2. Click target control C in page B” is described by the test operations “click” and “target control C”.
[0066] It should be noted that each test step is pre-configured with a corresponding test result, which is used to describe the user interface expected to be displayed after the corresponding test operation is performed. In this embodiment, the test result includes information about the simulation page and information about the jump page.
[0067] It should be noted that the server device in this embodiment is a device installed with a user interface automation testing tool.
[0068] In an exemplary embodiment, referring to Figure 3 , the server device obtains the preset test case including:
[0069] Step S31: the server device sequentially obtains test cases from the test case files of the application to be tested.
[0070] Specifically, the application to be tested is an application that needs to be tested for user interface automation testing. In actual applications, the tester can write multiple test cases for the application to be tested, and save the multiple test cases in a test case file, and then associate the written test case file with the application identifier of the application to be tested and store it in a pre-built test case library. In this way, when performing UI automation testing on the application to be tested, the server-side device can first obtain the test case file from the test case library according to the application identifier of the application to be tested, and then obtain the test cases from the test case file in sequence.
[0071] In step S31, the server device determines whether the currently acquired test case is the preset test case.
[0072] Specifically, preset identification information may be configured in advance for the preset test case, and the preset identification information may be used to distinguish whether the currently acquired test case is the preset test case.
[0073] Step S32: If the test case currently acquired by the server device is not the preset test case, the server device continues to acquire test cases from the test case file until the preset test case is acquired.
[0074] Specifically, when the server-side device determines that the test case currently acquired does not contain the preset identification information, it can be determined that the current test case is not the preset test case, and the test case can continue to be acquired from the test case file until the preset test case is acquired; when the server-side device determines that the test case currently acquired contains the preset identification information, it can be determined that the current test case is the preset test case.
[0075] In step S21, the server device executes the 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.
[0076] Specifically, the user interface automation testing tool is a tool for implementing user interface automation testing. The user interface automation testing tool may be UIAutomation, Appium, etc., which is not limited in this embodiment.
[0077] Among them, UIAutomation is the UI automation framework provided by Microsoft. Of course, its original intention is not just for automated testing. Its task is to allow more developers or applications to call Windows UI controls, but it can still be used for automated testing; because Microsoft had similar tools before, and this is a redesigned UI operation framework, its purpose is to be compatible with UI automation operations that support Windows series operating systems [XP, Vista, Server 2003], and it also naturally supports WPF. Of course, its design is different from the usual automation tools. For example: it does not bind the methods supported by the control to the control object itself, and does not provide special mouse / keyboard events, but it does provide event response monitoring and customization of processing methods for specific control objects. Its workflow is roughly like this:
[0078] a. First get the specific element object. There are many ways, such as handle, attribute value, etc.
[0079] b. Get the mode of this element object.
[0080] c. Use this pattern to make specific method calls, obtain attribute values, etc.
[0081] d. Listen to specific events of the specified object and execute the specified event handling function once it occurs.
[0082] Among them, Appium is an open source tool for mobile automation testing, supporting iOS and Android platforms, and languages such as Python and Java. That is, the same set of Java or Python scripts can run on both iOS and Android platforms. Appium is a C / S architecture, with a core web server that provides a set of REST interfaces. When receiving a connection from a client, it listens for commands, executes them on the mobile device, and returns the execution results to the client in an HTTP response.
[0083] In this embodiment, after writing the test case, the tester can write an automated test script for automatically executing the test case according to the test case, so that the automated test script can be used to implement automated testing of the user interface.
[0084] It should be noted that the automated test in this embodiment refers to a testing method in which an automated test script is written to automatically run a system or application under preset conditions and evaluate the running results.
[0085] In this embodiment, after executing the automated test script, the automated test tool converts the automated test script into test instructions that can be recognized by the mobile terminal device.
[0086] It should be noted that the mobile terminal device in this embodiment is an Android phone, iPAD, tablet computer, etc., or an IOS phone, iPAD, tablet computer, etc., which is to be tested on the user interface.
[0087] It is understandable that the automated testing tool needs to establish a connection with the mobile device before sending the test instruction to the mobile device. In this embodiment, in order to establish a connection with the mobile device, the test instruction needs to include the device information of the mobile device so that the automated testing tool can find the mobile device according to the device information and establish a connection with the mobile device.
[0088] In an exemplary embodiment, referring to Figure 4 , the automated testing tool is Appium, and the server-side device executes the automated testing script corresponding to the test case through a preset user interface automated testing tool to send the test instruction for the target control to the mobile-side device, including: step S40, the server-side device starts the Appium; step S41, the server-side device converts the automated testing script into the test instruction through the Appium, and sends the test instruction to the mobile-side device.
[0089] Specifically, Appium is installed on the server device. When automated testing of the user interface is required, the user can trigger a start instruction. After receiving the start instruction, the server can start Appium. Thereafter, Appium can convert the automated test script into the test instruction and send the test instruction to the mobile device.
[0090] Step S22: the mobile terminal device sends a network request to a preset server according to the test instruction to access the page to be displayed, wherein the page to be displayed includes the target control.
[0091] Specifically, the server provides services for the application to be tested, such as providing resources, saving data, etc. After receiving the test instruction from the server device, the mobile terminal device first sends a network request to the server so that the page data of the page to be displayed can be obtained through the network request.
[0092] It should be noted that the page to be displayed is a page in the application to be tested that contains the target control.
[0093] In step S23, the mobile terminal device receives the simulated page data returned by the preset proxy service based on the intercepted network request, and renders the page 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 and modifies the original page link corresponding to the target control contained in the page data to be displayed to a preset jump page link to generate the simulated page data.
[0094] Specifically, when the mobile terminal device sends a network request to obtain the page data to be displayed, the proxy service will intercept the network request so that the page data to be displayed obtained by the network request can be modified into simulated page data. Specifically, after intercepting the network request, the proxy service will forward the network request to the corresponding server. After the server returns response data (page data to be displayed) based on the network request, the proxy service will continue to intercept the response data, but will not return the response data to the mobile terminal device. Instead, it will modify the original page link corresponding to the target control contained in the page data to be displayed to a preset jump page link, thereby obtaining simulated page data, and then return the simulated page data to the mobile terminal device to use the simulated page data as the response data of the network request.
[0095] The proxy service is a software running on a computer. When the computer using the proxy service exchanges information with the Internet, the information is first sent to the proxy service, which forwards it and sends the received response back to the computer.
[0096] In this embodiment, the simulation page may also be called a mock page, which is used to replace the page originally returned by the server. The simulation page contains information about the target control.
[0097] As an example, the information of the target control included in the simulation page is as follows:
[0098] "id":87174,
[0099] "1ink": "https: / / www.bi1ibi1i.com / blackboard / dynamic / 133628",
[0100] "pic": "https: / / 10.hdslb.com / bfs / 1ive / 562d8f25d657e22aaf4da2fbe4f74a9f5ec267c7.Jpg",
[0101] "title": "MSI event predictions, participate in the interaction and win prizes".
[0102] In this embodiment, the id field represents the identification information of the target control; the link field represents that the target control has been bound to the jump page with the address link "https: / / www.bilibili.com / blackboard / dynamic / 133628"; the pic field represents the image address information of the target control; and the title field represents the title of the target control.
[0103] In an exemplary embodiment, referring to Figure 5 The proxy service intercepts the to-be-displayed page data returned by the server and modifies the original page link corresponding to the target control contained in the to-be-displayed page data into a preset jump page link, and generates the simulated page data including:
[0104] Step S50: the proxy service intercepts the to-be-displayed page data returned by the server, and searches for the original page link from the to-be-displayed page data according to the field information corresponding to the target control.
[0105] Specifically, the proxy service may pre-store field information of the target control, and the field information is used to obtain code data corresponding to the target control from the page data to be displayed. In this way, 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. Afterwards, the original page link of the target control can be obtained from the code data.
[0106] For example, the field information corresponding to the target control is the "link" field, and the found "link" field code data is as follows:
[0107] link: https: / / www.bilibili.com / blackboard / dynamic / 12452.
[0108] Step S51: the proxy service modifies the original page link into the jump page link, and uses the modified page data to be displayed as the simulated page data.
[0109] Specifically, the jump page link is a URL (Uniform Resource Locator) of a specified page, and a URL is a unified and unique address for locating resources on the network. The jump page can be accessed through the jump page link.
[0110] Step S24: 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.
[0111] Specifically, the test instruction is an instruction for operating a user interface in the application to be tested in the mobile terminal device.
[0112] In this embodiment, after receiving the test instruction, the mobile terminal device can first load the simulation page, and after completing the loading of the simulation page, simulate the user clicking the target control in the simulation page, so that after clicking the target control, the mobile terminal device can request the page data of the jump page from the server according to the URL address of the jump page bound to the target control (jump page link), and after obtaining the page data, render the page according to the page data, thereby displaying the jump page and realizing the jump from the simulation page to the jump page.
[0113] The user interface automated testing method of this embodiment loads a simulation page according to a test instruction through a mobile terminal device during the user interface automated testing process, without displaying the page according to the page data returned by the server. Since the jump page bound to the target control in the simulation page is a stable page, a stable jump page can be displayed when the target control is clicked, thereby avoiding the failure of subsequent test cases caused by unstable elements in the jump page and improving the test efficiency.
[0114] In an exemplary embodiment, the test instruction further includes parameter information of the proxy service, and before the mobile terminal device sends a network request to a preset server according to the test instruction to access the page to be displayed, the step further includes:
[0115] The mobile terminal device connects to the proxy service according to the parameter information.
[0116] Specifically, the parameter information may include port information, address information, etc. of the proxy service.
[0117] In this embodiment, before loading the simulation page, the mobile terminal device will first establish a connection with the proxy service according to the parameter information, so that after receiving the network request sent by the mobile terminal, the network request can be intercepted.
[0118] In an exemplary embodiment, referring to Figure 6 , 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, including: step S60, the mobile terminal device identifies the target control from the simulation page according to the test instruction; step S61, the mobile terminal device clicks the target control according to the test instruction; step S62, the mobile terminal device constructs a routing jump request according to the click operation on the target control; step S63, the mobile terminal device jumps to the jump page according to the routing jump request.
[0119] In this embodiment, after receiving the test instruction, the mobile terminal device can implement the automated test operation on the user interface according to the test instruction. Specifically, the mobile terminal device loads the preset simulation page, and after completing the loading of the simulation page, clicks the target control in the simulation page, thereby jumping the current simulation page to the jump page.
[0120] Routing refers to the process of directional forwarding based on the address of a data packet. In an APP, it specifically refers to the process of jumping to a corresponding page based on the URL contained in the page.
[0121] 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". When the target control is clicked, the APP (application) installed in the mobile device will parse the content of the link associated with the target control, construct a route jump request RouteRequest with the URL corresponding to the link and the necessary parameters, and then jump to the page specified by the URL through Router.routeTo.
[0122] In this embodiment, a routing jump request is constructed according to the link in the target control after mocking, and the jump is to the jump page. Since the jump page is a fixed page, the elements in the page will not or rarely change. Therefore, further testing operations can be performed during the automated testing process to reduce the impact of element changes on the stability of the automated testing.
[0123] In an exemplary embodiment, referring to Figure 7 , the mobile terminal device identifies the target control from the simulation page according to the test instruction, including: step S70, the mobile terminal device takes a screenshot of the simulation page to obtain a screenshot image; step S71, the mobile terminal device uses a preset image recognition algorithm to identify the target control from the screenshot image.
[0124] Specifically, the image recognition algorithm may be a traditional image recognition method, such as an image recognition method based on a template matching model. In another embodiment, an image recognition technology based on deep learning technology may also be used for implementation, which is not limited in this embodiment.
[0125] See also Figure 8 , is an architectural diagram of an embodiment of an automated testing system 80 of a user interface of the present application.
[0126] In this embodiment, the user interface automated testing system 80 includes a server device 81 and a mobile device 82, wherein:
[0127] The server device 81 is used to obtain a preset test case, where the test case is used to test the function of jumping to a preset jump page after clicking a target control;
[0128] The server device 81 is further used to execute the automated test script corresponding to the test case through a preset user interface automated test tool to send the test instruction for the target control to the mobile device;
[0129] The mobile terminal device 82 is used for sending a network request to a preset server according to the test instruction to access the page to be displayed, and the page to be displayed includes the target control;
[0130] The mobile terminal device 82 is further used to receive the simulated page data returned by the preset proxy service based on the intercepted network request, and to render the page according to the simulated page data to obtain a simulated page, wherein the proxy service intercepts the to-be-displayed page data returned by the server and modifies the original page link corresponding to the target control contained in the to-be-displayed page data into a preset jump page link, thereby generating the simulated page data;
[0131] 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.
[0132] In an exemplary implementation, the proxy service intercepts the to-be-displayed page data returned by the server and modifies the original page link corresponding to the target control contained in the to-be-displayed page data into a preset jump page link, and generating the simulated page data includes:
[0133] The proxy service intercepts the to-be-displayed page data returned by the server, and searches for the original page link from the to-be-displayed page data according to the field information corresponding to the target control;
[0134] The proxy service modifies the original page link into the jump page link, and uses the modified page data to be displayed as the simulated page data.
[0135] In an exemplary implementation, 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.
[0136] In an exemplary embodiment, the mobile terminal device 82 is also used to identify the target control from the simulation page according to the test instruction; click the target control according to the test instruction; construct a routing jump request according to the click operation on the target control; and jump to the jump page according to the routing jump request.
[0137] In an exemplary embodiment, the mobile terminal device 82 is further used to perform a screenshot operation on the simulated page to obtain a screenshot image; and to identify the target control from the screenshot image using a preset image recognition algorithm.
[0138] In an exemplary embodiment, the automated testing tool is Appium, and the server device 81 is also used to start the Appium; the automated testing script is converted into the test instruction through the Appium, and the test instruction is sent to the mobile device 82.
[0139] In an exemplary embodiment, the server device 81 is also used to sequentially obtain test cases from the test case file of the application to be tested; determine whether the test case currently obtained is the preset test case; if the test case currently obtained by the server device is not the preset test case, continue to obtain test cases from the test case file until the preset test case is obtained.
[0140] The user interface automated testing method of this embodiment loads a simulation page according to a test instruction through a mobile terminal device during the user interface automated testing process, without displaying the page according to the page data returned by the server. Since the jump page bound to the target control in the simulation page is a stable page, a stable jump page can be displayed when the target control is clicked, thereby avoiding the failure of subsequent test cases caused by unstable elements in the jump page and improving the test efficiency.
[0141] Fig. 9 The hardware architecture diagram of a computer device 9 suitable for implementing an automated test method for a user interface according to an embodiment of the present application is schematically shown. In this embodiment, the computer device 9 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. For example, it can be a tablet computer, a laptop computer, a desktop computer, a rack server, a blade server, a tower server, or a cabinet server (including an independent server, or a server cluster composed of multiple servers), etc. Fig. 9 As shown, the computer device 9 includes at least but is not limited to: a memory 120, a processor 121, and a network interface 122 that can communicate with each other through a system bus. Among them:
[0142] The memory 120 includes at least one type of computer-readable storage medium, which may be volatile or non-volatile. Specifically, the readable storage medium includes flash memory, hard disk, multimedia card, card-type 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 equipped on the computer device 9, a smart memory card (Smart Media Card, referred to as SMC), a secure digital (Secure Digital, referred to as SD) card, a flash card, etc. Of course, the memory 120 may also include both the internal storage module of the computer device 9 and its external storage device. In this embodiment, the memory 120 is usually used to store the operating system and various application software installed on the computer device 9, such as program codes of the automated testing method of the user interface, etc. In addition, the memory 120 can also be used to temporarily store various data that have been output or will be output.
[0143] In some embodiments, the processor 121 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or an automated test chip of other user interfaces. The processor 121 is generally used to control the overall operation of the computer device 9, such as executing control and processing related to data interaction or communication with the computer device 9. In this embodiment, the processor 121 is used to run program codes stored in the memory 120 or process data.
[0144] The network interface 122 may include a wireless network interface or a wired network interface, and the network interface 122 is generally 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, and to establish a data transmission channel and a communication link between the computer device 9 and the external terminal. The network may be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, etc.
[0145] It should be pointed out that Fig. 9 Only a computer device having components 120 to 122 is shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer than nine may be implemented instead.
[0146] In this embodiment, the user interface automated testing method stored in the memory 120 may be divided into one or more program modules and executed by one or more processors (processor 121 in this embodiment) to complete the present application.
[0147] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the automated testing method for the user interface in the embodiment are implemented.
[0148] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, 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, disk, optical disk, etc. In some embodiments, the computer-readable storage medium can be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium can also be an external storage device of a computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, referred to as SMC), a secure digital (Secure Digital, referred to as SD) card, a flash card, etc. Of course, the computer-readable storage medium can also include both the internal storage unit of the computer device and its external storage device. In this embodiment, the computer-readable storage medium is generally used to store an operating system and various application software installed on the computer device, such as the program code of the automated test method of the user interface in the embodiment, etc. In addition, the computer-readable storage medium can also be used to temporarily store various types of data that have been output or are to be output.
[0149] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on at least two network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiment scheme of the present application. Those of ordinary skill in the art may understand and implement it without creative labor.
[0150] Through the description of the above implementation methods, ordinary technicians in this field can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware. Ordinary technicians in this field can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A user interface automated testing method, applied to a user interface testing system including a server device and a mobile device, characterized in that: include: The server device obtains a preset test case, where the preset test case is used to test a function of jumping to a preset jump page after clicking a target control; The server device executes the automated test script corresponding to the preset test case through a preset user interface automated test tool to send a test instruction for the target control to the mobile device; The mobile terminal device sends a network request to a preset server according to the test instruction to access a page to be displayed, wherein the page to be displayed includes the target control; The mobile terminal device receives the simulated page data returned by the 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 to-be-displayed page data returned by the server and modifies the original page link corresponding to the target control contained in the to-be-displayed page data into a preset jump page link, thereby generating the simulated page data; 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.
2. The method for automated testing of a user interface according to claim 1, characterized in that: The proxy service intercepts the to-be-displayed page data returned by the server and modifies the original page link corresponding to the target control contained in the to-be-displayed page data into a preset jump page link, and generating the simulated page data includes: The proxy service intercepts the to-be-displayed page data returned by the server, and searches for the original page link from the to-be-displayed page data according to the field information corresponding to the target control; The proxy service modifies the original page link into the jump page link, and uses the modified page data to be displayed as the simulated page data.
3. The method for automated testing of a user interface according to claim 2, characterized in that: The test instruction also includes parameter information of the proxy service. Before the mobile terminal device sends a network request to a preset server according to the test instruction to access the page to be displayed, the step further includes: The mobile terminal device connects to the proxy service according to the parameter information.
4. The method for automated testing of a user interface according to claim 1, characterized in that: 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, including: The mobile terminal device identifies the target control from the simulation page according to the test instruction; The mobile terminal device clicks the target control according to the test instruction; The mobile terminal device constructs a routing jump request according to a click operation on the target control; The mobile terminal device jumps to the jump page according to the route jump request.
5. The method for automated testing of a user interface according to claim 4, characterized in that: The mobile terminal device identifying the target control from the simulation page according to the test instruction includes: The mobile terminal device performs a screenshot operation on the simulated page to obtain a screenshot image; The mobile terminal device uses a preset image recognition algorithm to identify the target control from the screenshot image.
6. The method for automated testing of a user interface according to claim 5, characterized in that: The automated testing tool is Appium, and the server-side device executes the automated testing script corresponding to the preset test case through the preset user interface automated testing tool to send the test instruction for the target control to the mobile-side device, including: The server device starts the Appium; The server-side device converts the automated test script into the test instruction through the Appium, and sends the test instruction to the mobile-side device.
7. The method for automated testing of a user interface according to any one of claims 1 to 6, characterized in that: The server device obtains the preset test case including: The server device sequentially obtains test cases from the test case file of the application to be tested; The server device determines whether the currently acquired test case is the preset test case; If the test case currently acquired by the server device is not the preset test case, the server device continues to acquire test cases from the test case file until the preset test case is acquired.
8. An automated testing system for a user interface, characterized in that: Including server devices and mobile devices, including: The server device is used to obtain a preset test case, and the preset test case is used to test the function of jumping to a preset jump page after clicking the target control; The server device is further used to execute the automated test script corresponding to the preset test case through a preset user interface automated test tool to send the test instruction for the target control to the mobile device; The mobile terminal device is used for sending a network request to a preset server according to the test instruction to access a page to be displayed, wherein the page to be displayed includes the target control; The mobile terminal device is further used to receive the simulated page data returned by the preset proxy service based on the intercepted network request, and to render the page according to the simulated page data to obtain a simulated page, wherein the proxy service intercepts the to-be-displayed page data returned by the server and modifies the original page link corresponding to the target control contained in the to-be-displayed page data into a preset jump page link, thereby generating the simulated page data; The mobile terminal device is further used 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 in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
