Data processing method and device
Through the method of automatically recording test cases, the problem of manual writing of test cases in the prior art is solved, and the effect of improving testing efficiency and coverage is achieved.
Patent Information
- Application Number
- CN202411747708.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-25
AI Technical Summary
In the prior art, test cases are manually written, which are inefficient and not suitable for general applications. How to realize automated recording of test cases is an urgent problem.
By starting the recording operation of the first interface of the target device, the interface element information and user operations are obtained, and the test case information is generated and sent to the test platform to automatically write test cases.
Improves testing efficiency, reduces duplicate manual testing efforts, increases test coverage, ensures that all key functions are validated, and provides consistent test results, reducing test errors caused by human factors.
Smart Images

Figure CN119690828A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a data processing method and device. Background Art
[0002] In the process of developing a world wide web (WEB) system, when the WEB system development enters the testing phase, testers need to verify the correctness and stability of the user interface functions. At this time, test cases can be used to quickly detect whether code changes introduce errors at the user interface (UI) level. However, current test cases are manually written, which is inefficient and not suitable for universal application.
[0003] Therefore, how to realize automatic recording of test cases is a problem that needs to be solved urgently. Summary of the invention
[0004] The present invention provides a data processing method and device for realizing automatic recording of interface elements and operation information (test cases).
[0005] In a first aspect, the present invention provides a data processing method, which includes: starting a recording operation on a first interface of a target device, obtaining interface element information of the first interface, the interface element information including position information of each element presented in the first interface, responding to an operation of a user on the first interface, determining a target element corresponding to the operation, generating first information according to the position information of the target element, the operation type and operation parameters of the operation, and sending the first information to a test platform.
[0006] Through the above scheme, the interface element information of the first interface and the user's operations on the first interface can be obtained, so that the test case recording can be realized. By automating the writing of test cases, the test efficiency can be improved, repetitive manual testing work can be reduced, and the test coverage can be increased to ensure that all key functions are verified. In addition, consistent test results can be provided and test errors caused by human factors can be reduced. In addition, automated test cases can provide timely feedback on the quality status of the product and provide valuable information for the development team for rapid iteration and improvement.
[0007] Optionally, the operation includes one or more of a single-click operation, a double-click operation, and an input text operation, wherein the single-click operation includes pressing the mouse and releasing the mouse, and the position difference between the mouse position when the mouse is pressed and the mouse position when the mouse is released is less than a preset threshold, the double-click operation includes a first mouse click and a second mouse click, and the position difference between the position when the first mouse click and the second mouse click is within a preset range, and the input text operation includes continuously entering multiple characters.
[0008] Through the above solution, multiple independent basic operation steps are merged into a more advanced operation step, and the merged advanced operation step is sent to the test platform, which can make the test steps more concise and accurate, and help improve the efficiency and readability of automated testing.
[0009] Optionally, interface element information of the first interface of the target device is obtained, including: obtaining node attributes and text content of each element in the first interface, and performing the following operations for each element: generating a first path according to the text content, and determining whether the first path is unique; if the first path is unique, using the first path as the location information of the element; if the first path is not unique, generating a second path according to the node attributes of the element, and determining whether the second path is unique; if the second path is unique, using the second path as the location information of the element; if the second path is not unique, obtaining the parent node element of the element, generating a third path according to the text content of the parent node element, and\or generating a fourth path according to the node attributes of the parent node element, and using the only path in the third path or the fourth path as the location information of the element.
[0010] Through the above scheme, the accuracy and stability of element positioning can be improved. Compared with the scheme of using cascading style sheets (CSS) selectors to locate web page elements in the prior art, when the prior art processes dynamic pages or frequently changing layouts, CSS selectors are prone to failure, resulting in unstable original positioning and affecting the reliability of the test. The present application changes the element positioning method to give priority to using XML Path Language (XPath) expressions. Since XPath has more powerful path expression capabilities, XPath can locate elements more accurately in a complex document object model (DOM) structure. Especially when processing dynamically changing web pages, XPath expressions can locate elements based on the hierarchical relationship, attributes or content of the elements, rather than relying solely on CSS classes or identity documents (IDs), which makes it more reliable in complex and changing page structures.
[0011] Optionally, the target device includes a recording tool and an executable script, the executable script is used to start the recording tool, start the interface recording operation of the target device, including: obtaining startup information from the test platform, the startup information is used to start the executable script and start the recording tool according to the started executable script.
[0012] Through the above solution, the user's operation process can be simplified so that they can start the recording task conveniently and quickly, while avoiding interference with other pages and dependence on a specific environment, and realizing an environment-independent and experience-friendly startup solution.
[0013] In a second aspect, the present invention provides a data processing method, which includes: receiving first information, the first information being generated based on location information of a target element, and an operation type and operation parameters of a user's operation on the target element, the target element being an element on a first interface of a target device; and storing the first information in a first database.
[0014] Through the above scheme, the interface element information of the first interface and the user's operations on the first interface can be obtained, so that the test case recording can be realized. By automating the writing of test cases, the test efficiency can be improved, repetitive manual testing work can be reduced, and the test coverage can be increased to ensure that all key functions are verified. In addition, consistent test results can be provided and test errors caused by human factors can be reduced. In addition, automated test cases can provide timely feedback on the quality status of the product and provide valuable information for the development team for rapid iteration and improvement.
[0015] Optionally, the first information has a first format, which is a format supported by a recording tool. Before storing the first information in the first database, the method further includes: converting the first information in the first format to obtain the first information in a second format, which is a format supported by a test platform.
[0016] Through the above scheme, the format of the first information is converted into a format supported by the test platform, and then the test platform stores the first information after the format conversion in the database, which can be directly used in subsequent test cases.
[0017] Optionally, the first database is a permanent database, and storing the first information in the first database includes: storing the first information in a second database, the second database is a temporary database, and if a recording end message is received, all the first information stored in the second database is stored in the first database, and the second database is cleared.
[0018] Through the above scheme, the test platform adopts a caching and polling mechanism to realize real-time updating of the operation steps being recorded by the recording tool, that is, the test platform obtains the latest test step information from the back end, and updates the interface in real time to display the operation steps currently being recorded. Compared with the prior art in which users cannot view the recorded operation steps in real time, which affects the debugging and confirmation during the test process, the present application can provide instant feedback to the operator to ensure the accuracy of the recording process, so that testers can see their operations being correctly captured in real time during the recording process, thereby improving the efficiency and accuracy of the test process. That is, if a problem is found, the operator can immediately adjust or re-record, instead of waiting until the entire process is over to discover the problem.
[0019] In a third aspect, the present invention provides a data processing device, the device comprising:
[0020] A starting module, used to start the recording operation of the first interface of the target device;
[0021] An acquisition module, used to acquire interface element information of the first interface, wherein the interface element information includes position information of each element presented in the first interface;
[0022] A generating module, configured to determine a target element corresponding to the operation in response to the user's operation on the first interface, and generate first information according to the position information of the target element, the operation type and the operation parameter of the operation;
[0023] The sending module is used to send the first information to the test platform.
[0024] In one possible implementation, the operation includes one or more of a single-click operation, a double-click operation, and an input text operation, wherein the single-click operation includes pressing the mouse and releasing the mouse, and the position difference between the mouse position when the mouse is pressed and the mouse position when the mouse is released is less than a preset threshold, the double-click operation includes a first single-click and a second single-click, and the position difference between the position when the first mouse click and the position when the second mouse click is within a preset range, and the input text operation includes continuously entering multiple characters.
[0025] In one possible implementation, the acquisition module is specifically used to: acquire the node attributes and text content of each element in the first interface, and for each element, perform the following operations: generate a first path based on the text content, and determine whether the first path is unique; if the first path is unique, use the first path as the location information of the element; if the first path is not unique, generate a second path based on the node attributes of the element, and determine whether the second path is unique; if the second path is unique, use the second path as the location information of the element; if the second path is not unique, acquire the parent node element of the element, generate a third path based on the text content of the parent node element, and\or generate a fourth path based on the node attributes of the parent node element, and use the only path in the third path or the fourth path as the location information of the element.
[0026] In a possible implementation, the target device includes a recording tool and an executable script, the executable script is used to start the recording tool, and the startup module is specifically used to: obtain startup information from the test platform, the startup information is used to start the executable script and start the recording tool according to the started executable script.
[0027] In a fourth aspect, the present invention provides a data processing device, the device comprising:
[0028] A receiving module, configured to receive first information, wherein the first information is generated according to location information of a target element, and an operation type and an operation parameter of a user's operation on the target element, and the target element is an element on a first interface of a target device;
[0029] The storage module is used to store the first information in the first database.
[0030] In a possible implementation, the first information has a first format, which is a format supported by a recording tool, and the storage module is further used to: convert the first information in the first format to obtain the first information in a second format, which is a format supported by a test platform.
[0031] In one possible implementation, the first database is a permanent database, and the storage module is specifically used to: store the first information in the second database, the second database is a temporary database, and if the recording end information is received, all the first information stored in the second database is stored in the first database, and the second database is cleared.
[0032] In a fifth aspect, the present invention further provides a data processing device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method described in the various possible designs of the first aspect.
[0033] In a sixth aspect, the present invention further provides a computer-readable storage medium having a computer program or instructions stored thereon. When the computer program or instructions are executed by a processor, the method described in the various possible designs of the first aspect is implemented.
[0034] In a seventh aspect, the present invention further provides a computer program product, which, when executed on a computer, enables the computer to execute any of the methods described in the first aspect above.
[0035] These implementations or other implementations of the present application will be more concise and understandable in the description of the following embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0037] Figure 1 A schematic diagram of the architecture of a data processing system provided by an embodiment of the present invention;
[0038] Figure 2 A schematic diagram of an interactive process of a data processing method provided by an embodiment of the present invention;
[0039] Figure 3 A schematic diagram of a process of starting a recording tool with one key provided by an embodiment of the present invention;
[0040] Figure 4 A schematic diagram of a flow chart of starting a recording operation on a first interface of a target device provided by an embodiment of the present invention;
[0041] Figure 5 A schematic diagram of starting a recording tool through an executable script provided by an embodiment of the present invention;
[0042] Figure 6 A schematic diagram of a flow chart of positioning interface elements provided by an embodiment of the present invention;
[0043] Figure 7 A schematic diagram of a data processing flow provided by an embodiment of the present invention;
[0044] Figure 8 A schematic diagram of a recording test case provided by an embodiment of the present invention;
[0045] Fig. 9 A schematic diagram of recording a test case for a page using a recording tool provided by an embodiment of the present invention;
[0046] Fig.10 A schematic diagram of an interface for recording test cases using a recording tool provided by an embodiment of the present invention;
[0047] Fig.11 A schematic diagram of another data processing flow provided by an embodiment of the present invention;
[0048] Fig.12 A schematic diagram of a data processing device provided by an embodiment of the present invention;
[0049] Fig.13 A schematic diagram of another data processing device provided by an embodiment of the present invention;
[0050] Fig.14 A schematic diagram of another data processing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and beneficial effects of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0052] Below, some terms in this application are explained. It should be noted that these explanations are for the convenience of understanding by those skilled in the art and do not constitute a limitation on the scope of protection claimed in this application.
[0053] 1. Assertions.
[0054] An assertion is a checkpoint used to verify whether the actual output or behavior of a program is as expected. In Web UI automation testing, assertions are usually used to verify whether page elements exist, check whether the attributes or text content of elements are correct, confirm whether a specific operation produces the expected results, etc. For example, when testing a login function, assertions may be used to check whether the login button is clickable, whether an error message is displayed after entering incorrect credentials, whether the correct page is redirected after a successful login, etc.
[0055] 2. WebSocket.
[0056] WebSocket is a network communication protocol that allows real-time, two-way data exchange between servers and clients. Once a connection is established, it can remain open without the need to frequently establish and disconnect connections like the Hypertext Transfer Protocol (HTTP). After a WebSocket connection is established, data can be sent immediately, reducing communication delays. By establishing a persistent connection, WebSocket allows the server to actively push data to the client without the client having to constantly send requests to obtain updates.
[0057] 3. Uniform resource locator protocol (URLProtocol).
[0058] URL Protocol is a custom protocol that allows applications to start local programs or perform specific operations through a specific URL format. When a user clicks or enters a URL using this protocol, the operating system will identify and start the corresponding application. In Windows systems, URL protocols are usually configured through the registry to associate specific protocol names with application paths. In this article, URL protocols are used to quickly start recording tools. For example, a custom protocol such as "myrecord: / / xxx" is used to start the recording tool.
[0059] 4. UIRecorder.
[0060] UIRecorder is a recording tool for Web UI automated testing that can record user interactions in the browser, such as mouse clicks, keyboard input, and other operations, and convert these behaviors into executable test scripts.
[0061] As described in the background technology, automated recording of use cases is a problem that urgently needs to be solved. The current method for automated writing of WebUI use cases is a method based on programming languages and frameworks, that is, automated use case scripts are written through specific programming languages (such as Java, Python, etc.) and combined with corresponding test frameworks (such as Selenium, UnitTest, etc.). These scripts include initializing the test environment, executing test steps, verifying test results, and handling abnormal situations. When running the test script, the test framework will automatically execute and generate a test report.
[0062] However, this method has many disadvantages, such as: 1. High learning cost: This method requires mastering specific programming languages and testing frameworks, which may be difficult for testers with non-technical backgrounds; 2. High maintenance cost: Since test cases are saved in files in the form of scripts, when the page structure changes, a large amount of code needs to be modified, which increases the complexity of maintenance; 3. Strong environmental dependence: The script generated by the recording needs to be built locally for execution, so a specific programming environment and dependent libraries need to be installed; 4. Complex installation: The steps for installing the recording tool are cumbersome, and different people may install different versions of the tool, which may lead to version compatibility issues during the test process.
[0063] Therefore, how to efficiently and automatically record test cases is an urgent problem that needs to be solved.
[0064] Based on this, the present invention provides a data processing method, which realizes efficient and automatic recording of test cases by acquiring interface element information of a first interface and operations of the first interface.
[0065] The present application scheme is described in detail below in conjunction with the accompanying drawings.
[0066] See also Figure 1 , showing a schematic diagram of the architecture of a data processing system. The architecture includes a test platform 110 and a target device 120, which are connected by wire or wirelessly. Usually, a test platform can be connected to multiple target devices (such as target device 121, target device 122, target device 123, etc. in the figure), so that test cases can be tested on multiple target devices through one test device.
[0067] In this application, the target device can be a variety of terminal devices such as PC and mobile terminals. Recording tools are provided on the target device, such as browser plug-ins (such as Selenium IDE, Katalon Recorder), stand-alone applications (such as UFT, TestComplete), or integrated development environment plug-ins (such as Playwright Test Recorder of VS Code), etc. The recording tool can record the UI test cases of WEB, thereby recording all the operations of the user on the WEB interface. The recorded information can also send the recorded information to the test platform.
[0068] In this application, the test platform can receive the recording information of the recording tool and make assertions based on the recording information to verify whether the actual output or behavior of the WEB interface meets expectations.
[0069] It should be noted that Figure 1 The data processing system shown is only an example. In addition to the test platform and the target device, the data processing system may also include other devices or apparatuses, such as routing devices, conversion devices, gateway devices, etc., without limitation.
[0070] based on Figure 1 The data processing system shown is shown in Figure 2 , showing an interactive flow diagram of a data processing method provided by the present application, the flow mainly includes the following steps:
[0071] Step 210: The recording tool starts recording the first interface of the target device.
[0072] Here, the target device may call a recording tool to record the test case for the target device, that is, download the recording tool in the target device, and then use the recording tool in the target device to record the test case.
[0073] Optionally, the target device can download the recording tool from the test platform.
[0074] Optionally, the target device may select a nullsoft scriptable install system (NSIS) tool to create an installation package, and add a registry configuration required to start an executable file (EXE) program to the generated NSIS script.
[0075] Through the above solution, users do not need to manually process any registry settings, which simplifies the user's operation process and reduces the risk of errors during the installation process, allowing users to complete the installation of the recording tool more quickly and conveniently. In addition, the prior art directly packages the Python program into a folder, requiring users to manually download the folder and create a registry file, which is cumbersome. The present application can integrate the packaged folder and registry file into an installation package to achieve one-click installation, that is, simplifying the originally complex installation steps into a simple click operation, lowering the user's usage threshold, greatly improving the user experience, and avoiding compatibility issues caused by different versions of tools.
[0076] Optionally, UIRecorder may be used as a basic component of the recording tool, that is, the target device downloads UIRecorder from the test platform.
[0077] Optionally, after obtaining the start instruction input by the user, the recording tool can be started in a variety of ways, thereby achieving one-click start of the recording tool, such as installing a recording plug-in through the browser (this solution is real-time and simple), or using Node.js to start the browser (this solution can avoid the plug-in from interfering with other pages), or using Python and Selenium to start the browser (this solution can effectively prevent the plug-in from affecting other pages), etc., without restriction.
[0078] However, the above solutions all have disadvantages. For example, in the solution of installing the recording plug-in through the browser, the plug-in will inject scripts into all browsing pages, which may interfere with the normal operation of other pages; in the solution of using Node.js to start the browser, it is necessary to install the Node.js environment, which increases the configuration burden and reduces flexibility; in the solution of using Python and Selenium to start the browser, it is necessary to rely on the Python environment. Therefore, this application proposes a new solution for realizing one-click start of the recording tool, please refer to Figure 3 , showing a schematic diagram of a process of starting a recording tool with one key, the solution includes the following steps:
[0079] Step 310: Use Python combined with the Selenium library to implement core functions.
[0080] These include loading a recording tool (such as a plug-in) to start a browser, receiving an end instruction from a recording tool (such as a plug-in) to close the browser, and recording operation logs.
[0081] Step 320: Use the PyInstaller tool to package the Python program into an executable file to ensure that it can run independently.
[0082] Step 330: Add the generated executable file to the system registry so that the front end can directly call the local .exe program through the URL protocol to start the recording tool.
[0083] Through the above steps 310 to 330, based on the solution of using Python and Selenium to start the browser, the Python program is packaged into an executable file, and it is integrated into the operating system by writing a registry file. Finally, the recording tool can be started by calling a custom protocol (such as: myrecord: / / xxx) using a simple front-end code. In this way, the user's operation process can be simplified, allowing them to start the recording task conveniently and quickly, while avoiding interference with other pages and dependence on a specific environment, and realizing an environment-independent and experience-friendly startup solution.
[0084] In the above steps 310 to 330, the Python program is packaged into an executable file using the PyInstaller tool, and finally an executable script is generated, through which the recording tool can be started. That is, the target device includes not only the recording tool but also the executable script, see Figure 4 , showing a schematic diagram of a process of starting a recording operation on a first interface of a target device, step 210 specifically includes:
[0085] Step 410: The test platform obtains a startup instruction input by the user.
[0086] When the user wants to start the recording tool, enter the corresponding start command on the test platform.
[0087] Step 420: The test platform sends the startup information corresponding to the startup instruction to the target device, and the target device starts the recording tool according to the startup information.
[0088] Here, the startup information is used to start the executable script and start the recording tool according to the started executable script.
[0089] For details, please refer to Figure 5 , showing a schematic diagram of starting a recording tool through an executable script. As can be seen from the figure, the target device 510 includes a recording tool 511 and an executable script 512, and the executable script 512 also includes a Selenium tool. The user recording process can be divided into the following two steps:
[0090] (1) When the user wants to start the recording tool 511, the corresponding start command is input in the test platform 520. The front end of the test platform 520 calls the exe file in the executable script 512 of the target device 510 through the URL protocol. Then the executable script 512 starts the browser to load the recording tool 511. The recording tool 511 starts the recording operation, wherein the recording operation includes event monitoring and DOM capture;
[0091] (2) When the user wants to end the recording, the user clicks the End Recording button on the browser interface of the target device 510. After that, the recording tool 511 generates the recording steps and closes the browser. The recording tool 511 establishes a connection with the executable script 512 through the webSocket protocol, and the executable script 512 generates a log file.
[0092] Step 220: The recording tool obtains interface element information of the first interface.
[0093] The first interface element information includes position information of each element presented in the first interface, that is, the first interface information includes the interface elements and the positions corresponding to the interface elements.
[0094] Optionally, a CSS selector may be used to locate an interface element (such as a web page element), or an XPath expression may be used to locate an interface element, and so on, without limitation herein.
[0095] Optionally, you can use improved XPath to more accurately locate elements in Web UI automated tests, see Figure 6 , showing a schematic diagram of the process of locating interface elements, which specifically includes the following steps:
[0096] Step 610: Obtain the node attributes and text content of each element in the first interface.
[0097] Here, before locating the interface element, initialization needs to be performed first, that is, the node attributes and text content of the interface element are obtained first.
[0098] Optionally, the text content can be processed after being obtained, for example, removing extra spaces and line breaks.
[0099] Step 620: For each element, generate a first path according to the text content, and determine whether the first path is unique. If it is unique, execute step 630; if it is not unique, execute step 640.
[0100] Here, for common tags (such as , <button> , <label>When there is no ID (such as etc.), the first path XPath is generated using the text content. Specifically, the contains and normalize-space functions can be used to match the text content to improve the uniqueness of the XPath.
[0101] Step 630: Use the first path as the position information corresponding to the element.
[0102] Here, if the first path can be uniquely determined, return the first path XPath expression.
[0103] Step 640: Generate a second path based on the node attributes and determine whether the second path is unique. If it is unique, execute step 650; if it is not unique, execute 660.
[0104] Here, traverse all the attributes of the node, select appropriate attributes to generate the XPath. The ID attribute can be used preferentially, followed by other attributes such as name, class, placeholder, etc. Then check whether the generated XPath is unique. If it is not unique, try other attributes or combinations.
[0105] Step 650: Use the second path as the position information corresponding to the element.
[0106] Here, if the second path can be uniquely determined, return the second path XPath expression.
[0107] Step 660: Obtain the parent node element of the element, generate a third path based on the text content of the parent node element, and / or generate a fourth path based on the node attributes of the parent node element. Use the unique path in the third path or the fourth path as the position information corresponding to the element.
[0108] If a unique XPath cannot be generated through both node attributes and text content, consider the position of the element in its parent node and recursively search upward, that is, search for the path of the parent node (the steps for searching the parent node path can refer to the above steps 620 to step 650). Specifically, if the current node is not unique in the parent node, record its index position. The final XPath is the node XPath + index, such as: ( / / span[contains(text(),'query')]), until an XPath that uniquely identifies the target node is found.
[0109] Through the above scheme, the accuracy and stability of element positioning can be improved. Compared with the scheme of using CSS selectors to locate web page elements in the prior art, the CSS selectors in the prior art are prone to failure when processing dynamic pages or frequently changing layouts, resulting in unstable original positioning and affecting the reliability of the test. The present application changes the element positioning method to give priority to using XPath expressions. Since XPath has a more powerful path expression capability, XPath can locate elements more accurately in a complex DOM structure. Especially when processing dynamically changing web pages, XPath expressions can locate elements based on the hierarchical relationship, attributes or content of the elements, rather than relying solely on CSS classes or IDs, which makes it more reliable in complex and changing page structures.
[0110] Step 230: The recording tool determines a target element corresponding to the operation in response to the user's operation on the first interface, and generates first information according to position information of the target element, an operation type and operation parameters of the operation.
[0111] Here, after obtaining the information of each element of the first interface in step 220, it is also necessary to obtain the user's operation during the recording process and record the element information corresponding to the user's operation.
[0112] Optionally, you can use custom keywords to record the user's operation steps, that is, first define a set of keywords, define the test steps and operation process as a series of methods and their corresponding implementation logic, each keyword represents a specific operation or function, such as page operation (click, input, selection, etc., for example, "open_browser" represents opening the browser, "click" represents clicking, "input_string" represents input), assertion (verifying page element status or text) and data processing, etc., and each keyword method can support multiple parameters (such as element positioning, input value, etc.), and then use these defined keywords to write test cases. Each test case can describe a series of operation steps and expected results. When executing the test case, the framework converts the keywords into actual operations, executes them step by step, and performs assertions and data processing.
[0113] Through the above solution, testers do not need to write a complete automated test script, but only need to select appropriate keyword methods and parameters to complete the writing of test cases. Moreover, when executing the test, the automation framework will call the corresponding implementation logic according to the keyword to complete the operation. When the program changes, only the affected parameters need to be updated without modifying the existing test framework. If there are new test requirements, new keywords can be added to expand the capabilities without making major changes to the existing platform. In this way, test cases can be created efficiently and are easy to maintain.
[0114] However, in the prior art, recording user operations is to record multiple independent basic events (such as mouse press, mouse release, click, text input, etc.), which results in high complexity of test steps and poor readability. The present application combines multiple independent basic events into a high-level single instruction, making the test steps more concise.
[0115] Optionally, the operation includes one or more of a mouse click operation, a mouse double-click operation, and a text input operation. Specifically:
[0116] (1) The operation of clicking the mouse includes pressing the mouse and releasing the mouse, and the position difference between the mouse position when the mouse is pressed and the mouse position when the mouse is released is less than a preset threshold.
[0117] That is, when detecting mouse operations in the prior art, two events, mouse press (mouseDown) and mouse release (mouseUp), are detected and recorded separately, while the present application combines mouseDown and mouseUp into one command (i.e., a mouse click event click) when it is detected that they occur at the same position or the coordinate error is less than a preset threshold (e.g., 20 pixels).
[0118] (2) The double-click operation includes a first click and a second click, and the position difference between the position when the first click and the position when the second click is within a preset range.
[0119] In this application, when two consecutive click events are detected, they are combined into one command (i.e., double-click mouse event dblClick). Compared with the prior art, which records four operations (mouseDown, mouseUp, mouseDown, mouseUp), this application only needs to record one operation (dblClick). This makes the test steps more concise when the test is finally performed.
[0120] (3) The operation of inputting text includes inputting multiple characters continuously.
[0121] Here, when input content (sendKeys) events are detected, the parameters of these events (such as keys) are merged into a string to generate a new command (ie, input text event sendKeys).
[0122] In the prior art, when a single character keyboard input (sendKeys) is detected, each input content is recorded separately, while the present application combines single keyboard events of continuous input into one event, making the steps more concise.
[0123] Through the above solution, multiple independent basic operation steps are merged into a more advanced operation step, and the merged advanced operation step is sent to the test platform, which can make the test steps more concise and accurate, and help improve the efficiency and readability of Web UI automated testing.
[0124] Understandably, when recording Web UI automated tests, since modern web pages usually have complex structures, it is necessary to switch between frames and windows. A frame is an independent area in a web page, and a window is a browser tab or pop-up window. If you want to operate elements in different frames or windows, you must first switch to the corresponding window interface to ensure that the recording tool can correctly locate and operate the target elements.
[0125] Optionally, during the recording process, the recording tool can record the frame / window information of each operation, and compare the current frame / window with the previous record to determine whether the current frame / window is consistent with the previous frame / window. If a change in the frame or window is detected, a corresponding switching command (such as a switchFrame or switchWindow command) is generated to ensure that subsequent operations can be performed in the correct context.
[0126] Through the above scheme, specific commands for switching frames and windows are added. Compared with the prior art, which requires additional codes or processing operations to switch frames and windows, the present application directly places the steps of switching frames and windows in the recording tool, eliminating additional operation steps. Users can directly switch frames and windows according to the recording tool, which is easy to operate, reduces human resources, and ensures that subsequent operations can be performed in the correct window.
[0127] Step 240: The recording tool sends the first information to the test platform. Correspondingly, the test platform receives the first information from the target device.
[0128] Since users use different target devices, the complexity of communication between the target device and the test platform is inconsistent. If a unified recording tool is used to communicate with the test platform, the communication process can be standardized to ensure compatibility and controllability. In addition, there is no need to build the target device environment. The recording tool can be used directly to capture user operations and generate standardized data, and the data can be transmitted to the test platform, thereby improving the efficiency and reliability of the test process.
[0129] Here, the recording tool can send the first information to the test platform through a preset communication protocol (such as HTTP protocol). If the recording tool is a UIRecorder tool, the first information can be sent to the test platform through the UIRecorder tool.
[0130] However, the UIRecorder tool has the following two problems when applied: 1. Communication limitation: The original UIRecorder tool can only realize communication between internal components, and cannot transmit the operation information captured by the browser plug-in to the external test platform, that is, the test platform cannot obtain and process the user's operation in the browser in real time, which limits the function and flexibility of the tool. 2. Coupling problem: The internal components of UIRecorder are highly coupled. This coupling design makes it difficult for the tool to adapt to different test environments and requirements, reducing its applicability and scalability in actual testing. Therefore, the browser plug-in of UIRecorder can be modified to ensure that it can seamlessly connect to the test platform.
[0131] Optionally, UIRecorder can be decoupled, that is, the UIRecorder plug-in function can be separated from the original tool to make it an independent module. In this way, UIRecorder no longer relies on a specific backend service, but communicates with the test platform through a standardized interface, and can realize direct data transmission from the recording tool to the test platform.
[0132] Optionally, the recording tool may encapsulate the first information into a JS object notation (JSON) format, and then send the encapsulated first information to the test platform.
[0133] Here, the recording tool can obtain the first information (including page element information and user operations, etc.), and encapsulate the first information into JOSN format, and directly call the application programming interface (API) interface provided by the test platform through the HTTP protocol to send the first information to the test platform.
[0134] Optionally, the recording tool may encapsulate the first information into a preset data format, that is, send the first information to the test platform in a data format including the operation type (such as click, input), the target element location, and the operation parameter (such as input text). In this way, the test platform can directly understand and process the information from the recording tool by using a standard data format.
[0135] In step 250, the test platform stores the first information in a first database.
[0136] Optionally, the test platform may convert the format of the first information according to a preset data structure, where the preset data structure is a data structure supported by the test platform. In this way, after converting the format of the first information, the test platform may directly process the first information.
[0137] Specifically, after the test platform receives the first information, it parses the first information and converts the first information into a data structure (keyword + parameter) supported by the test platform. For example, the click operation is converted into the "click" keyword and includes the location information of the target element.
[0138] Optionally, the conversion may be performed according to the operation type correspondence table in Table 1 below:
[0139] Recording Tool Operation Type Platform Keyword Method click Click sendKeys input_string url visit_url sleep Wait switchFrame switch_to_frame switchWindow switch_to_window … …
[0140] Table 1
[0141] It can be understood that Table 1 is only an example, showing the correspondence between some recording tool operation types and platform keyword methods, and does not show all the correspondences. In addition, the correspondences can be customized by users according to actual conditions and do not serve as a limitation to this application.
[0142] Optionally, the test platform can store the first information in the second database. If the test platform receives the recording end information from the recording tool, all the first information stored in the second database is stored in the first database, and the second database is cleared, wherein the first database is a permanent database, such as a Mysql database, and the second database is a temporary database, such as a remote dictionary server (redis) database. In this way, the test platform stores the first information after format conversion in the first database, which can be directly used in subsequent test cases, and the recorded test cases are structured and stored and uniformly managed for easy tracking and maintenance.
[0143] The test platform can periodically send requests to the target device or recording tool, and the recording tool returns the latest test step information (i.e., the first information). After receiving the first information, the test platform converts the first information and stores the converted first information in the second database. In this way, the test platform can read data through the second database and update the interface through the front end to display the operation steps currently being recorded. Afterwards, after the recording is completed, the test platform can clear the second database to release resources.
[0144] Specifically, the test platform can implement the real-time display and recording operation steps through the following steps (1) to (3):
[0145] (1) After the test platform backend receives the step information from the recording tool, it stores it in redis. It can be stored in a list format, using a globally unique recording ID (recordId) to store it in the variable key, and the step information in the variable value.
[0146] (2) The front end of the test platform uses a timer to periodically send requests to the back end application programming interface API to obtain the latest test step information, and displays the obtained step information on the interface in real time.
[0147] (3) The test platform uses the end flag (such as is_end) in the interface to determine whether the recording is finished. When the user clicks to end the recording in the recording tool, the recording tool generates a test step with a variable type of save and sends it to the test platform. When the test platform determines that the recording is finished, the backend deletes the corresponding Redis record and the frontend turns off the timer.
[0148] Through the above scheme, the test platform adopts a caching and polling mechanism to realize real-time updating of the operation steps being recorded by the recording tool, that is, the test platform obtains the latest test step information from the back end, and updates the interface in real time to display the operation steps currently being recorded. Compared with the prior art in which users cannot view the recorded operation steps in real time, which affects the debugging and confirmation during the test process, the present application can provide instant feedback to the operator to ensure the accuracy of the recording process, so that testers can see their operations being correctly captured in real time during the recording process, thereby improving the efficiency and accuracy of the test process. That is, if a problem is found, the operator can immediately adjust or re-record, instead of waiting until the entire process is over to discover the problem.
[0149] Optionally, the data in the first database may be used for assertion.
[0150] Here, through the above steps, the recording tool has recorded the user's interactive behavior, including operations such as mouse clicks, keyboard input, and the page elements that interact with them, and sent them to the test platform, that is, the test platform has obtained a complete test case. It is understandable that assertions are needed to verify the status of the program to ensure that the program runs as expected, that is, to check whether the output or behavior of the program meets the expected results.
[0151] Optionally, the recording tool can convert these operation behaviors into savable scripts. Each test case is encapsulated as an independent script file. When executing the test case, the tool will read these recorded script files and perform operations and assertion checks in a preset order.
[0152] Optionally, the recording tool can also store these operation behaviors in a database. In this way, compared with storing them in independent script files, storing the data in a database can make it easier to manage the data.
[0153] Optionally, the source of assertion methods can be unified, that is, when the recording tool is started, it dynamically obtains a list of all assertion methods on the test platform by calling the test platform API interface, directly uses these methods during the recording process, and stores the generated assertion information in a standardized format, and finally sends it to the test platform through an HTTP request to ensure that the assertion methods generated by the tool can be run directly on the platform without additional conversion.
[0154] Optionally, the recording tool may display the acquired assertion method list in the user interface for the user to select. When the user selects an assertion method and enters the required parameters, the recording tool generates standardized assertion information according to the assertion method selected by the user and the input parameters.
[0155] Optionally, the recorded use case data may be displayed to the user in the form of a page, and the user may operate the recorded use case data on the page, for example, copying a use case, deleting a use case, adding a use case, and so on.
[0156] Through the above scheme, it can be ensured that the assertion method generated by the recording tool can be directly run on the platform without the need for an additional conversion process. Compared with the prior art in which the assertion method of the original tool is incompatible with the assertion framework of the test platform, resulting in the generated test cases being unable to be directly used on the platform, the present application can achieve seamless connection between the recording tool and the test platform, thereby improving the efficiency and reliability of automated testing, and avoiding compatibility issues by unifying the assertion method, making the creation and execution of test cases smoother and more efficient.
[0157] Through the above steps 210 to 250, the interface element information of the first interface and the user's operations on the first interface can be obtained, so that the test case can be recorded. By automating the writing of test cases, the test efficiency can be improved, repetitive manual testing work can be reduced, and the test coverage can be increased to ensure that all key functions are verified. In addition, consistent test results can be provided to reduce test errors caused by human factors. In addition, the present application does not require any local environment to be built. The generation and execution of test cases are completed on the test platform to ensure consistency and convenience. Automated test cases can provide timely feedback on the quality status of the product and provide valuable information for the development team for rapid iteration and improvement.
[0158] A data processing method is introduced above, which can realize automatic recording of test cases. The method is illustrated by three specific examples below.
[0159] Example 1:
[0160] See also< / label> Figure 7 , a data processing flow chart is shown, which is used to realize the recording of test cases, and specifically, the following steps may be included:
[0161] Step 710: The recording tool obtains page element information and operation steps, and transmits them to the test platform.
[0162] Here, the recording tool installed by the user (such as a browser plug-in) will automatically capture all the user's operations on the web page (such as clicks, inputs, etc.) and related page element information. The recording tool generates operation steps based on this information and transmits these steps to the test platform.
[0163] See also Figure 8 , showing a schematic diagram of recording test cases. As can be seen from the figure, the recording tool records the test cases and transmits the recorded steps to the backend of the test platform, wherein the recording tool records the test cases including event monitoring, DOM capture, and generation steps.
[0164] Step 720: The backend of the test platform receives the operation steps and parses them, and temporarily stores the parsed data in the cache.
[0165] Continue reading Figure 8 After receiving the operation steps, the test platform parses the operation steps to obtain step information and stores it in redis.
[0166] Step 730: The front end of the test platform obtains the latest test step information from the back end by periodic polling.
[0167] Here, users can view the status and progress of the recording in real time. Figure 8 The backend of the test platform obtains step information by reading redis and displays the steps in real time on the front end.
[0168] Step 740: The test platform receives the instruction to end recording and stores the recorded test steps in the database.
[0169] Here, when the user clicks the "End Recording" button, the recording tool (such as a browser plug-in) sends an end command to the test platform. After receiving this command, the test platform stops the front-end polling operation and saves all recorded test steps. Figure 8 , the backend of the test platform stores data in Mysql.
[0170] It can be understood that the above steps 710 to 740 can refer to the above steps 210 to 250, which will not be described in detail here.
[0171] Through the above solution, user operations can be automatically captured without manually writing test scripts, which improves the efficiency of test case creation; at the same time, by displaying the recording status in real time, users can understand the recording progress at any time to ensure the completeness and accuracy of the test cases.
[0172] Example 2:
[0173] See also Fig. 9 , showing a schematic diagram of using a recording tool to record test cases for a page. The figure is a simplified schematic diagram of a network page, which includes a URL and other elements of the page (such as the login interface of the Iview visual reporting platform). When the recording tool starts to record test cases for the interface, the page will display "Chrome is being controlled by the automatic testing software" to remind the user that the case recording has started. There can be a recording window at the bottom of the page to display the path and attributes of the recorded element. For example, when the user clicks on an element on the page, the recording window displays the recording path as: div[@class='rightContent_3GeA4'], and displays the attributes of the element as: id, text, name, class.
[0174] See also Fig.10 , shows a schematic diagram of the interface of the recording tool for recording test cases. As can be seen from the figure, the page can display detailed recording information (such as the recorded URL, case details, user, etc.). After the recording tool records a test case, the test case will be displayed on the user page, for example, Fig.10 There are 5 test cases, each with a detailed description.
[0175] by Fig. 9 As an example, continue to refer to Fig. 9 , assuming that the first step when the user records the test case is to visit the URL, then the method of test step 1 is visit_url, and the value is the URL visited by the user. In this way, step 1 can be accessed according to the method and the corresponding value Fig. 9 The second step is to click the "Please enter your account number" box, then the method corresponding to test step 2 is click, and the corresponding page element is Loc = / / input[@id = 'usename'], which is the same as Fig. 9 The fourth step is for the user to enter the account number, so the method corresponding to test step 4 is Input_string, and the corresponding page element is Fig. 9 The "Please enter your account number" box has a value of A, that is, the user Fig. 9 Enter "A" in the "Please enter your account number" box.
[0176] Continue reading Fig.10 In this page, you can also set whether to execute the test case, as well as copy test cases, add test cases, delete test cases, etc. After the test case is recorded, you can also choose to debug or archive the test case. This makes it easier for users to operate, omits repeated steps, and allows users to quickly process test cases and improve efficiency.
[0177] Example 3:
[0178] See also Fig.11 , showing another data processing flow diagram for realizing the recording of test cases, specifically, the following steps may be included:
[0179] Step 1101: Download and install the recording tool UIRecorder.
[0180] Since the registry configuration required by the EXE program is added to the NSIS script, this step can achieve one-click installation of the recording tool.
[0181] Step 1102: Start the recording tool UIRecorder.
[0182] Since this solution packages the Python program into an executable file and integrates it into the operating system by writing a registry file, this step can use a simple front-end code to call the custom protocol to start the recording tool, thereby achieving one-click start.
[0183] Step 1103: The recording tool UIRecorder obtains interface element information of the first interface of the target device.
[0184] Here, referring to the above steps 610 to 660, the above solution can be implemented using HTML, and the HTML structure is as follows:
[0185]
[0186]
[0187] <div id="main">
[0188] <div class="container"id="test1">
[0189] < / button> <button type="submit"> Query< / button>
[0190]
[0191] <div class="container">
[0192] <div class="container"id="test2">
[0193] <button type="submit"> Query< / button>
[0194]
[0195]
[0196]
[0197]
[0198]
[0199] Here, taking a specific example, assume there are two "Query" buttons on a page. If you want to locate the second "Query" button, the following steps are required:
[0200] (a) Obtain the target node (button) and its text content ("Query").
[0201] (b) Generate an XPath using the text content: / / button[contains(text(),'Query')], and check whether this XPath is unique.
[0202] In this example, since there are two button nodes containing the text "Query", this XPath is not unique.
[0203] (c) Generate an XPath using an attribute, such as the type attribute: / / button[@type='submit'], and check whether this XPath is unique.
[0204] In this example, since there are two button nodes with the type attribute of submit, this XPath is also not unique.
[0205] (d) Obtain the position of the node in the parent node. Combining steps (b) and (c), finally generate a unique XPath: / / div[@id='test2'] / button[contains(text(),'Query')].
[0206] Through the above solution, by gradually refining and combining different positioning strategies, a unique and stable XPath expression is finally generated to accurately locate the target element, which is especially effective for dealing with complex page structures and dynamically changing Web applications.
[0207] Step 1104: The recording tool UIRecorder obtains the operations of the user on the first interface.
[0208] Here, this application integrates a series of low-level events into a single higher-level instruction, making the test steps more concise and accurate.
[0209] Step 1105: The recording tool UIRecorder records the frame / window information.
[0210] Referring to the above step 230, the function of step 1105 can be implemented by the following contents:
[0211] {
[0212] window:cmdInfo.window,
[0213] frame:cmdInfo.frame,
[0214] cmd:'switchFrame',
[0215] data:null
[0216] }
[0217] Step 1106: Decouple UIRecorder to enable communication between UIRecorder and the test platform.
[0218] It is understandable that step 1106 can be placed after step 1101, and the specific operation sequence is not limited.
[0219] Step 1107: UIRecorder encapsulates the first information into JOSN format and calls an API interface to send the first information to the test platform.
[0220] For example, when a user performs a click operation, the JOSN format is as follows:
[0221] 'stepInfo':{
[0222] 'type':'saveCmd', / / Value: saveCmd, save, save means the recording ends
[0223] 'data':{
[0224] 'cmd':'click', / / operation type
[0225] 'data':{
[0226] 'path':" / / input[@id='password']", / / element positioning
[0227] 'text':”, / / operation parameters
[0228] }
[0229] }
[0230] }
[0231] Step 1108: The test platform receives the first information and parses the first information to obtain information that the test platform can understand, so as to ensure that the recorded use case can be directly run on the platform after being saved.
[0232] For example, the first information in step 1107 is parsed:
[0233] {
[0234] "type":"test step", / / Value: test step, expected result (command is assertion)
[0235] "step_name":"click", / / step name
[0236] "method":"click", / / operation type
[0237] "pageObject":" / / input[@id='password']", / / element positioning
[0238] "value":"" / / operation parameters
[0239] }
[0240] Step 1109: The test platform views the operation steps recorded by the recording tool in real time.
[0241] Referring to the above step 250, the function of the ninth step can be implemented by the following contents:
[0242] API interface:
[0243] URL: / generalMsg / get_record_step
[0244] method:POST
[0245] Request format:
[0246] {
[0247] “recordId”:"06e42d65-4238-4020-84d2-2d242cf97229" / / recording id
[0248] }
[0249] Return format:
[0250] {
[0251] "data":[
[0252] {
[0253] "id":null,
[0254] "method":"visit_url",
[0255] "pageObject":null,
[0256] "step_name":"Visit URL",
[0257] "type":"Test Step",
[0258] "value":"http: / / fat-report.ppdaicorp.com"
[0259] },
[0260] {
[0261] "id":null,
[0262] "method":"click",
[0263] "pageObject":"loc= / / input[@id='username']",
[0264] "step_name":"Click",
[0265] "type":"Test Step",
[0266] "value":null
[0267] }
[0268] ],
[0269] "is_end":0, / / Recording end mark
[0270] "status":1
[0271] }
[0272] Step 1110: The test platform stores the first information in a database.
[0273] Step 1111: The recording tool dynamically obtains the assertion method list.
[0274] Here, referring to the above step 250, this step can be divided into two processes: (1) the recording tool obtains the API interface; (2) the recording tool calls the API. Specifically, the following content can be used to implement the function of step 1111:
[0275] (1) API interface:
[0276] URL: / generalMsg / auto_method_assert method:GET
[0277] Response format: JSON, example:
[0278] (2) Recording tool calls API:
[0279]
[0280]
[0281] Step 1112: The recording tool uses one of the assertion methods in step 11 to make an assertion.
[0282] Here, the recording tool displays a list of assertion methods obtained in the user interface for the user to select. After the user selects an assertion method, he enters the required parameters. Then the recording tool generates standardized assertion information based on the assertion method selected by the user and the input parameters.
[0283] Specifically, the following is an example of assertion information generated by the recording tool:
[0284]
[0285]
[0286] Step 1113: The test platform obtains assertion information.
[0287] Specifically, the following content can be used to implement the function of step 1113.
[0288]
[0289] Through the above scheme, the interface element information of the first interface and the user's operations on the first interface can be obtained, so that the test case recording can be realized. By automating the writing of test cases, the test efficiency can be improved, repetitive manual testing work can be reduced, and the test coverage can be increased to ensure that all key functions are verified. In addition, consistent test results can be provided and test errors caused by human factors can be reduced. In addition, automated test cases can provide timely feedback on the quality status of the product and provide valuable information for the development team for rapid iteration and improvement.
[0290] Based on the same concept, an embodiment of the present application also provides a data processing device, which can execute the data processing method introduced in the above content.
[0291] See also Fig.12, a schematic diagram of the structure of a data processing device provided in an embodiment of the present application is given, such as Fig.12 As shown, the data processing device includes:
[0292] A starting module 1201 is used to start a recording operation on a first interface of a target device;
[0293] The acquisition module 1202 is used to acquire interface element information of the first interface, where the interface element information includes position information of each element presented in the first interface;
[0294] A generating module 1203 is used to determine a target element corresponding to the operation in response to the user's operation on the first interface, and generate first information according to the position information of the target element, the operation type and the operation parameter of the operation;
[0295] The sending module 1204 is used to send the first information to the test platform.
[0296] In one possible implementation, the operation includes one or more of a single-click operation, a double-click operation, and an input text operation, wherein the single-click operation includes pressing the mouse and releasing the mouse, and the position difference between the mouse position when the mouse is pressed and the mouse position when the mouse is released is less than a preset threshold, the double-click operation includes a first single-click and a second single-click, and the position difference between the position when the first mouse click and the position when the second mouse click is within a preset range, and the input text operation includes continuously entering multiple characters.
[0297] In a possible implementation, the acquisition module 1202 is specifically used to: obtain the node attributes and text content of each element in the first interface, and for each element, perform the following operations: generate a first path based on the text content, and determine whether the first path is unique; if the first path is unique, use the first path as the location information of the element; if the first path is not unique, generate a second path based on the node attributes of the element, and determine whether the second path is unique; if the second path is unique, use the second path as the location information of the element; if the second path is not unique, obtain the parent node element of the element, generate a third path based on the text content of the parent node element, and\or, generate a fourth path based on the node attributes of the parent node element, and use the unique path in the third path or the fourth path as the location information of the element.
[0298] In a possible implementation, the target device includes a recording tool and an executable script, the executable script is used to start the recording tool, and the startup module 1201 is specifically used to: obtain startup information from the test platform, the startup information is used to start the executable script and start the recording tool according to the started executable script.
[0299] Based on the same concept, an embodiment of the present application also provides a data processing device, which can execute the data processing method introduced in the above content.
[0300] See also Fig.13 , a schematic diagram of the structure of another data processing device provided in an embodiment of the present application is given, such as Fig.13 As shown, the data processing device includes:
[0301] The receiving module 1301 is used to receive first information, wherein the first information is generated according to the location information of the target element, and the operation type and operation parameters of the user's operation on the target element, and the target element is an element on the first interface of the target device;
[0302] The storage module 1302 is used to store the first information in a first database.
[0303] In one possible implementation, the first information has a first format, which is a format supported by a recording tool. The storage module 1302 is also used to: convert the first information in the first format to obtain the first information in a second format, which is a format supported by a test platform.
[0304] In one possible implementation, the first database is a permanent database, and the storage module 1302 is specifically used to store the first information in the second database, which is a temporary database. If the recording end information is received, all the first information stored in the second database is stored in the first database, and the second database is cleared.
[0305] See also Fig.14 , showing a schematic diagram of the structure of another data processing device provided in an embodiment of the present application, such as Fig.14 As shown, the data processing device includes: a memory 1401 and a processor 1402, and the processor 1402 is coupled to the memory 1401. The memory 1401 is used to store program instructions, and the processor 1402 is used to call the program instructions stored in the memory 1401 and execute the above data processing method according to the obtained program.
[0306] Optionally, the data processing device may further include an interface circuit 1403, which may be a transceiver or an input / output interface. The input / output interface is used to input and / or output information, where output may be understood as sending and input may be understood as receiving. The processor 1402 may communicate with other devices in the data processing device or other devices other than the data processing device through the interface circuit 1403 to obtain information required for executing the above data processing method.
[0307] When the data processing device 1400 is used to implement Figure 2When the method shown is performed, the processor 1402 is used to implement the functions of the above-mentioned starting module 1201, obtaining module 1202, generating module 1203, and sending module 1204.
[0308] It is understandable that the processor in the embodiments of the present application may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.
[0309] The memory in the embodiments of the present application can be a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, a register, a hard disk, a mobile hard disk, a compact disc read-only memory (CD-ROM) or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. The storage medium can also be a component of the processor.
[0310] Based on the same technical concept, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program or instruction is stored. When the computer program or instruction is executed by a processor, the computer executes the above-mentioned data processing method.
[0311] Based on the same technical concept, an embodiment of the present invention further provides a computer-readable program product, which, when executed, enables a computer to execute the above data processing method.
[0312] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0313] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0314] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0315] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0316] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A data processing method, characterized in that: The method comprises: Initiate recording of the first interface of the target device; Acquire interface element information of the first interface, wherein the interface element information includes position information of each element presented in the first interface; In response to an operation of a user on the first interface, determining a target element corresponding to the operation, and generating first information according to position information of the target element, an operation type and an operation parameter of the operation; The first information is sent to the test platform.
2. The method according to claim 1, characterized in that The operation includes one or more of a single-click operation, a double-click operation, and a text input operation; The operation of clicking the mouse includes pressing the mouse and releasing the mouse, and the position difference between the mouse position when the mouse is pressed and the mouse position when the mouse is released is less than a preset threshold; The double-clicking operation includes a first click of the mouse and a second click of the mouse, and the position difference between the position when the first click of the mouse and the position when the second click of the mouse is within a preset range; The operation of inputting text includes continuously inputting a plurality of characters.
3. The method according to claim 1, characterized in that The acquiring interface element information of the first interface of the target device includes: Obtaining node attributes and text content of each element in the first interface; For each element, perform the following operations: generating a first path according to the text content, and determining whether the first path is unique; If the first path is unique, use the first path as the location information of the element; If the first path is not unique, generating a second path according to the node attributes of the element, and determining whether the second path is unique; If the second path is unique, use the second path as the location information of the element; If the second path is not unique, obtain the parent node element of the element, generate a third path according to the text content of the parent node element, and / or generate a fourth path according to the node attributes of the parent node element, and use the unique path in the third path or the fourth path as the location information of the element.
4. The method according to claim 1, characterized in that The target device includes a recording tool and an executable script, and the executable script is used to start the recording tool; The initiating a recording operation on the first interface of the target device includes: The startup information from the test platform is obtained, where the startup information is used to start the executable script and start the recording tool according to the started executable script.
5. A data processing method, characterized in that: The method comprises: receiving first information, where the first information is generated according to location information of a target element and an operation type and an operation parameter of a user's operation on the target element, where the target element is an element on a first interface of a target device; The first information is stored in a first database.
6. The method according to claim 5, characterized in that The first information has a first format, and the first format is a format supported by the recording tool; Before storing the first information in the first database, the method further includes: The first information in the first format is format-converted to obtain the first information in a second format, where the second format is a format supported by the test platform.
7. The method according to claim 5 or 6, characterized in that The first database is a permanent database; The storing the first information in a first database comprises: storing the first information in a second database, where the second database is a temporary database; If the recording end information is received, all the first information stored in the second database is stored in the first database, and the second database is cleared.
8. A data processing device, characterized in that: The device comprises: A starting module, used to start the recording operation of the first interface of the target device; An acquisition module, configured to acquire interface element information of the first interface, wherein the interface element information includes position information of each element presented in the first interface; A generating module, configured to determine, in response to an operation of a user on the first interface, a target element corresponding to the operation, and generate first information according to position information of the target element, an operation type and an operation parameter of the operation; A sending module is used to send the first information to the test platform.
9. A data processing device, characterized in that: The device comprises: A receiving module, configured to receive first information, wherein the first information is generated according to location information of a target element, and an operation type and an operation parameter of a user's operation on the target element, wherein the target element is an element on a first interface of a target device; A storage module is used to store the first information in a first database.
10. A data processing device, characterized in that: include: A processor, wherein the processor is coupled to a memory, the memory is used to store a computer program or an instruction, and the processor is used to execute the computer program or the instruction to implement the method according to any one of claims 1 to 7.
11. A computer-readable storage medium, characterized in that: It stores a computer program executable by a computer device, and when the program is run on the computer device, the computer device executes the steps of any method described in claims 1 to 7.
12. A computer program product, characterized in that When the method is executed on a computer, the computer is enabled to execute the method according to any one of claims 1 to 7.
Citation Information
Cited By
Page comparison detection method and computer program product
CN121301975A
Page comparison detection method and computer program product
CN121301975B
