User interface automation testing method and related equipment
By installing Appium on the terminal device and executing the UI automation test script, the slow speed problem caused by the Appium automation test framework's dependence on the PC environment is solved, and faster UI automation testing is achieved.
Patent Information
- Application Number
- CN202010212041.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-24
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2040-03-24
AI Technical Summary
The existing Appium automated testing framework relies on the PC environment, resulting in slow UI automated testing.
Install Appium on the terminal device, execute UI automation test scripts through the script execution unit, directly obtain and execute test cases, and reduce dependence on the PC environment.
Improved the speed of UI automation testing and reduced dependence on PC environment.
Smart Images

Figure CN111538650B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic technology, and in particular to a user interface automated testing method and related equipment. Background Art
[0002] The mainstream Android user interface (UI) automation frameworks currently in the industry include Robotium, UIAutomator, and Appium. All three are used in the field of automated testing and can automate application testing. Robotium is an open-source automated testing framework for Android that integrates with Android's native testing framework to automate application testing. UIAutomator is the official Google-provided UI testing framework included with Android 4.1 and above, which can test not only individual applications but also the entire system. Appium is an open-source test automation framework for testing native, hybrid, and mobile web applications. Appium uses UIAutomator for Android UI automation operations. Built on top of UIAutomator, Appium offers cross-language and cross-platform support (including Java and Python), making it highly popular. Currently, when performing UI automation testing within an Appium-based automation framework, because the Appium Server runs on a PC, both the automated test scripts and the Android device's UI automation operations must be forwarded and fed back through the personal computer (PC). This heavy reliance on the PC environment results in slow UI automation testing. Summary of the Invention
[0003] The embodiments of the present application provide a user interface automation testing method and related equipment for reducing dependence on the PC environment and improving the speed of UI automation testing.
[0004] In a first aspect, an embodiment of the present application provides a user interface automated testing method, applied to a first electronic device, the first electronic device including Appium and a script execution unit, the method comprising:
[0005] The script execution unit executes a user interface UI automated test script to send a first request to the Appium, where the first request is used to request a first automated test result, where the first automated test result is obtained by executing a first test case;
[0006] After receiving the first request, the Appium starts the Appium server;
[0007] The Appium obtains the first test case through the Appium server;
[0008] The Appium executes the first test case through the Appium server to obtain the first automated test result;
[0009] The Appium sends the first automated test result to the script execution unit.
[0010] In a second aspect, an embodiment of the present application provides a user interface automated testing device, applied to a first electronic device, the first electronic device including Appium and a script execution unit, the device including:
[0011] The script execution unit is used to execute a user interface UI automated test script to send a first request to the Appium, wherein the first request is used to request a first automated test result, where the first automated test result is obtained by executing a first test case;
[0012] The Appium is configured to start the Appium server after receiving the first request; obtain the first test case through the Appium server; execute the first test case through the Appium server to obtain the first automated test result; and send the first automated test result to the script execution unit.
[0013] In a third aspect, an embodiment of the present application provides a first electronic device, which includes a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing some or all of the steps described in the method described in the first aspect of the embodiment of the present application.
[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the above-mentioned computer-readable storage medium is used to store a computer program, wherein the above-mentioned computer program is executed by a processor to implement some or all of the steps described in the method described in the first aspect of the embodiment of the present application.
[0015] It can be seen that in an embodiment of the present application, the first electronic device includes Appium and a script execution unit, which executes a UI automation test script to send a first request to the Appium, and the first request is used to request to obtain the automation test result; after receiving the first request, the Appium starts the Appium server; the Appium obtains the first test case through the Appium server; the Appium executes the first test case through the Appium server to obtain a first automation test result; the Appium sends the first automation test result to the script execution unit. Since the Appium is installed on the terminal side, the UI automation test mainly runs on the terminal side, thereby reducing dependence on the PC environment and improving the speed of UI automation testing.
[0016] These and other aspects of the present application will become more readily apparent from the description of the following embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0018] Figure 1a This is a network architecture diagram provided by an embodiment of the present application;
[0019] Figure 1b This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0020] Figure 2 This is a flow chart of an automated user interface testing method provided by an embodiment of the present application;
[0021] Figure 3 This is a flowchart of a user interface automation testing method provided by an embodiment of the present application;
[0022] Figure 4 is a structural diagram of a first electronic device provided in an embodiment of the present application;
[0023] Figure 5 This is a structural diagram of a user interface automation testing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0025] The following are detailed descriptions of each.
[0026] The terms "first," "second," "third," and "fourth," etc., in the specification and claims of this application and the accompanying drawings are used to distinguish between different objects, rather than to describe a specific order. In addition, the terms "including," "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or elements is not limited to the listed steps or elements, but may optionally include steps or elements not listed, or may optionally include other steps or elements inherent to the process, method, product, or apparatus.
[0027] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0028] Below, some terms in this application are explained to facilitate understanding by those skilled in the art.
[0029] See Figure 1a , Figure 1a This is a network architecture diagram provided in an embodiment of the present application. The network consists of a first electronic device and a second electronic device. The first electronic device is installed with a script execution unit, Appium, the middleware Bootstrap.jar, and UIAutomator. The second electronic device stores script startup commands and test cases. The second electronic device can be a PC, an iOS device, or an Android device, that is, an electronic device running a different operating system.
[0030] See Figure 1b , Figure 1b: It is a structural diagram of an electronic device provided in an embodiment of the present application, which is applied to the above-mentioned first electronic device and second electronic device. The electronic device may include various handheld devices with wireless communication functions, vehicle-mounted devices, wearable devices (such as smart watches, smart bracelets, pedometers, etc.), computing devices or other processing devices connected to a wireless modem, as well as various forms of user equipment (UE), mobile stations (MS), terminal devices, etc. For the convenience of description, the devices mentioned above are collectively referred to as electronic devices. The electronic device includes a processor, a memory, a signal processor, a transceiver, a display screen, a speaker, a microphone, a random access memory (RAM), a camera, and a sensor, etc. Among them, the memory, signal processor, display screen, speaker, microphone, RAM, camera, and sensor are connected to the processor, and the transceiver is connected to the signal processor.
[0031] The display screen may be a liquid crystal display (LCD), an organic or inorganic light-emitting diode (OLED), an active matrix organic light-emitting diode (AMOLED), or the like.
[0032] The camera may be a normal camera or an infrared camera, which is not limited here. The camera may be a front camera or a rear camera, which is not limited here.
[0033] The sensor includes at least one of the following: a light sensor, a gyroscope, an infrared proximity sensor, a fingerprint sensor, a pressure sensor, and the like. The light sensor, also known as an ambient light sensor, is used to detect the brightness of ambient light. The light sensor may include a photosensitive element and an analog-to-digital converter. The photosensitive element is used to convert the collected light signal into an electrical signal, and the analog-to-digital converter is used to convert the electrical signal into a digital signal. Optionally, the light sensor may further include a signal amplifier, which may amplify the electrical signal converted by the photosensitive element and output it to the analog-to-digital converter. The photosensitive element may include at least one of a photodiode, a phototransistor, a photoresistor, and a silicon photocell.
[0034] Among them, the processor is the control center of the electronic device, which uses various interfaces and lines to connect the various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory and calling data stored in the memory, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole.
[0035] The processor may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor.
[0036] The memory is used to store software programs and / or modules. The processor executes the various functional applications and data processing of the electronic device by running the software programs and / or modules stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one software program required for a function, etc.; the data storage area may store data created based on the use of the electronic device, etc. In addition, the memory may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0037] See also Figure 2 , Figure 2 This is a flow chart of an automated user interface testing method provided in an embodiment of the present application, which is applied to a first electronic device, the first electronic device including Appium and a script execution unit. The method includes:
[0038] Step 201: The script execution unit executes a user interface UI automated test script to send a first request to the Appium, where the first request is used to request a first automated test result obtained by executing a first test case.
[0039] Step 202: After receiving the first request, the Appium starts the Appium server.
[0040] Step 203: The Appium obtains the first test case through the Appium server.
[0041] Step 204: The Appium executes the first test case through the Appium server to obtain the first automated test result.
[0042] Step 205: The script execution unit receives the first automated test result sent by the Appium.
[0043] The user interface, or UI for short, refers to the visible appearance of software and its underlying components that interact with users (menus, dialog boxes, windows, and other controls). UI testing involves testing whether the UI style meets customer requirements. It often includes menus, buttons, icons, text boxes, dialog boxes, error messages, help messages, text, and images. Examples include checking for correct text, aesthetics, a perfect combination of text and images, and user-friendliness.
[0044] Appium is an open-source, cross-platform testing framework for testing native and hybrid mobile apps. It supports iOS, Android, and Firefox OS. It uses WebDriver's JSON wire protocol to drive Apple's UIAutomation library and Android's UIAutomator framework. Appium's iOS support is based on Dan Cuellar's research into iOS automation. Appium also integrates with Selendroid to support older Android versions. Appium supports all languages supported by Selenium WebDriver, including Java, Objective-C, JavaScript, PHP, Python, Ruby, C#, Clojure, and Perl, and can use Selenium WebDriver's APIs. Appium supports any testing framework. Using only Apple's UIAutomation requires writing test cases in JavaScript and running them using instructions. Similarly, using only Google's UIAutomation requires writing test cases in Java. Appium enables true cross-platform automated testing.
[0045] The Appium server is based on the http protocol.
[0046] The HTTP protocol is a standard for initiating requests and responses between clients and servers. The server processes the HTTP requests sent by the client and sends a response message to the client. It uses the TCP / IP protocol to transmit various data. The most commonly used HTTP requests are GET and POST. Therefore, the Appium server in this application basically implements these two methods to upload and download files. GET requests are generally used to request specific page information and return an entity body. POST requests are used to submit forms or upload files.
[0047] In one implementation of the present application, before the script execution unit executes the UI automated test script to send the first request to the Appium, the method further includes:
[0048] Appium starts a first service, where the first service is used to listen to a first port;
[0049] The Appium receives the first request through the first port.
[0050] The UI automation test script includes multiple requests, and the first request is one of the multiple requests.
[0051] The first port may be port 4723, for example.
[0052] In one implementation of the present application, the first request carries an identifier of the application to be tested, and the Appium obtains the first test case through the Appium server, including:
[0053] The Appium sends a second request to the second electronic device, where the second request is used to request a test case, and the second request carries first basic information of the application to be tested and second basic information of the first electronic device, where the first basic information is determined based on an identifier of the application to be tested;
[0054] The Appium receives the first test case sent by the second electronic device in response to the second request, where the first test case is determined based on the first basic information and the second basic information.
[0055] The identifier of the application to be tested may be, for example, the name of the application to be tested.
[0056] The first basic information may be, for example, the names of all Activity components and startup parameters of the application to be tested; the second basic information may be, for example, the operating system and operating system version number of the first electronic device.
[0057] The second electronic device generates a simulated operation of the application to be tested based on the operating system, operating system version number, and all Activity component names and startup parameters of the application to be tested of the first electronic device, and generates a first test case based on the simulated operation.
[0058] In one implementation of the present application, the first basic information includes element attribute information. Before the Appium sends the second request to the second electronic device, the method further includes:
[0059] The Appium locates the element of the application to be tested and obtains the element attribute information.
[0060] In one implementation of the present application, the Appium locates an element of the application to be tested and obtains attribute information of the element, including at least one of the following:
[0061] The Appium locates the element of the application to be tested by the ID and obtains the element attribute information of the application to be tested;
[0062] The Appium locates the element of the application to be tested by class_name to obtain the element attribute information of the application to be tested;
[0063] The Appium locates the element of the application to be tested through XPath to obtain the element attribute information of the application to be tested;
[0064] The Appium locates the element of the application to be tested through text to obtain the element attribute information of the application to be tested;
[0065] The Appium locates the element of the application to be tested through css_selector to obtain the element attribute information of the application to be tested;
[0066] The Appium locates the element of the application to be tested by name and obtains the element attribute information of the application to be tested;
[0067] The Appium locates the element of the application to be tested through linkText to obtain element attribute information of the application to be tested.
[0068] Specifically, the Appium locates the element of the application to be tested by id, and obtains the element attribute information of the application to be tested as follows:
[0069] driver.findElement(By.id(“kw”));
[0070] Specifically, the Appium locates the element of the application to be tested by name, and obtains the element attribute information of the application to be tested as follows:
[0071] driver.findElement(By.name('wd'));
[0072] Specifically, the Appium locates the element of the application to be tested by class_name, and obtains the element attribute information of the application to be tested as follows:
[0073] driver.findElement(By.className(“s_ipt”));
[0074] Specifically, the Appium locates the element of the application to be tested through XPath to obtain the element attribute information of the application to be tested, including:
[0075] The h3 element is located by first locating its parent element, then fuzzy positioning through contains, and finally positioning through text.
[0076] Specifically, the h3 element is located by locating its parent element. The positioning method is as follows:
[0077] driver.findElement(By.xpath(" / / div[@class="'right_cont'] / h3"));
[0078] Specifically, through contains fuzzy positioning, the positioning method is as follows:
[0079] driver.findElement(By.xpath(" / / h3[contains(@class,'title')]"));
[0080] Specifically, the Appium locates the element of the application to be tested through text, and obtains the element attribute information of the application to be tested as follows:
[0081] driver.findElement(By.xpath(“ / / h3[text()='Personal Information']”));
[0082] Or, driver.findElement(By.xpath(“ / / h3[contains(text(),'Personal Information')]”)).
[0083] In one implementation of the present application, the first electronic device further includes middleware Bootstrap.jar and UIAutomator, and the Appium executes the first test case through the Appium server to obtain a first automated test result, including:
[0084] The Appium sends the first test case to the middleware Bootstrap.jar;
[0085] The middleware Bootstrap.jar starts a second service, where the second service is used to listen to a second port;
[0086] The middleware Bootstrap.jar receives the first test case sent by the Appium through the second port;
[0087] The middleware Bootstrap.jar converts the first test case into a first command, which can be recognized and executed by the UIAutomator;
[0088] The UIAutomator executes the first command to obtain the first automated test result;
[0089] The UIAutomator sends the first automated test result to the middleware Bootstrap.jar;
[0090] The middleware Bootstrap.jar sends the first automated test result to the Appium.
[0091] The second port may be, for example, port 4724.
[0092] In one implementation of the present application, before the script execution unit executes the UI automated test script to send the first request to the Appium, the method further includes:
[0093] The script execution unit receives a script start command sent by the second electronic device, where the script start command is used to start the UI automation test script;
[0094] The script execution unit starts the UI automation test script based on the script start command.
[0095] Wherein, the script startup command is an adb command.
[0096] It can be seen that in an embodiment of the present application, the first electronic device includes Appium and a script execution unit, which executes a UI automation test script to send a first request to the Appium, and the first request is used to request to obtain the automation test result; after receiving the first request, the Appium starts the Appium server; the Appium obtains the first test case through the Appium server; the Appium executes the first test case through the Appium server to obtain a first automation test result; the Appium sends the first automation test result to the script execution unit. Since the Appium is installed on the terminal side, the UI automation test mainly runs on the terminal side, thereby reducing dependence on the PC environment and improving the speed of UI automation testing.
[0097] With the Figure 2 For details on the embodiment shown, please refer to Figure 3 , Figure 3 This is a flowchart of a user interface automation testing method provided in an embodiment of the present application, which is applied to a first electronic device and a second electronic device. The first electronic device includes Appium, a script execution unit, and middleware Bootstrap.jar and UIAutomator. The method includes:
[0098] Step 301: The script execution unit receives a script start command sent by the second electronic device, where the script start command is used to start the UI automation test script.
[0099] Step 302: The script execution unit starts the UI automation test script based on the script start command.
[0100] Step 303: The Appium starts a first service, where the first service is used to listen to a first port.
[0101] Step 304: The Appium receives a request sent by the script execution unit through the first port.
[0102] Step 305: The script execution unit executes the UI automated test script to send a first request to the Appium, where the first request is used to request to obtain automated test results, and the first request carries an identifier of the application to be tested.
[0103] Step 306: After receiving the first request, the Appium starts the Appium server.
[0104] Step 307: The Appium locates the element of the application to be tested by id to obtain the element attribute information of the application to be tested; and or, the Appium locates the element of the application to be tested by class_name to obtain the element attribute information of the application to be tested; and or, the Appium locates the element of the application to be tested by xpath to obtain the element attribute information of the application to be tested; and or, the Appium locates the element of the application to be tested by text to obtain the element attribute information of the application to be tested; and or, the Appium locates the element of the application to be tested by css_selector to obtain the element attribute information of the application to be tested; and or, the Appium locates the element of the application to be tested by name to obtain the element attribute information of the application to be tested; and or, the Appium locates the element of the application to be tested by linkText to obtain the element attribute information of the application to be tested.
[0105] Step 308: The Appium sends a second request to the second electronic device, where the second request is used to request a test case. The second request carries first basic information of the application to be tested and second basic information of the first electronic device. The first basic information is determined based on the identifier of the application to be tested, and the first basic information includes element attribute information.
[0106] Step 309: The Appium receives a first test case sent by the second electronic device in response to the second request, where the first test case is determined based on the first basic information and the second basic information.
[0107] Step 310: The Appium sends the first test case to the middleware Bootstrap.jar.
[0108] Step 311: The middleware Bootstrap.jar receives the first test case sent by the Appium through a second port, where the second port is the port used for listening after the middleware Bootstrap.jar starts the second service.
[0109] Step 312: The middleware Bootstrap.jar converts the first test case into a first command, which can be recognized and executed by the UIAutomator.
[0110] Step 313: The UIAutomator executes the first command to obtain a first automated test result.
[0111] Step 314: The UIAutomator sends the first automated test result to the middleware Bootstrap.jar.
[0112] Step 315: The middleware Bootstrap.jar sends the first automated test result to the Appium.
[0113] Step 316: The Appium sends the first automated test result to the script execution unit.
[0114] It should be noted that the specific implementation process of this embodiment can refer to the specific implementation process described in the above method embodiment, and will not be described again here.
[0115] With the above Figure 2 and Figure 3 For details on the embodiment shown, please refer to Figure 4 , Figure 4 This is a schematic structural diagram of a first electronic device provided in an embodiment of the present application. As shown in the figure, the first electronic device includes a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for performing the following steps:
[0116] Execute a user interface UI automated test script to send a first request to the Appium, where the first request is used to request a first automated test result, where the first automated test result is obtained by executing a first test case;
[0117] After receiving the first request, start the Appium server;
[0118] Obtaining the first test case through the Appium server;
[0119] Executing the first test case through the Appium server to obtain the first automated test result;
[0120] Sending the first automated test result to the script execution unit.
[0121] In one implementation of the present application, before executing the UI automated test script to send the first request to the Appium, the program further includes instructions for performing the following steps:
[0122] Start a first service, where the first service is used to monitor a first port;
[0123] The first request is received through the first port.
[0124] In one implementation of the present application, the first request carries an identifier of the application to be tested. In obtaining the first test case through the Appium server, the program includes instructions for executing the following steps:
[0125] Sending a second request to a second electronic device, where the second request is used to request a test case, and the second request carries first basic information of the application to be tested and second basic information of the first electronic device, where the first basic information is determined based on an identifier of the application to be tested;
[0126] The first test case sent by the second electronic device in response to the second request is received, where the first test case is determined based on the first basic information and the second basic information.
[0127] In one implementation of the present application, the first basic information includes element attribute information. Before sending the second request to the second electronic device, the program further includes instructions for performing the following steps:
[0128] Element location is performed on the application to be tested to obtain element attribute information.
[0129] In one implementation of the present application, in terms of locating the element of the application to be tested and obtaining the element attribute information, the program includes instructions specifically for executing the following steps:
[0130] Locating the element of the application to be tested by using the ID to obtain the element attribute information of the application to be tested;
[0131] and / or, locating the element of the application to be tested by class_name to obtain element attribute information of the application to be tested;
[0132] and / or, locating elements of the application to be tested by using XPath to obtain element attribute information of the application to be tested;
[0133] and / or, locating elements of the application to be tested through text to obtain element attribute information of the application to be tested;
[0134] and / or, locating elements of the application to be tested by using css_selector to obtain element attribute information of the application to be tested;
[0135] and / or, locating the element of the application to be tested by name to obtain element attribute information of the application to be tested;
[0136] And / or, locate the element of the application to be tested through linkText to obtain element attribute information of the application to be tested.
[0137] In one implementation of the present application, the first electronic device further includes middleware Bootstrap.jar and UIAutomator. In terms of executing the first test case through the Appium server to obtain the first automated test result, the program includes instructions specifically for performing the following steps:
[0138] Sending the first test case to the middleware Bootstrap.jar;
[0139] The middleware Bootstrap.jar starts a second service, where the second service is used to listen to a second port;
[0140] receiving the first test case sent by the Appium through the second port;
[0141] Converting the first test case into a first command, where the first command can be recognized and executed by the UIAutomator;
[0142] Execute the first command to obtain the first automated test result;
[0143] Sending the first automated test result to the middleware Bootstrap.jar;
[0144] Sending the first automated test result to the Appium.
[0145] In one implementation of the present application, before the script execution unit executes the UI automated test script to send the first request to the Appium, the program further includes instructions for performing the following steps:
[0146] Receiving a script start command sent by the second electronic device, where the script start command is used to start the UI automated test script;
[0147] The UI automation test script is started based on the script start command.
[0148] It should be noted that the specific implementation process of this embodiment can refer to the specific implementation process described in the above method embodiment, and will not be described again here.
[0149] The above embodiments mainly introduce the solutions of the embodiments of the present application from the perspective of the execution process on the method side. It is understandable that, in order to realize the above functions, the first electronic device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0150] In the embodiment of the present application, the functional units of the first electronic device can be divided according to the method example. For example, each functional unit can be divided according to each function, or two or more functions can be integrated into one processing unit. The integrated unit can be implemented in the form of hardware or in the form of a software functional unit. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical functional division. In actual implementation, there may be other division methods.
[0151] The following is an embodiment of the device of the present application, which is used to execute the method implemented by the method embodiment of the present application. Figure 5 , Figure 5 1 is a schematic diagram of a user interface automated testing apparatus provided in an embodiment of the present application, which is applied to a first electronic device. The first electronic device includes a script execution unit 501 and an Appium 502. The apparatus includes:
[0152] The script execution unit 501 is configured to execute a user interface UI automated test script to send a first request to the Appium 502, wherein the first request is used to request a first automated test result obtained by executing a first test case;
[0153] The Appium 502 is configured to start the Appium server after receiving the first request; obtain the first test case through the Appium server; execute the first test case through the Appium server to obtain the first automated test result; and send the first automated test result to the script execution unit.
[0154] In one implementation of the present application, when executing the UI automation test script, the Appium
[0155] Before sending the first request, the Appium 502 is also used to:
[0156] Start a first service, where the first service is used to monitor a first port;
[0157] The first request is received through the first port.
[0158] In one implementation of the present application, the first request carries an identifier of the application to be tested. In obtaining the first test case through the Appium server, the Appium 502 is specifically configured to:
[0159] Sending a second request to a second electronic device, where the second request is used to request a test case, and the second request carries first basic information of the application to be tested and second basic information of the first electronic device, where the first basic information is determined based on an identifier of the application to be tested;
[0160] The first test case sent by the second electronic device in response to the second request is received, where the first test case is determined based on the first basic information and the second basic information.
[0161] In one implementation of the present application, the first basic information includes element attribute information. Before sending the second request to the second electronic device, the Appium 502 is further configured to locate the element of the application to be tested to obtain the element attribute information.
[0162] In one implementation of the present application, in locating an element of the application to be tested and obtaining the element attribute information, the Appium 502 is specifically configured to:
[0163] Locating the element of the application to be tested by using the ID to obtain the element attribute information of the application to be tested;
[0164] and / or, locating the element of the application to be tested by class_name to obtain element attribute information of the application to be tested;
[0165] and / or, locating elements of the application to be tested by using XPath to obtain element attribute information of the application to be tested;
[0166] and / or, locating elements of the application to be tested through text to obtain element attribute information of the application to be tested;
[0167] and / or, locating elements of the application to be tested by using css_selector to obtain element attribute information of the application to be tested;
[0168] and / or, locating the element of the application to be tested by name to obtain element attribute information of the application to be tested;
[0169] And / or, locate the element of the application to be tested through linkText to obtain element attribute information of the application to be tested.
[0170] In one implementation of the present application, the first electronic device further includes middleware Bootstrap.jar 503 and UIAutomator 504. In terms of executing the first test case through the Appium server to obtain the first automated test result, the Appium 502 is specifically configured to send the first test case to the middleware Bootstrap.jar 503.
[0171] The middleware Bootstrap.jar 503 is used to start a second service, which is used to listen to a second port and receive the first test case sent by the Appium 502 through the second port;
[0172] The middleware Bootstrap.jar 503 is further used to convert the first test case into a first command, which allows the first command to be recognized and executed by the UIAutomator 504;
[0173] The UIAutomator 504 is configured to execute the first command and obtain the first automated test result;
[0174] The UIAutomator 504 is further configured to send the first automated test result to the middleware Bootstrap.jar 503;
[0175] The middleware Bootstrap.jar 503 is also used to send the first automated test result to the Appium 502.
[0176] It should be noted that the script execution unit 501, the Appium 502, the middleware Bootstrap.jar 503 and the UIAutomator 504 can be implemented by a processor.
[0177] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, and the computer program enables a computer to execute part or all of the steps of any method described in the above method embodiments, and the above computer includes an electronic device.
[0178] The present application also provides a computer program product, comprising a non-transitory computer-readable storage medium storing a computer program. The computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, without limitation. The computer program is operable to cause a computer to execute some or all of the steps of any of the methods described in the above method embodiments. The computer program product may be a software installation package, and the computer may include a first electronic device.
[0179] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0180] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0181] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0182] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0183] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0184] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes a number of instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the above-mentioned methods of each embodiment of the present application. The aforementioned memory includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0185] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program. The program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0186] The above is a detailed introduction to the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for those skilled in the art, according to the idea of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A user interface automated testing method, characterized in that: Applied to a first electronic device, the first electronic device includes Appium and a script execution unit, and the method includes: The script execution unit executes a user interface UI automated test script to send a first request to the Appium, where the first request is used to request a first automated test result, where the first automated test result is obtained by executing a first test case, and the first request carries an identifier of the application to be tested; After receiving the first request, the Appium starts an Appium server, which runs on the second electronic device; The Appium obtains the first test case through the Appium server, including: the Appium sends a second request to the second electronic device, the second request is used to request to obtain the test case, the second request carries first basic information of the application to be tested and second basic information of the first electronic device, the first basic information is determined based on the identifier of the application to be tested; the Appium receives the first test case sent by the second electronic device in response to the second request, the first test case is determined based on the first basic information and the second basic information; The Appium executes the first test case through the Appium server to obtain the first automated test result; The Appium sends the first automated test result to the script execution unit.
2. The method according to claim 1, characterized in that Before the script execution unit executes the UI automated test script to send the first request to the Appium, the method further includes: Appium starts a first service, where the first service is used to listen to a first port; The Appium receives the first request through the first port.
3. The method according to claim 1, characterized in that The first basic information includes element attribute information. Before the Appium sends the second request to the second electronic device, the method further includes: The Appium locates the element of the application to be tested and obtains the element attribute information.
4. The method according to claim 3, characterized in that The Appium locates an element of the application to be tested and obtains attribute information of the element, including at least one of the following: The Appium locates the element of the application to be tested by the ID and obtains the element attribute information of the application to be tested; The Appium locates the element of the application to be tested by class_name to obtain the element attribute information of the application to be tested; The Appium locates the element of the application to be tested through XPath to obtain the element attribute information of the application to be tested; The Appium locates the element of the application to be tested through text to obtain the element attribute information of the application to be tested; The Appium locates the element of the application to be tested through css_selector to obtain the element attribute information of the application to be tested; The Appium locates the element of the application to be tested by name and obtains the element attribute information of the application to be tested; The Appium locates the element of the application to be tested through linkText to obtain element attribute information of the application to be tested.
5. The method according to any one of claims 1 to 4, characterized in that The first electronic device further includes middleware Bootstrap.jar and UIAutomator, and the Appium executes the first test case through the Appium server to obtain the first automated test result, including: The Appium sends the first test case to the middleware Bootstrap.jar; The middleware Bootstrap.jar starts a second service, where the second service is used to listen to a second port; The middleware Bootstrap.jar receives the first test case sent by the Appium through the second port; The middleware Bootstrap.jar converts the first test case into a first command, which can be recognized and executed by the UIAutomator; The UIAutomator executes the first command to obtain the first automated test result; The UIAutomator sends the first automated test result to the middleware Bootstrap.jar; The middleware Bootstrap.jar sends the first automated test result to the Appium.
6. The method according to claim 5, characterized in that Before the script execution unit executes the UI automated test script to send the first request to the Appium, the method further includes: The script execution unit receives a script start command sent by the second electronic device, where the script start command is used to start the UI automation test script; The script execution unit starts the UI automation test script based on the script start command.
7. A user interface automated testing device, the device being configured to execute the method according to any one of claims 1 to 6, characterized in that: Applied to a first electronic device, the first electronic device includes Appium and a script execution unit, and the apparatus includes: The script execution unit is configured to execute a user interface UI automated test script to send a first request to the Appium, wherein the first request is used to request a first automated test result obtained by executing a first test case; The Appium is configured to start the Appium server after receiving the first request; obtain the first test case through the Appium server; execute the first test case through the Appium server to obtain the first automated test result; and send the first automated test result to the script execution unit.
8. A first electronic device, characterized in that: The method comprises a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing the steps in the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 6.