UI test method and device, equipment and medium
By burying attributes of HTML elements of the test page, UI test cases including test behavior, operation sequence and expected results are generated, which solves the problems of inefficiency in existing UI testing methods and difficulty in maintaining automated test cases, and achieves efficient UI testing process.
Patent Information
- Application Number
- CN202411564176.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-14
AI Technical Summary
Existing UI testing methods are inefficient, manual testing is time-consuming and error-prone, while automated test cases are difficult to maintain and require frequent updates to deal with changes in UI pages.
By adding attribute burial points to HTML elements in the test page, a UI test case is generated, which includes test behavior, operation sequence and expected results, which are applied to the test scenario to obtain execution results and verify based on the results and expectations.
It realizes that without manually updating UI test cases, improves UI testing efficiency, ensures the stable operation of the test environment, and reduces the maintenance work of testers.
Smart Images

Figure CN119441050A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of testing technology, and in particular to a UI testing method, device, equipment and medium. Background Art
[0002] UI testing is a type of testing also known as user interface testing, through which the interface of the application is checked to see if it is working properly or if there are any loopholes that hinder the user behavior and do not meet the written specifications. It is essential to understand how the user will interact between the user and the website to perform UI testing, by performing UI testing, the tester will mimic the user's behavior to see how the user will interact with the program and see if the website is functioning as expected and if there are any defects.
[0003] In the related art, UI testing can be performed manually or automatically. Manual generation requires testers to manually perform each test on each element. For example, a test input field will require typing different values again and again for any differences. However, for complex websites and websites with rich user interfaces, manual testing is inefficient, time-consuming and error-prone. Automatic testing can be achieved through mature testing tools, but testing tools require the writing of automated test cases. If the UI page changes, the automated test cases need to be rewritten, otherwise they will fail, and the maintenance of automated test cases is more difficult. Summary of the invention
[0004] The present invention provides an artificial intelligence UI testing method, device, computer equipment and medium to solve the technical problems of low efficiency of manual testing and difficult maintenance of automated test cases.
[0005] In a first aspect, a UI testing method is provided, comprising:
[0006] Adding attribute tracking points to HTML elements in the test page to obtain HTML tracking point attribute data, wherein the test HTML element is an HTML element with attribute expression in the test page;
[0007] Generate a UI test case according to the HTML embedding attribute data, wherein the UI test case at least includes a test behavior, a test operation sequence, and a test expectation;
[0008] Apply the UI test case to the test scenario to obtain the execution result obtained after the test HTML element executes the test behavior according to the test operation sequence;
[0009] A UI test result is obtained according to the execution result and the test expectation.
[0010] In a second aspect, a UI testing device is provided, comprising:
[0011] A tracking module is used to add attribute tracking to the HTML element in the test page to obtain HTML tracking attribute data, wherein the test HTML element is an HTML element with attribute expression in the test page;
[0012] A generating module, used to generate a UI test case according to the HTML embedding attribute data, wherein the UI test case at least includes a test behavior, a test operation sequence, and a test expectation;
[0013] An application module, used for applying the UI test case to a test scenario to obtain an execution result obtained after the test HTML element executes the test behavior according to the test operation sequence;
[0014] The test module is used to obtain the UI test result according to the execution result and the test expectation.
[0015] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned UI testing method when executing the computer program.
[0016] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned UI testing method are implemented.
[0017] In the scheme implemented by the above-mentioned UI testing method, device, computer equipment and storage medium, attribute embedding points can be added to the HTML element in the test page through the client to obtain HTML embedding point attribute data, and the test HTML element is an HTML element with attribute expression in the test page; a UI test case is generated according to the HTML embedding point attribute data, and the UI test case at least includes a test behavior, a test operation sequence and a test expectation; the UI test case is applied to the test scenario to obtain the execution result obtained after the test HTML element executes the test behavior according to the test operation sequence; the UI test result is obtained according to the execution result and the test expectation, and the UI test result is fed back to the client. In the present invention, UI test cases are generated through HTML embedding point attribute data, so that the HTML test cases can be expressed through the personalized attribute data of the embedding points, so as to enrich the application scenarios of the UI test cases, and can ensure the stable operation of the UI test environment without the need to manually update the UI test cases, thereby improving the UI test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0019] Figure 1 is a schematic diagram of an application environment of a UI testing method in one embodiment of the present invention;
[0020] Figure 2 It is a flowchart of a UI testing method in one embodiment of the present invention;
[0021] Figure 3 is a flow chart of a UI testing method according to another embodiment of the present invention;
[0022] Figure 4 yes Figure 2 A schematic flow chart of a specific implementation of step S20;
[0023] Figure 5 yes Figure 2 A schematic flow chart of a specific implementation of step S30;
[0024] Figure 6 is a flowchart of a UI testing method in one embodiment of the present invention;
[0025] Figure 7 yes Figure 2 A schematic flow chart of a specific implementation of step S40;
[0026] Figure 8 is a structural schematic diagram of a UI testing device in one embodiment of the present invention;
[0027] Fig. 9 is a schematic diagram of a structure of a computer device in one embodiment of the present invention;
[0028] Fig.10 It is another structural schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0030] The UI testing method provided by the embodiment of the present invention can be applied in Figure 1 In the application environment, the client communicates with the server through the network. The server can add attribute points to the HTML elements in the test page through the client to obtain HTML point attribute data, and the test HTML element is an HTML element with attribute expression in the test page; generate a UI test case according to the HTML point attribute data, and the UI test case includes at least test behavior, test operation sequence and test expectation; apply the UI test case to the test scenario to obtain the execution result obtained after the test HTML element executes the test behavior according to the test operation sequence; according to the execution result and the test expectation, the UI test result is obtained, and the UI test result is fed back to the client. In the present invention, the UI test case is generated through the HTML point attribute data, so that the HTML test case can be expressed through the personalized attribute data of the point, so as to enrich the application scenario of the UI test case, and can ensure the stable operation of the UI test environment without manually updating the UI test case, saving the time of the tester to manually update the test case, and improving the UI test efficiency. Among them, the client can be but not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices. The server can be implemented with an independent server or a server cluster composed of multiple servers. The present invention is described in detail below through specific embodiments.
[0031] See also Figure 2 As shown, Figure 2 A flowchart of a UI testing method provided by an embodiment of the present invention includes the following steps:
[0032] S10: Add attribute tracking points to the HTML elements in the test page to obtain HTML tracking point attribute data.
[0033] The UI testing method provided by the present invention can be applied to front-end testing platforms in various application scenarios. Through UI testing, it can be tested whether the functional modules of the user interface are reasonably laid out, whether the overall style is consistent, and whether the placement of each control conforms to the available usage habits. In addition, the convenience of interface operation, simplicity of navigation, availability of page elements, correctness of the text in the interface, uniformity of naming, beauty of the page, and perfection of the combination of text and pictures can also be tested.
[0034] Among them, the test HTML element is an HTML element with attribute expression in the test page. In Web development, HTML page is the basic language for building web pages. As the basic building block of HTML page, HTML element defines the content and structure of the page. The syntax of HTML element consists of start tag, end tag and content. The start tag is used to specify the name of the element, the end tag is used to mark the end of the element, and the content is the text between the element tag or some HTML elements. Common HTML elements mainly include title elements, link elements, image elements, list elements, table elements, etc.
[0035] In this embodiment, taking into account the different test requirements, special code snippets can be inserted into the HTML code of the test page according to the test requirements to mark the HTML element attributes, so as to add attribute tracking points to the HTML elements in the test page. For example, special code snippets are inserted in the HTML code for clicking on the page, visiting the page, and the page dwell time. By adding attribute tracking points to the HTML elements in the test page, different test behaviors and test operation sequences can be expressed through the HTML tracking point attribute data, thereby enriching the test cases in the test scenario. For example, by adding the attribute tracking point of font color to the text box, the test behavior of font color change in the test scenario can be expressed through the font color. By adding the attribute tracking point of click to the button, the test behavior of click in the test scenario can be expressed through clicking the button.
[0036] It is important to understand that some attributes of the HTML elements in the test page are global attributes and can be applied to any HTML element, while some attributes are not global attributes and can only be applied to specific HTML elements. Figure 3 As shown, before step S10, that is, before adding attribute embedding points to the HTML elements in the test page and obtaining the HTML embedding point attribute data of the test page, the method further includes the following steps:
[0037] S50: Obtain the HTML structure corresponding to the test page.
[0038] S60: Selecting an HTML element with attribute expression in the test page as a test HTML element according to the unique element identifier.
[0039] The HTML structure includes HTML elements with association relationships. In the HTML structure, the HTML elements are connected to each other through various association methods, forming the basis of the web page structure. The association relationships here include but are not limited to parent-child relationships, sibling relationships, or descendant relationships.
[0040] Correspondingly, step S10, i.e., adding attribute embedding points to the HTML elements in the test page to obtain HTML embedding point attribute data of the test page, specifically includes the following steps S11-S12;
[0041] S11. Locate the structure code of the test HTML element in the HTML structure according to the unique element identifier.
[0042] S12. Utilize the association relationship between the HTML elements to perform attribute marking in the structure code of the test page to obtain HTML embedding attribute data of the test page.
[0043] For steps S11-S12, considering that the HTML elements in the structural code of the test page are bound with different attributes, in HTML, custom attributes can be used to associate HTML elements, and attribute marking is performed in the structural code of the test page according to the attribute association relationship. For example, in the structural code of the test page, the form element can display the association between the label element and the value of the form element ID through the display button, and the form element can be verified and associated when the form is submitted through the verification button. The data element itself will not be displayed on the page, but will be displayed on the page by using it in conjunction with the text box.
[0044] Specifically, the association relationship between HTML elements can be used to obtain the attribute types covered by the test HTML elements; for attribute types with operation associations, the operation-associated attributes are marked in the structural code of the test page according to the order of operation associations; for attribute types with syntax associations, the syntax-associated attributes are marked in the structural code of the test page according to the logic of syntax associations; for attribute types without associations, the attributes are marked in the structural code of the test page according to the attribute types of the test HTML elements.
[0045] It is understandable that the above attribute marking is based on the set identification information, usually the unique element identifier corresponding to the HTML element, and the attribute-marked HTML can be accurately identified. Only by accurately marking the HTML element with attributes can the virtual events created by the visual buying point be matched with the element, so as to accurately filter out the attribute changes triggered by the element. For example, based on the unique identifier of the "Add to Cart" button element, the "Add to Cart" button element on the product details page of the application can be uniquely located. The unique identifier will neither match the "Buy Now" button nor the "Add to Cart" button on the product list or other pages.
[0046] S20: Generate a UI test case according to the HTML embedding attribute data.
[0047] Among them, UI test cases at least include test behavior, test operation sequence and test expectation. It can be understood that adding attribute tracking to HTML elements in the test page is equivalent to adding corresponding attribute tags to HTML element attributes. The element attributes of the tag can be used in UI test cases, including but not limited to the following aspects:
[0048] 1. uitest-action: string; string, consisting of values such as 'click' and 'hover', simulating test behaviors such as mouse and keyboard.
[0049] 2. uitest-step: number; the number indicates the execution step number. The order of execution is distinguished by the size of the step.
[0050] 3. uitest-expect: string; expected result, the expected result after executing the step. If it does not meet the expected value, the test fails. If it meets the expected result, execute the next step.
[0051] 4. uitest-id: string; string, unique test UUID, through which you can find the page element corresponding to the UUID in the real HTML page.
[0052] It should be noted that the HTML tracking attribute data can record the HTML element, attribute value, trigger condition and other information of each tracking point, which can provide additional information or behavior for UI test cases. For example, the test needs to add a link to navigate to another page, or add an ID to use scripts to operate elements. At this time, you can add attributes directly to the HTML element, or dynamically add attributes through scripts. Figure 4 As shown, in step S20, that is, generating a UI test case according to the HTML embedding attribute data, specifically includes the following steps S21-S22;
[0053] S21. Locate the target structure code with attribute index in the structure code of the test page according to the HTML embedding attribute data.
[0054] S22. Under the attribute indexing of the target structure code, use the test behavior, test operation sequence and test expectation to describe the corresponding attribute expression of the test HTML element to generate a UI test case.
[0055] In this embodiment, for each HTML element with a tracking point, the process of creating a UI test case is used to verify the accessibility, visibility and functionality of the HTML element. For example, if there is a button with a tracking point attribute, it can be tested whether the button can be clicked normally and whether the correct text and style are displayed.
[0056] In actual application scenarios, HTML embedding attribute data is usually marked in the HTML template or component of the project. First, clarify the technology stack and packaging tools used by the project. Different technology stacks and packaging tools have different ideas. Then identify HTML embedding attribute data in the HTML template of the project to find HTML elements with custom data attributes, determine the purpose and expected behavior of the custom attributes, and finally extract the custom data attributes during the packaging process, and generate corresponding UI test cases based on the extracted custom data attributes.
[0057] Taking into account the differences in HTML embedding attributes, when locating the target structure code with attribute indexing in the structure code of the test page, the attributes with different test significances for UI testing can be determined by analyzing the HTML embedding attributes, and the target structure code with corresponding attribute indexing can be located in the structure code of the test page according to the test significance of the attributes. Further, under the attribute indexing of the target structure code, the test behavior is determined. For example, if the attribute indexing represents a click event, the test behavior can be to click the element and verify whether the corresponding operation occurs, and then determine the order of the test operations to simulate the user's interaction on the page. For example, if a form submission is tested, the form fields need to be filled in first, and then the submit button is clicked. Finally, the expected result of the test is described. For example, if clicking a button should navigate to another page, then the test expectation is that after clicking the button, the page should successfully navigate to the specified page.
[0058] S30: Apply the UI test case to the test scenario to obtain the execution result obtained after the test HTML element executes the test behavior according to the test operation sequence.
[0059] In this embodiment, applying the UI test case to the test scenario requires determining the test environment to determine which browsers, operating systems, and devices the test is performed on, ensuring that the test environment is as similar as possible to the environment used by actual users. Then, the test steps are executed one by one according to the test operation sequence in the test case.
[0060] Exemplarily, the test operation may include the following operations: input data, enter test data in input boxes, drop-down menus and other elements, click buttons, simulate users clicking buttons, links and other elements, verify results, check whether the elements on the page display the correct content and whether the status is as expected, wait for the page to load, and after performing certain operations, wait for the page to load to complete, to ensure the correctness of subsequent operations.
[0061] It is understandable that in some special scenarios, the testing process may encounter various abnormal situations, such as page loading failure, element not found, error message, etc. These abnormal situations need to be handled in a timely manner to ensure the accuracy and stability of the test.
[0062] It should be noted that UI test cases need to be applied to the test scenario and expressed in the test scenario through HTML embedding attribute data, such as Figure 5 As shown, in S30, the UI test case is applied to the test scenario to obtain the execution result obtained after the test HTML element executes the test behavior according to the test operation sequence, which specifically includes the following steps S31-S33;
[0063] S31. Apply the UI test case to a test scenario. If a measured HTML element in the test scenario exists in the UI test case, retrieve the measured HTML element to obtain an attribute added to the measured HTML element.
[0064] S32. According to the attribute added to the measured HTML element, execute the test behavior on the measured HTML element in a test operation sequence to obtain an execution result.
[0065] S33: Generate a UI test result of successful testing according to the execution result.
[0066] Specifically, after applying the UI test case to the test scenario, first check the page status to detect whether the page status meets the test expectations. This can include checking the page title, URL, display content, etc. Then check the HTML element attributes and status. For the tested HTML elements, verify whether their attributes and status meet expectations. For example, check whether the button becomes disabled after being clicked, whether the value in the input box is correct, etc. Then check the logs and error information, check the logs and error information generated by the test framework to determine whether any abnormal situations have occurred. If there is an error, analyze the cause of the error and fix it. Finally, collect and record the results. Collect and record the test execution results for subsequent analysis and reporting. Here you can use the report function provided by the test framework, or save the results to a file.
[0067] It is understandable that, for the analysis of the test execution results, the UI test results of successful tests and the UI test results of failed tests can be determined. If the measured HTML element in the test scenario exists in the UI test case, and the attribute added to the measured HTML element is retrieved, a UI test result of successful test is generated. Correspondingly, if the measured HTML element in the test scenario does not exist in the UI test case, or the measured HTML element in the test scenario exists in the UI test case but the attribute added to the measured HTML element cannot be retrieved, a UI test result of failed test is generated.
[0068] It should be noted that during the test, there will be repeated retrieval and testing behaviors. Specifically, you can determine whether there is a next test behavior by retrieving whether the current tested HTML element is in a specific attribute or state. For example, you can check whether an element has a specific class name, data attribute, or is in a specific state (such as visible, interactive, etc.).
[0069] Correspondingly, if the measured HTML element has a next test behavior, the step of retrieving the measured HTML element is repeated to obtain the attribute added to the measured HTML element with the associated test behavior, and the test behavior is performed on the corresponding measured HTML element.
[0070] Specifically, the measured HTML element attributes can be obtained. Once the measured HTML element with the associated test behavior is found, its attribute value can be obtained using the method provided by the script or test framework. According to the needs, various attributes of the element can be obtained, such as class name, text content, etc. Then the test behavior is executed. According to the obtained attribute value and test requirements, the corresponding test behavior is executed on the measured HTML element, which may include operations such as clicking, inputting, and verifying attribute values.
[0071] In actual application scenarios, such as Figure 6 As shown, first initialize the data set, provide the corresponding data set to the test resource, then open the test page, and then determine whether the measured HTML element in the test page exists in the UI test instance. If so, retrieve the measured HTML element, obtain the attribute added by the measured HTML element, perform operations according to the attribute added by the measured HTML element, and obtain the corresponding test resource from the data set to determine whether the HTML test element has a next step. If so, retrieve the measured HTML element again. Otherwise, complete the test of the HTML element and generate a UI test result of a successful test. If the measured HTML element is not retrieved, generate a UI test result of a failed test.
[0072] S40: Obtaining a UI test result according to the execution result and the test expectation.
[0073] In this embodiment, by summarizing the UI test results of all test cases, a corresponding UI test report can be generated, which includes information such as the total number of test cases, the number of passed test cases, the number of failed test cases, and the reasons for failure. For ease of understanding, the test report can be presented in the form of a table, a chart, or text, and provides detailed information for each failed UI test case, including a description of the UI test case, execution steps, expected results, actual results, and reasons for failure.
[0074] It should be noted that the UI test results include test success and test failure. Figure 7 As shown, in S40, that is, according to the execution result and the test expectation, a UI test result is obtained, which specifically includes the following steps S41-S42;
[0075] S41, comparing the execution result with the test expectation.
[0076] S42: If the test result meets the test expectation, generate a UI test result indicating a successful test.
[0077] Correspondingly, S42, if the test result does not meet the test expectation, a UI test result of test failure is generated.
[0078] In this embodiment, based on the comparison results, it can be determined whether each UI test case passes or fails. If the execution result is completely consistent with the test expectation, the test case passes; if there is a difference, the test case fails. When judging the test results, some boundary conditions and fault tolerance should be considered. For example, some differences may be caused by browser compatibility issues or network delays, and these differences can be tolerated to a certain extent.
[0079] It is understandable that for failed UI test cases, detailed failure reasons may be recorded, which may include but are not limited to page element not found, incorrect attribute value, interaction behavior not triggered, data display error, etc.
[0080] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0081] In one embodiment, a UI testing device is provided, which corresponds one-to-one to the UI testing method in the above embodiment. Figure 8 As shown, the UI testing device includes a tracking module 101, a generating module 102, an acquiring module 103 and a testing module 104. The functional modules are described in detail as follows:
[0082] The tracking module 101 is used to add attribute tracking to the HTML element in the test page to obtain HTML tracking attribute data, wherein the test HTML element is an HTML element with attribute expression in the test page;
[0083] A generating module 102, configured to generate a UI test case according to the HTML embedding attribute data, wherein the UI test case at least includes a test behavior, a test operation sequence, and a test expectation;
[0084] An application module 103 is used to apply the UI test case to a test scenario to obtain an execution result obtained after the test HTML element executes the test behavior according to the test operation sequence;
[0085] The testing module 104 is used to obtain a UI test result according to the execution result and the test expectation.
[0086] In one embodiment, the device further comprises:
[0087] An acquisition module, used for acquiring an HTML structure corresponding to the test page before adding attribute embedding points to the HTML elements in the test page to obtain the HTML embedding point attribute data of the test page, wherein the HTML structure includes HTML elements with associated relationships, and each HTML element has a unique element identifier;
[0088] A selection module, used for selecting an HTML element with attribute expression in a test page as a test HTML element according to the unique element identifier;
[0089] Accordingly, the tracking point module 101 is specifically used for:
[0090] Locating the structure code of the test HTML element in the HTML structure according to the unique element identifier;
[0091] Utilize the association between the HTML elements to perform attribute marking in the structure code of the test page to obtain the HTML embedding attribute data of the test page
[0092] In one embodiment, the tracking module 101 is further used for:
[0093] Utilizing the association relationship between the HTML elements, obtaining the attribute type covered by the test HTML element;
[0094] For the attribute type with operation association, the attribute marking of the operation association is performed in the structure code of the test page according to the order of the operation association;
[0095] For the attribute type with grammatical association, the attribute marking of the grammatical association is performed in the structure code of the test page according to the logic of the grammatical association;
[0096] For attribute types that have no association, attribute marking is performed in the structure code of the test page according to the attribute type of the test HTML element.
[0097] In one embodiment, the generating module 102 is specifically configured to:
[0098] According to the HTML embedding attribute data, locate the target structure code with attribute index in the structure code of the test page;
[0099] Under the attribute indexing of the target structure code, the corresponding attribute expressions of the test HTML elements are described using test behaviors, test operation sequences and test expectations to generate UI test cases.
[0100] In one embodiment, the application module 103 is specifically used for:
[0101] Applying the UI test case to the test scenario, and if the measured HTML element in the test scenario exists in the UI test case, retrieving the measured HTML element to obtain the attribute added to the measured HTML element;
[0102] According to the attributes added to the measured HTML element, executing the test behavior on the measured HTML element in a test operation sequence to obtain an execution result;
[0103] Generate a UI test result of successful testing according to the execution result;
[0104] Accordingly, the generating module is further used for:
[0105] If the measured HTML element in the test scenario does not exist in the UI test case, or the measured HTML element in the test scenario exists in the UI test case but the attribute added to the measured HTML element cannot be retrieved, a UI test result of test failure is generated.
[0106] In one embodiment, the device is further used for:
[0107] A retrieval module is used to, after performing a test behavior on the HTML element in the measured scenario according to the retrieved attributes to obtain a test resource from a pre-configured data set, if the measured HTML element has a next test behavior, repeatedly perform the retrieval of the measured HTML element to obtain the attribute added to the measured HTML element with the associated test behavior, and perform the test behavior on the corresponding measured HTML element.
[0108] In one embodiment, the test module is specifically used to:
[0109] comparing the execution result with the test expectation;
[0110] If the test result meets the test expectation, a UI test result indicating a successful test is generated;
[0111] If the test result does not meet the test expectation, a UI test result of test failure is generated.
[0112] The present invention provides a UI testing device, which generates UI test cases through HTML embedding attribute data, so that the HTML test cases can be expressed through the personalized attribute data of the embedding points to enrich the application scenarios of the UI test cases. While ensuring the stable operation of the UI testing environment, there is no need to manually update the UI test cases, thereby improving the UI testing efficiency.
[0113] For the specific definition of the UI testing device, please refer to the definition of the intelligent question and answer method above, which will not be repeated here. Each module in the above-mentioned UI testing device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0114] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, it implements a function or step on the server side of a UI testing method.
[0115] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Fig.10As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps on the client side of a UI testing method
[0116] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0117] Adding attribute tracking points to HTML elements in the test page to obtain HTML tracking point attribute data, wherein the test HTML element is an HTML element with attribute expression in the test page;
[0118] Generate a UI test case according to the HTML embedding attribute data, wherein the UI test case at least includes a test behavior, a test operation sequence, and a test expectation;
[0119] Apply the UI test case to the test scenario to obtain the execution result obtained after the test HTML element executes the test behavior according to the test operation sequence;
[0120] According to the execution result and the test expectation, a UI test result is obtained. In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0121] Adding attribute tracking points to HTML elements in the test page to obtain HTML tracking point attribute data, wherein the test HTML element is an HTML element with attribute expression in the test page;
[0122] Generate a UI test case according to the HTML embedding attribute data, wherein the UI test case at least includes a test behavior, a test operation sequence, and a test expectation;
[0123] Apply the UI test case to the test scenario to obtain the execution result obtained after the test HTML element executes the test behavior according to the test operation sequence;
[0124] A UI test result is obtained according to the execution result and the test expectation.
[0125] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant descriptions on the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0126] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0127] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0128] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A UI testing method, characterized in that: include: Adding attribute tracking points to HTML elements in the test page to obtain HTML tracking point attribute data, wherein the test HTML element is an HTML element with attribute expression in the test page; Generate a UI test case according to the HTML embedding attribute data, wherein the UI test case at least includes a test behavior, a test operation sequence, and a test expectation; Apply the UI test case to the test scenario to obtain the execution result obtained after the test HTML element executes the test behavior according to the test operation sequence; A UI test result is obtained according to the execution result and the test expectation.
2. The UI testing method according to claim 1, characterized in that: Before adding attribute embedding points to HTML elements in the test page to obtain HTML embedding point attribute data of the test page, the method includes: Obtaining an HTML structure corresponding to a test page, wherein the HTML structure includes HTML elements with associated relationships, and each HTML element has a unique element identifier; Selecting an HTML element with attribute expression in the test page as a test HTML element according to the unique element identifier; Correspondingly, adding attribute embedding points to the HTML elements in the test page to obtain HTML embedding point attribute data of the test page includes: Locating the structure code of the test HTML element in the HTML structure according to the unique element identifier; The association relationship between the HTML elements is used to perform attribute marking in the structural code of the test page to obtain HTML embedding attribute data of the test page.
3. The UI testing method according to claim 2, characterized in that: The method of using the association relationship between the HTML elements to perform attribute marking in the structure code of the test page to obtain HTML embedding attribute data of the test page includes: Utilizing the association relationship between the HTML elements, obtaining the attribute type covered by the test HTML element; For the attribute type with operation association, the attribute marking of the operation association is performed in the structure code of the test page according to the order of the operation association; For the attribute type with grammatical association, the attribute marking of the grammatical association is performed in the structure code of the test page according to the logic of the grammatical association; For attribute types that have no association, attribute marking is performed in the structure code of the test page according to the attribute type of the test HTML element.
4. The UI testing method according to claim 1, characterized in that: Generating a UI test case according to the HTML embedding attribute data includes: According to the HTML embedding attribute data, locate the target structure code with attribute index in the structure code of the test page; Under the attribute indexing of the target structure code, the corresponding attribute expressions of the test HTML elements are described using test behaviors, test operation sequences and test expectations to generate UI test cases.
5. The UI testing method according to claim 1, characterized in that: The applying the UI test case to the test scenario to obtain the execution result obtained after the test HTML element executes the test behavior according to the test operation sequence, includes: Applying the UI test case to the test scenario, and if the measured HTML element in the test scenario exists in the UI test case, retrieving the measured HTML element to obtain the attribute added to the measured HTML element; According to the attributes added to the measured HTML element, executing the test behavior on the measured HTML element in a test operation sequence to obtain an execution result; Generate a UI test result of successful testing according to the execution result; Correspondingly, if the measured HTML element in the test scenario does not exist in the UI test case, or the measured HTML element in the test scenario exists in the UI test case but the attribute added to the measured HTML element cannot be retrieved, a UI test result of test failure is generated.
6. The UI testing method according to claim 5, characterized in that: After executing the test behavior on the HTML element in the measured scene according to the retrieved attribute to obtain the test resource from the pre-configured data set, the method further includes: If the measured HTML element has a next test behavior, the measured HTML element is retrieved repeatedly to obtain the attribute added to the measured HTML element with the associated test behavior, and the test behavior is executed on the corresponding measured HTML element.
7. The UI testing method according to any one of claims 1 to 6, characterized in that: Obtaining a UI test result according to the execution result and the test expectation includes: comparing the execution result with the test expectation; If the test result meets the test expectation, a UI test result indicating a successful test is generated; If the test result does not meet the test expectation, a UI test result of test failure is generated.
8. A UI testing device, characterized in that: include: A tracking module is used to add attribute tracking to the HTML element in the test page to obtain HTML tracking attribute data, wherein the test HTML element is an HTML element with attribute expression in the test page; A generating module, used to generate a UI test case according to the HTML embedding attribute data, wherein the UI test case at least includes a test behavior, a test operation sequence, and a test expectation; An application module, used for applying the UI test case to a test scenario to obtain an execution result obtained after the test HTML element executes the test behavior according to the test operation sequence; The test module is used to obtain the UI test result according to the execution result and the test expectation.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the UI testing method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the UI testing method according to any one of claims 1 to 7 are implemented.