Html document processing method and device, and html element positioning method
By generating standard attribute values and adding retrieval attributes, the problem of low test case efficiency caused by changes in HTML element attribute values in UI automated testing is solved, and efficient reuse and accurate location of test cases are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU PINWEI SOFTWARE CO LTD
- Filing Date
- 2022-08-11
- Publication Date
- 2026-07-03
AI Technical Summary
In UI automation testing, changes in the attribute values of HTML elements lead to low efficiency in writing test cases and require frequent modifications to the location code.
By generating standard attribute values that reflect the relative relationships between target elements and adding retrieval attributes, the element selector of the automated testing framework is used for positioning, ensuring the reusability and accuracy of test cases.
It reduces repetitive work in test case writing, improves the efficiency and reusability of test case writing, and ensures that the target element can still be accurately captured when the element attributes change.
Smart Images

Figure CN115269433B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technology, and in particular to an HTML document processing method, apparatus, HTML element positioning method, computer device, and storage medium. Background Technology
[0002] In the practice of implementing UI (User Interface) automated testing for web applications based on a browser / server architecture, it is necessary to capture HTML (Hypertext Markup Language) elements of the UI interface. Before capturing, the HTML elements need to be located. Traditional techniques typically rely on the value of a specific attribute of an element. However, the attribute value of the same element can change depending on the content presented on the same UI interface. Therefore, when writing test cases, the code related to locating these elements needs to be modified, resulting in a significant amount of repetitive work and extremely low test case writing efficiency. Summary of the Invention
[0003] The purpose of this application is to address at least one of the aforementioned technical deficiencies, particularly the low efficiency of test case writing in the prior art.
[0004] In a first aspect, embodiments of this application provide an HTML document processing method, including:
[0005] Obtain the document to be processed, which is the HTML document of the page to be tested;
[0006] Multiple target elements are identified from all elements in the document to be processed; each target element includes at least one target attribute, and target attributes with the same attribute name in different target elements conform to a preset rule.
[0007] Generate standard attribute values corresponding to the target elements; the standard attribute values reflect the relative relationships between the target elements.
[0008] Add a search attribute to the target element to obtain the target document; the attribute name of the search attribute is the string that the element selector of the automated testing framework supports searching for, and the attribute value of the search attribute is the standard attribute value corresponding to the target element.
[0009] In one embodiment, generating standard attribute values corresponding to the target element includes:
[0010] Determine the position of the target element in the list;
[0011] Generate standard attribute values corresponding to the target element based on its position in the list.
[0012] In one embodiment, the attribute value of the target attribute includes a prefix value and a change value. The prefix value of the target attribute is the same as the preset prefix value, and the change value of the target attribute corresponds one-to-one with the target element.
[0013] Identify multiple target elements among all elements in the document to be processed, including:
[0014] For any element in the document to be processed, determine whether the attribute values of each attribute within that element contain a preset prefix value. If so, then use that element as the target element.
[0015] In one embodiment, the change in the target attribute reflects the position of the target element in the list, and standard attribute values corresponding to the target element are generated, including:
[0016] The prefix value is removed from the attribute value of the target attribute based on the preset prefix value to obtain the change value of the target attribute;
[0017] The change values of the target attribute are simplified, and the standard attribute value is obtained based on the simplification result.
[0018] In one embodiment, retrieval attributes are added to the target element, including:
[0019] Determine the automation testing framework to use for UI automation testing;
[0020] Use the strings that the element selector of the automated testing framework supports searching as standard attribute names;
[0021] Add a search attribute to the target element, with the attribute name being the standard attribute name and the attribute value being the standard attribute value.
[0022] In one embodiment, the automated testing framework includes Cypress.
[0023] Secondly, embodiments of this application provide a method for locating HTML elements, including:
[0024] Obtain the target document; the target document is obtained by processing the HTML document processing method in any of the above embodiments;
[0025] Based on the attribute name of the search attribute, the element selector of the automated testing framework is used to locate the element with the search attribute in the target document.
[0026] Thirdly, embodiments of this application provide an HTML document processing apparatus, including:
[0027] The document acquisition module is used to acquire the document to be processed, which is the HTML document of the page to be tested.
[0028] The target element determination module is used to identify multiple target elements among all elements in the document to be processed; each target element includes at least one target attribute, and target attributes with the same attribute name in different target elements conform to a preset rule;
[0029] The standard attribute value generation module is used to generate standard attribute values corresponding to the target elements; the standard attribute values reflect the relative relationships between the target elements.
[0030] The target document generation module is used to add search attributes to target elements to obtain the target document. The attribute name of the search attribute is the string that the element selector of the automated testing framework supports searching for, and the attribute value of the search attribute is the standard attribute value corresponding to the target element.
[0031] Fourthly, embodiments of this application provide a storage medium, characterized in that: the storage medium stores computer-readable instructions, which, when executed by one or more processors, cause one or more processors to perform the steps of the HTML document processing method or HTML element positioning method in any of the above embodiments.
[0032] Fifthly, embodiments of this application provide a computer device, including: one or more processors, and a memory;
[0033] The memory stores computer-readable instructions, which, when executed by one or more processors, perform the steps of the HTML document processing method or HTML element location method in any of the above embodiments.
[0034] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0035] Based on any of the above embodiments, multiple target elements are determined from all elements in the document to be processed according to whether the elements in the document have target attributes. Retrieval attributes are added to these target elements. If any target element needs to be retrieved in a test case, it can be based on the retrieval attributes. The attribute names of the retrieval attributes are adapted to the element selector, ensuring accurate positioning. Since the retrieval attributes reflect the relative relationships between target elements, even if the target attributes of a target element change, the same test cases can still accurately retrieve the required target element, ensuring good reusability of the test cases. This greatly reduces repetitive work when writing test cases and improves the efficiency of test case writing. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 A flowchart illustrating an HTML document processing method provided in one embodiment of this application;
[0038] Figure 2 This is a schematic diagram of the process for generating standard attribute values in one embodiment of this application;
[0039] Figure 3a This is a schematic diagram of an unprocessed HTML document in one embodiment of this application;
[0040] Figure 3b This is a schematic diagram of an HTML document obtained by the HTML document processing method in one embodiment of this application;
[0041] Figure 4 This is a schematic diagram of the process for generating standard attribute values in another embodiment of this application;
[0042] Figure 5 This is a flowchart illustrating the HTML element positioning process in one embodiment of this application. Detailed Implementation
[0043] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0044] Firstly, embodiments of this application provide an HTML document processing method, please refer to... Figure 1 This includes steps S102 to S108.
[0045] S102, Obtain the document to be processed, which is the HTML document of the page to be tested.
[0046] The page to be tested is any page in a web application that needs to be automated for testing. HTML is a language for creating web page files, which uses tag-based instructions to display content such as images, sounds, pictures, text animations, and videos.
[0047] S104, Identify multiple target elements among all elements of the document to be processed.
[0048] A target element includes at least one target attribute, and target attributes with the same attribute name in different target elements conform to a preset rule.
[0049] It's understandable that each HTML document contains multiple HTML elements. These elements may have different functions, including but not limited to input boxes, buttons, radio buttons, checkboxes, dropdown lists, two-dimensional lists, tree lists, and various field data. To simulate user actions on the UI, it's necessary to capture the HTML elements corresponding to each action. Each HTML element includes one or more attributes. These attributes can provide additional information about the HTML element or configure its functionality, and each attribute exists as a key-value pair: attribute name and attribute value. The elements of the document can be analyzed by parsing the document and building a DOM (Document Object Model) tree.
[0050] For example, taking the `body` element, which is used to configure the main content of the page, setting the `style` attribute to `background-color:grey` will set the page's background color to black. Similarly, taking the `input` element, which is used to collect input information on the page, will also work. <input type=""text”name="txtName”"> By setting the attribute name "type" to "text", an input box that allows users to enter content can be set on the page. Conversely, by setting the attribute name "name" to "txtID", the element can be easily identified. This demonstrates that attributes with the same name function identically.
[0051] When writing test cases, instructions for locating and fetching elements are included. These instructions are based on the attribute names and values of elements. The content of a given test page may change, meaning there's a one-to-one correspondence between some HTML element attribute values and their displayed content. However, to accurately retrieve the corresponding element, it's sometimes necessary to use this correspondence to pinpoint it. In other words, there's a one-to-one correspondence between the target attribute value and the target element's displayed content. The target attribute value reflects the absolute characteristics of the target element, and locating and fetching target elements with target attributes often requires utilizing the target attribute values.
[0052] The above situation necessitates writing corresponding test cases when presenting different content on the same test page. This means modifying the parameters in the element location and fetching instructions within the test cases based on changes in the attribute values of certain elements, resulting in poor test case reusability. For example, when simulating a user's shopping action on a shopping interface, such as clicking the nth item in the product list, it's necessary to fetch the element corresponding to that nth item. However, the nth item in the product list may differ between two different moments; for instance, it might be a hairdryer from brand A in the first moment and toothpaste from brand B in the second. This will cause some attribute values of the corresponding element to change, thus requiring modifications to the element location and fetching instructions in the test cases.
[0053] Therefore, if it is necessary to capture target elements based on target attributes, the changing patterns of target attributes can be summarized to derive preset rules. When a document to be processed is obtained, it is determined whether an element is a target element by judging whether different elements have at least one attribute with the same attribute name and attribute value that conforms to the preset rules. The target element is the object to be optimized in this embodiment to solve the problem of poor reusability. The purpose of optimization is to ensure that even if the target attributes of the target element change, the test cases do not need to be changed.
[0054] S106 generates standard attribute values corresponding to the target elements; the standard attribute values reflect the relative relationships between the target elements.
[0055] It is understandable that there is a one-to-one correspondence between the attribute value of the target attribute and the content presented by the target element, that is, the attribute value of the target attribute reflects the absolute characteristics of the target element. However, when performing UI automation testing, only the relative relationships between target elements can be considered.
[0056] For example, let's take simulating a user's shopping action on a shopping interface. All items in the product list are target elements. To simulate clicking the nth item in the list, we need to select one from multiple target elements. Traditionally, this would require first determining the attribute value of the target attribute for a hair dryer (brand A) to pinpoint the specific target element. Then, the test case would need to be modified to match the attribute value of the target attribute for toothpaste (brand B) to lock onto the specific target element. However, the exact nth item in the product list doesn't affect the test's effectiveness. Since the relative relationships between items in the list remain constant, using the item's position in the list as the basis for positioning allows us to reuse the same test case even when the items in the list change.
[0057] Therefore, to achieve the above optimization objectives, a one-to-one standard attribute value is generated for each target element. Based on the standard attribute value corresponding to each target element, a retrieval attribute with the standard attribute value is added to each target element. The retrieval attribute reflects the relative relationship between target elements, and therefore remains unchanged when the target attributes of the target elements change. Based on the relative relationship between the target elements, this ensures that the required target element can be selected from multiple target elements, and also guarantees the reusability of test cases.
[0058] S108, add search attributes to the target element to obtain the target document.
[0059] The attribute name of the search attribute is the string that the element selector of the automated testing framework supports searching for, and the attribute value of the search attribute is the standard attribute value corresponding to the target element.
[0060] It's understandable that UI automation testing can be performed by running test cases within a pre-defined automation testing framework. Common frameworks include Selenium and Cypress. These frameworks are configured with element selectors that can locate elements based on specific strings. To speed up processing within the pre-defined framework, the attribute name for the search property is set to a string supported by the element selector. When writing test cases, the relevant instructions to call the element selector can be directly written, enabling rapid location of elements.
[0061] Specifically, for each target element, since the element selectors of each automated testing framework support different search strings, the first step is to determine the automated testing framework used for UI automation testing. The string supported by the element selector of the automated testing framework is used as the standard attribute name. A search attribute is added to the target element, with the attribute name being the standard attribute name and the attribute value being the standard attribute value corresponding to that target element. Taking the Cypress framework as an example, after determining that the test is being conducted under the Cypress framework, its proprietary element selector supports element location for attributes with the names "data-cy", "data-test", or "data-testid", from which one can be selected as the attribute name for the search attribute. If "data-cy" is selected, finally, a search attribute "data-cy=xxx" is added to each target element, where xxx represents the standard attribute value corresponding to that target element.
[0062] Based on the HTML document processing method in this embodiment, multiple target elements are determined from all elements in the document to be processed according to whether the elements have target attributes. Retrieval attributes are added to these target elements. If any target element needs to be retrieved in a test case, it can be based on the retrieval attributes. The attribute names of the retrieval attributes are adapted to the element selectors, ensuring accurate positioning. Since the retrieval attributes reflect the relative relationships between target elements, even if the target attributes of a target element change, the same test cases can still accurately retrieve the required target element, ensuring good reusability of the test cases. This greatly reduces repetitive work when writing test cases and improves the efficiency of test case writing.
[0063] In one embodiment, the attribute value of the target attribute includes a prefix value and a change value. The prefix value of the target attribute is the same as a preset prefix value, and the change value of the target attribute changes according to a preset rule. Determining multiple target elements among all elements of the document to be processed includes: for any element of the document to be processed, determining whether the attribute values of each attribute within that element contain a preset prefix value; if so, then that element is selected as the target element.
[0064] It's understandable that, for ease of data management, the attribute value of a target attribute is set to consist of a prefix value and a variation value. The process involves determining whether the attribute values of attributes with the same name across different elements contain a preset prefix value corresponding to that attribute name. If so, these attribute values containing the preset prefix value conform to a preset rule, and the attribute containing the preset prefix value is the target attribute; the element with the target attribute is the target element. This determination can be achieved by constructing a regular expression based on the preset prefix value, matching the regular expression against the attribute value of each attribute within the element, and determining whether the attribute value of each attribute within the element contains the preset prefix value based on the matching results. For example, in a shopping platform interface, each product has a unique numeric string for differentiation and identification. This numeric string consists of a prefix value and a variation value. Each product has the same prefix value, while the variation value changes depending on the product. For example, if the target attribute value for a hair dryer of brand A is "6919194182052860992" and the target attribute value for toothpaste of brand B is "6919778194489044032", then "6919" can be used as a preset prefix value. If an attribute value is prefixed with "6919" and then includes an uncertain variable value, it conforms to a preset rule. Based on this, we determine whether each element is a target element.
[0065] In one embodiment, if the target elements are multiple elements in the same list, a standard attribute value corresponding to the target element can be generated based on the target element's position in the list. Please refer to [link to relevant documentation]. Figure 2Specifically, it includes steps S202 and S204.
[0066] S202, Determine the position of the target element in the list.
[0067] That is, to determine the specific position of each target element in the list.
[0068] S204: Generate standard attribute values corresponding to the target element based on its position in the list.
[0069] After determining the position of each target element, you can directly use its position as the standard attribute value, or you can process the target element's position in the list according to its type to facilitate differentiation. For example, for a target element corresponding to a product, if the product is the nth item in the product list, then "productn" can be used as the standard attribute value. Please refer to [link to relevant documentation]. Figure 3a and Figure 3b . Figure 3a The image shows the product list before optimization. Based on this list, traditional techniques require locating the target element in the list using an attribute named "data-product-id". The value of the "data-product-id" attribute will change after the products in the list are changed. Figure 3b The optimized product list is shown, which allows for location based on the search attribute "data-cy," which is compatible with Cypress's element selector. Taking the first product in the list as an example, regardless of what the first product becomes, it will always have a search attribute named "data-cy" with the value "product1," enabling test cases to be reused.
[0070] In some cases, the change in a target attribute is related to the target element's position in the list; that is, the change in the target attribute reflects the target element's position in the list. A problem affecting test case reusability might be that the target attribute's value is too complex. In such cases, standard attribute values can be generated based on the target attribute's value. For details, please refer to [link to relevant documentation]. Figure 4 Generating standard attribute values corresponding to the target element includes steps S402 and S404.
[0071] S402, Remove the prefix value from the attribute value of the target attribute according to the preset prefix value to obtain the change value of the target attribute.
[0072] Since the attribute value of the target attribute is known, after extracting the attribute value, the part of the attribute value that is the same as the preset prefix value is removed, and the remaining part is the change value of the target attribute. For example, assuming x is less than 10, the attribute value of the target attribute of the xth product in the list is "691910000x", and the preset prefix value is "6919", then removing "6919" from the target attribute value and leaving "10000x" is the change value.
[0073] S404 simplifies the change values of the target attribute and obtains the standard attribute value based on the simplification result.
[0074] Simplify characters in the changed value that are irrelevant to the position of the target element in the list, that is, simplify the "10000" before "x" in "10000x", and generate the standard attribute value based on the obtained "x".
[0075] Secondly, this application provides a method for locating HTML elements. Please refer to [link to relevant documentation]. Figure 5 The method includes steps S502 and S504.
[0076] S502, Obtain the target document. The target document is obtained by processing the HTML document processing method in any of the above embodiments.
[0077] S504, based on the attribute name of the search attribute, uses the element selector of the automated testing framework to locate elements with the search attribute in the target document.
[0078] After processing the HTML document to be processed by any of the above embodiments, each target element has an attribute value corresponding to a retrieval attribute. Under the same automated testing framework, the target element can be accurately located by using the attribute name of the retrieval attribute and the standard attribute value corresponding to the target element as keywords. For example, using Cypress as the automated testing framework, please refer to [link to relevant documentation]. Figure 3b To retrieve the element corresponding to the first product in the list, you can run the `get` command in Cypress, for example, `cy.get.('[data-cy=product1]')`. Figure 3b The element corresponding to the first item in the list is used to locate the desired target element. Even if the first item in the list is different at different times, the same test case can still achieve the same test effect, demonstrating high test case reusability.
[0079] Thirdly, embodiments of this application provide an HTML document processing apparatus, including a document acquisition module, a target element determination module, a standard attribute value generation module, and a target document generation module. The document acquisition module is used to acquire a document to be processed, which is an HTML document of a page to be tested. The target element determination module is used to determine multiple target elements among all elements in the document to be processed; each target element includes at least one target attribute, and target attributes with the same attribute name in different target elements conform to a preset rule. The standard attribute value generation module is used to generate standard attribute values corresponding to the target elements, and the standard attribute values reflect the relative relationships between the target elements. The target document generation module is used to add retrieval attributes to the target elements to obtain the target document; the attribute name of the retrieval attribute is a string supported for searching by the element selector of the automated testing framework, and the attribute value of the retrieval attribute is the standard attribute value corresponding to the target element.
[0080] In one embodiment, the target document generation module includes a retrieval attribute adding unit. The retrieval attribute adding unit is used to determine the automated testing framework used for UI automated testing; use strings supported by the element selector of the automated testing framework as standard attribute names; and add retrieval attributes to the target element, with the attribute name being the standard attribute name and the attribute value being the standard attribute value corresponding to the target element. The target element determination module is used to, for any element in the document to be processed, determine whether the attribute values of each attribute within that element contain a preset prefix value; if so, then that element is selected as the target element.
[0081] In one embodiment, the target attribute value includes a prefix value and a change value. The prefix value of the target attribute is the same as a preset prefix value, and the change value of the target attribute changes according to a preset rule. The standard attribute value generation module is used to determine the position of the target element in the list; based on the position of the target element in the list, it generates a standard attribute value corresponding to the target element.
[0082] In one embodiment, the change value of the target attribute reflects the position of the target element in the list. The standard attribute value generation module is used to remove the prefix value from the attribute value of the target attribute according to the preset prefix value to obtain the change value of the target attribute; the change value of the target attribute is simplified, and the standard attribute value is obtained according to the simplification result.
[0083] Specific limitations regarding the HTML document processing device can be found in the limitations of the HTML document processing method described above, and will not be repeated here. Each module in the HTML document processing device described above can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module. It should be noted that the module division in this embodiment is illustrative and only represents a logical functional division; other division methods may be used in actual implementation.
[0084] Fourthly, embodiments of this application provide a storage medium, characterized in that: the storage medium stores computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform: obtaining a document to be processed, the document to be processed being an HTML document of a page to be tested; determining multiple target elements among all elements of the document to be processed; each target element includes at least one target attribute, and target attributes with the same attribute name in different target elements conform to a preset rule; generating standard attribute values corresponding to the target elements; the standard attribute values reflecting the relative relationships between target elements; adding a retrieval attribute to the target elements to obtain the target document; the attribute name of the retrieval attribute is a string supported for searching by the element selector of the automated testing framework, and the attribute value of the retrieval attribute is the standard attribute value corresponding to the target element.
[0085] In some embodiments, when computer-readable instructions are executed by one or more processors, the one or more processors cause the one or more processors to perform the steps of the HTML document processing method or HTML element location method in any of the above embodiments.
[0086] Fifthly, embodiments of this application provide a computer device, including: one or more processors, and a memory;
[0087] The memory stores computer-readable instructions. When executed by one or more processors, these instructions perform the following: Retrieve the document to be processed, which is an HTML document of the page to be tested; Identify multiple target elements among all elements in the document to be processed; Each target element includes at least one target attribute, and target attributes with the same attribute name in different target elements conform to a preset rule; Generate standard attribute values corresponding to the target elements; The standard attribute values reflect the relative relationships between target elements; Add a retrieval attribute to the target elements to obtain the target document; The attribute name of the retrieval attribute is a string supported by the element selector of the automated testing framework, and the attribute value of the retrieval attribute is the standard attribute value corresponding to the target element.
[0088] In some embodiments, when computer-readable instructions are executed by one or more processors, the one or more processors cause the one or more processors to perform the steps of the HTML document processing method or HTML element location method in any of the above embodiments.
[0089] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.
[0090] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0091] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An HTML document processing method, characterized in that, include: Obtain the document to be processed, which is the HTML document of the page to be tested; Identify multiple target elements among all elements of the document to be processed; The target element includes at least one target attribute, and the target attributes with the same attribute name in different target elements conform to a preset rule; Generate standard attribute values corresponding to the target elements; the standard attribute values reflect the relative relationships between the target elements. Add a search attribute to the target element to obtain the target document; the attribute name of the search attribute is the string that the element selector of the automated testing framework supports searching for, and the attribute value of the search attribute is the standard attribute value corresponding to the target element. The generation of standard attribute values corresponding to the target element includes: Determine the position of the target element in the list; Based on the position of the target element in the list, generate the standard attribute value corresponding to the target element; Adding search attributes to the target element includes: Determine the automation testing framework to use for UI automation testing; The standard attribute name is the string that the element selector of the automated testing framework supports searching for. Add the search attribute to the target element, with the attribute name being the standard attribute name and the attribute value being the standard attribute value.
2. The method according to claim 1, characterized in that, The attribute value of the target attribute includes a prefix value and a change value. The prefix value of the target attribute is the same as the preset prefix value, and the change value of the target attribute corresponds one-to-one with the target element. The step of determining multiple target elements among all elements of the document to be processed includes: For any element in the document to be processed, determine whether the attribute values of each attribute within the element contain the preset prefix value. If so, then the element is taken as the target element.
3. The method according to claim 2, characterized in that, The change in the target attribute reflects the position of the target element in the list, and generating the standard attribute value corresponding to the target element includes: The prefix value is removed from the attribute value of the target attribute according to the preset prefix value to obtain the change value of the target attribute; The change values of the target attribute are simplified, and the standard attribute value is obtained based on the simplification result.
4. The method according to any one of claims 1-3, characterized in that, The automated testing framework includes Cypress.
5. A method for locating HTML elements, characterized in that, include: Obtain the target document; The target document is obtained by processing the HTML document processing method according to any one of claims 1-4; Based on the attribute name of the search attribute, the element selector of the automated testing framework is used to locate the element with the search attribute in the target document.
6. An HTML document processing device, characterized in that, include: The document acquisition module is used to acquire the document to be processed, which is the HTML document of the page to be tested; The target element determination module is used to determine multiple target elements among all elements of the document to be processed; the target element includes at least one target attribute, and the target attributes with the same attribute name in different target elements conform to a preset rule; A standard attribute value generation module is used to generate standard attribute values corresponding to the target element; the standard attribute values reflect the relative relationships between the target elements; the standard attribute value generation module is used to determine the position of the target element in the list, and generate the standard attribute values corresponding to the target element based on the position of the target element in the list; The target document generation module is used to add search attributes to the target element to obtain the target document; the attribute name of the search attribute is a string that the element selector of the automated testing framework supports searching for, and the attribute value of the search attribute is the standard attribute value corresponding to the target element. The target document generation module includes a retrieval attribute addition unit; The retrieval attribute adding unit is used to determine the automated testing framework used for UI automated testing, and to add the retrieval attribute, whose attribute name is the standard attribute name and whose attribute value is the standard attribute value, to the target element, using the string that the element selector of the automated testing framework supports for searching.
7. A storage medium, characterized in that: The storage medium stores computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the HTML document processing method as described in any one of claims 1 to 4 or the HTML element positioning method as described in claim 5.
8. A computer device, characterized in that, include: One or more processors, and memory; The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the HTML document processing method as described in any one of claims 1 to 4 or the HTML element positioning method as described in claim 5.