A method, apparatus, device, medium, and product for application testing.
By generating independent location identifiers and establishing mapping relationships, the problem of frequent test case adjustments caused by the reliance on code-level positioning for page elements in existing technologies is solved, achieving high efficiency and accuracy in automated testing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2026-04-03
AI Technical Summary
In existing automated testing tools, the positioning of page elements relies too heavily on the code level, leading to frequent adjustments to test cases during page iterations. This increases the workload of testers, makes them prone to errors, and affects testing efficiency and accuracy.
By obtaining relevant information about page elements in the application, independent location identifiers are generated, and a mapping relationship between page elements and location identifiers is established. Test cases are generated, and automated testing is performed based on the mapping relationship, achieving rapid element location and testing without going through the code level.
It reduces the time and errors of manually locating elements, improves the efficiency and accuracy of automated testing, and reduces the impact of page iteration on test cases.
Smart Images

Figure CN119862118B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of application testing technology, and in particular to a method, apparatus, device, medium, and product for application testing. Background Technology
[0002] In the field of software development and testing, automated testing tools are commonly used to test applications, and their application has become an important means of improving testing efficiency and quality.
[0003] In current technologies, mainstream automated testing tools generally use location markers to identify elements on a page in order to perform corresponding test operations. However, existing location markers are all closely dependent on the code level. When the page code in the application changes, it may be affected, thus causing the test cases to fail.
[0004] Furthermore, with the rapid development of mobile internet, the iteration speed of pages in applications is constantly accelerating, and page structures and element identifiers need frequent modifications and adjustments during development. For testers, this means constantly updating element location information in test cases to adapt to page changes. This process is not only tedious and time-consuming but also prone to errors, severely impacting testing efficiency and accuracy. Summary of the Invention
[0005] In view of the above problems, a method, apparatus, device, medium, and product for application testing are proposed to overcome or at least partially solve the above problems, including:
[0006] A method for testing an application, the method comprising:
[0007] Retrieve information about page elements in the application;
[0008] Based on the relevant information, generate the positioning identifier of the page element;
[0009] Establish a mapping relationship between the page elements and the location identifiers;
[0010] Test cases are generated for the location identifier, and during automated testing, the test cases are invoked to test the page elements based on the mapping relationship.
[0011] Optionally, before generating test cases for the location identifier, the method further includes:
[0012] When a triggering event is detected, the scaling identifier of the page element is updated.
[0013] Optionally, the triggering event includes any one of the following: code update of the application, UI interaction graph update of the application.
[0014] Optionally, generating the location identifier of the page element based on the relevant information includes:
[0015] Multiple pieces of information from the aforementioned related information are combined to obtain a string;
[0016] Based on the string, generate the positioning identifier of the page element.
[0017] Optionally, the relevant information includes visual information, and obtaining relevant information about page elements in the application includes:
[0018] By analyzing the UI interaction diagram of the application, the visual information of the page elements is obtained.
[0019] Optionally, the visual information includes any one or more of the following: UI style, element size, element position, function description, and user interaction process information.
[0020] Optionally, the relevant information includes non-visual information, and obtaining relevant information about page elements in the application includes:
[0021] By scanning the page elements of the application, non-visual information of the page elements is obtained.
[0022] Optionally, the non-visual information includes any one or more of the following: element identifier, element class name, element path, and page structure information.
[0023] An application testing apparatus, the apparatus comprising:
[0024] The relevant information acquisition module is used to acquire relevant information about page elements in the application;
[0025] A location identifier generation module is used to generate a location identifier for the page element based on the relevant information.
[0026] A mapping relationship establishment module is used to establish a mapping relationship between the page elements and the positioning identifiers;
[0027] An automated testing module is used to generate test cases for the location identifier, and during the automated testing process, it calls the test cases to test the page elements based on the mapping relationship.
[0028] An electronic device includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the method described above.
[0029] A computer-readable storage medium on which a computer program is stored, which, when executed by a processor, implements the method described above.
[0030] A computer program product includes a computer program that, when executed by a processor, implements the method described above.
[0031] The embodiments of the present invention have the following advantages:
[0032] In this embodiment of the invention, by obtaining relevant information about page elements in the application; generating location identifiers for page elements based on the relevant information; establishing a mapping relationship between page elements and location identifiers; generating test cases for the location identifiers; and calling the test cases to test the page elements during automated testing based on the mapping relationship, it is possible to quickly locate and test page elements through location identifiers and mapping relationships, reducing the time and errors of manually locating elements and improving the efficiency and accuracy of automated testing. Attached Figure Description
[0033] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 This is a flowchart of the steps of an application testing method provided in some embodiments of the present invention;
[0035] Figure 2 This is a flowchart illustrating an application testing method provided in some embodiments of the present invention;
[0036] Figure 3 This is a flowchart of the steps of another application testing method provided in some embodiments of the present invention;
[0037] Figure 4 This is a flowchart of the steps of another application testing method provided in some embodiments of the present invention;
[0038] Figure 5 This is a structural block diagram of an application testing apparatus provided in some embodiments of the present invention. Detailed Implementation
[0039] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0040] In related technologies, element positioning identifiers (ID, CLASS, XPath) rely too much on the code level, which means that test cases need to frequently adjust element positioning during page iteration, increasing the workload of testers.
[0041] Among them, ID identification and positioning: As a unique identifier for an element in an HTML or XML document, the ID has a high degree of specificity and stability. During development, the ID is explicitly generated and bound by the developer in the code.
[0042] CLASS tagging: CLASS is another element locating method that allows the same class name to be assigned to multiple elements, enabling batch operations. Unlike ID, CLASS generation and management are relatively flexible, but this also leads to relatively lower stability in its locating. When the page structure or style changes, CLASS tags may be affected, requiring testers to update test cases.
[0043] XPath is a method for locating elements based on the page hierarchy. It generates path expressions based on the element's position in the DOM tree. While XPath provides powerful location capabilities, it relies on the page hierarchy generated by user actions. Therefore, when the page element hierarchy changes, the XPath path also changes, leading to unreliable location.
[0044] In this embodiment of the invention, an independent mapping method for element location identifiers is proposed. By establishing a mapping table and extracting the page structure by combining the UI (User Interface) interaction diagram and configuration file, location identifiers such as ID, CLASS, and XPath are mapped to location identifiers independent of the code level. The independent identifiers are associated with the original location identifiers to form a mapping table. When the page iterates or the original identifiers change, the mapping table is automatically updated to ensure the accuracy of element location. In subsequent tests, only the independent mapping identifiers need to be used, without being separated from the development code level.
[0045] Through this invention, testers only need to focus on the mapped independent element location identifiers when writing test cases, and write the test cases based on these identifiers, without needing to concern themselves with the specific implementation of the elements at the code level. When the identifiers at the code level change, the test cases do not need to be modified. This effectively reduces the impact of page iterations on automated test cases, improves testing efficiency, and reduces the workload of testers. Simultaneously, it also improves the accuracy and stability of element location, ensuring the smooth execution of automated testing.
[0046] The present invention will be further described below with reference to the accompanying drawings:
[0047] Reference Figure 1 The diagram illustrates a flowchart of the steps of an application testing method provided by some embodiments of the present invention, which may specifically include the following steps:
[0048] Step 101: Obtain relevant information about page elements in the application.
[0049] During development or testing, specific methods or tools can be used to identify and collect relevant information about various elements on the application interface (such as buttons, text boxes, images, etc.), thereby helping developers better understand and optimize the application's interface layout and interaction design. Alternatively, it can provide testers with necessary element information to write and execute automated test scripts, ensuring the application's quality and stability.
[0050] For example, automated testing tools can be used to perform a global scan of the code in an application or the pages generated by that code, extracting element IDs, classes, dimensions, and page structure information (such as HTML information, HyperText Markup Language, a standard markup language used to create and design web pages).
[0051] Among these, automated testing tools (such as Selenium and Appium) provide APIs for locating and manipulating page elements in an application. These tools support various location methods (such as ID, CLASS, XPath, etc.) and allow testers to write scripts to simulate user actions and verify the application's behavior.
[0052] In some embodiments of the present invention, the relevant information includes visual information, and obtaining the relevant information of page elements in the application includes: obtaining the visual information of the page elements by parsing the UI interaction diagram of the application.
[0053] Visual information refers to the various visual characteristics of page elements presented on the user interface. These characteristics may include, but are not limited to, the element's color, shape, size, border, shadow, transparency, font style and size, and the resolution of images or icons.
[0054] A UI interaction diagram is a diagram or model used to describe the layout and interaction logic of an application's user interface. It can include various page elements, their arrangement, the ways users interact with these elements (such as clicking, swiping, etc.), and the events and responses triggered by these interactions.
[0055] In practical applications, UI interaction diagrams can be parsed using parsing scripts to extract visual information of each element, such as color, size, position, function description, and user interaction behavior.
[0056] In some embodiments of the present invention, the visual information includes any one or more of the following: UI style, element size, element position, function description, and user interaction process information.
[0057] UI style refers to the appearance and style of the user interface, including colors, fonts, layout, icons, etc. Element size refers to the size of each element on the UI interface (such as buttons, text boxes, images, etc.). Element position refers to the positional relationship of each element on the UI interface relative to other elements or the entire interface. Functional description refers to the functional information of the elements conveyed to the user through visual means (such as text, icons, etc.).
[0058] User interaction process information refers to the interaction process information generated when a user operates the UI interface, such as actions like clicking, swiping, and dragging, as well as the interface changes triggered by these actions.
[0059] In some embodiments of the present invention, the relevant information includes non-visual information, and obtaining the relevant information of page elements in the application includes: obtaining the non-visual information of the page elements by scanning the page elements of the application.
[0060] Non-visual information refers to information that cannot be directly perceived through vision, and may include, but is not limited to, element attributes (such as whether it is clickable, whether it is selected, whether it is disabled, etc.), status (such as loading, error, success, etc.), relationships with other elements (such as parent-child relationships, sibling relationships, etc.), and functional descriptions (such as what the button does).
[0061] As examples, automated testing tools can be used to scan application page elements, extract non-visual information from these elements, and store it in a structured manner.
[0062] In some embodiments of the present invention, the non-visual information includes any one or more of the following: element identifier, element class name, element path, and page structure information.
[0063] The element identifier refers to a unique identifier (such as an ID) for each page element, used to uniquely identify the element in the code.
[0064] An element class name (such as CLASS) refers to the class (or style sheet class) assigned to a page element, which can be used to define the element's style and behavior.
[0065] An element path (such as XPath) refers to the path from the root element of the page to the target element, and it is used to describe the position of the element in the page structure.
[0066] Page structure information (such as HTML information) refers to the hierarchical structure and relationships of page elements. It is used to describe the parent-child relationship, sibling relationship, etc. between elements, as well as the overall layout and composition of the page.
[0067] As examples, after obtaining relevant information about page elements in an application, the scanned and parsed information about page elements can be aggregated to build a database containing all relevant information about the elements, and the database will continuously collect and update information.
[0068] Step 102: Generate the positioning identifier of the page element based on the relevant information.
[0069] As some examples, a location identifier can be a unique, independent identifier, referring to a string or data structure that can uniquely identify a page element. It can be built based on the page element's attributes (such as ID, CLASS, XPath, etc.) and used to accurately locate the element in subsequent operations.
[0070] In some embodiments of the present invention, generating the positioning identifier of the page element based on the relevant information includes: combining multiple pieces of information in the relevant information to obtain a string; and generating the positioning identifier of the page element based on the string.
[0071] In practical applications, relevant information can be analyzed and multiple pieces of information related to page elements can be combined to form a more complete and specific description.
[0072] Here, a string refers to a text sequence obtained by combining multiple relevant information, which contains enough information to generate a unique identifier.
[0073] For example, through automated testing tools, all the identifiers of an element (ID+CLASS+XPath) can be obtained, combined into a complete string through an algorithm, encrypted through hash conversion, and then converted into base64 to form a unique and independent identifier, i.e., a unique signature.
[0074] For example, a page element has the ID: Pow-Button, the CLASS: Pow-text-blue-500, and the XPath: asdx123466.
[0075] Combined into a string using an algorithm:
[0076] ˋPow-Button\n+Pow-text-blue-500\n+asdx123466\n+${p configuration information}\n+${UI style}\nˋ.
[0077] After hashing and encrypting the combined string, a base64 conversion is performed to generate a unique string identifier (location identifier / unique independent identifier).
[0078] Step 103: Establish the mapping relationship between the page elements and the positioning identifiers.
[0079] In this context, mapping refers to a correspondence that connects page elements with positioning tags, allowing page elements to be indirectly referenced through positioning tags.
[0080] For example, a mapping relationship can be a simple set of key-value pairs (where the key is a location identifier and the value is a page element) or a more complex data structure (such as a hash table, dictionary, etc.).
[0081] In practical applications, features can be extracted from each element in the database by traversing it. The unique features of each element (such as ID+CLASS+XPath) are extracted to form a unique independent identifier (location identifier). Testers can customize the name of this key independent identifier and other relevant information. After the name is determined, a mapping is formed. This independent identifier uniquely represents an element and remains stable during page iteration, unaffected by code modifications. The mapping relationships of all elements are integrated and finally compiled into a mapping table and stored. This table will serve as a reference for element location during automated testing and will be updated and maintained as needed.
[0082] Step 104: Generate test cases for the location identifier, and during the automated testing process, call the test cases to test the page elements based on the mapping relationship.
[0083] In this context, a test case refers to a script or code snippet written for a specific testing purpose. It includes the test input, expected output, and the steps required to execute the test. Test cases can be used to verify whether a function of a system or application works as expected.
[0084] As examples, test cases can be generated for page elements based on location identifiers. That is, test cases can use location identifiers to refer to the corresponding page elements and set test information, such as test operations, for the location identifier.
[0085] During automated testing, based on the established mapping relationship, the corresponding test cases are invoked to test page elements. For example, by looking up the mapping table, the page element corresponding to the location identifier in the test case can be determined, and then the page element can be tested without having to focus on the code level.
[0086] When writing test cases, testers only need to focus on the mapping of independent element location identifiers and write the test cases accordingly, without needing to concern themselves with the specific implementation of the elements at the code level. Through this embodiment of the invention, test cases do not need to be modified when the code-level identifiers change.
[0087] After testing is complete, the test results can be analyzed. For example, the actual output can be compared with the expected output to determine whether the page elements work as expected. If the test results do not meet expectations, debugging and repair can be performed.
[0088] In some embodiments of the present invention, before generating test cases for the location identifier, the method further includes: updating the calibration identifier of the page element when a triggering event is detected.
[0089] In some embodiments of the present invention, the triggering event includes any one of the following: code update of the application, UI interaction graph update of the application.
[0090] In this context, application code updates refer to modifications or updates to the application's source code. Application UI / UX updates refer to modifications or updates to the application's user interface (UI) interaction logic, such as adjustments to page layout, or the addition or deletion of page elements.
[0091] As examples, when a triggering event is detected, the tagging identifiers of the affected page elements can be updated automatically or manually by the developers. After updating the tagging identifiers, validation can be performed to ensure that the new identifiers accurately locate the corresponding page elements.
[0092] As examples, when the business code iteration (application code update) is committed, it triggers an automated program on GitLab (a Git-based open-source code hosting and management platform) to notify testers and automatically captures changes in information such as ID / CLASS in the code through a workflow. Similarly, when the UI interaction diagram (application UI interaction diagram update) is updated, it triggers the upload script analysis to update the basic information of the elements and synchronously update the location identifiers in the mapping table.
[0093] Among them, ID / CLASS information changes refer to changes that may occur due to developers modifying code, product modifications, etc. For example, the original ID: Pow-text-1 will be changed to Pow-new-text-2.
[0094] In some examples, code development uses Git, a code management tool. After product updates are completed, such as changing the button color from dark blue to light blue, the corresponding class in the code will be changed from "Pow-blue-1" to "Pow-blue-2". After committing code to Git, the new commit and its update content can be detected. The AI workflow deployed on Git can then compare the new commit and the updated content. If the update involves changes to identifier elements such as ID / CLASS, the updated element and its corresponding related information are determined based on the update content. After being combined into a complete string by an algorithm, it is hashed and encrypted into base64 as a new location identifier for that element, and then updated in the latest mapping table.
[0095] In this embodiment of the invention, by obtaining relevant information about page elements in the application; generating location identifiers for page elements based on the relevant information; establishing a mapping relationship between page elements and location identifiers; generating test cases for the location identifiers; and calling the test cases to test the page elements during automated testing based on the mapping relationship, it is possible to quickly locate and test page elements through location identifiers and mapping relationships, reducing the time and errors of manually locating elements and improving the efficiency and accuracy of automated testing.
[0096] The following is in conjunction with the appendix Figure 2 The present invention will be described by way of example:
[0097] Step 201: Scanning page elements and extracting information.
[0098] Step 202: Extract the ID, CLASS, and Xpth of the page elements to extract the visual features (visual information) of the elements.
[0099] Step 203: Summarize element information (related information).
[0100] Step 204: Generation of independent element location identifiers (location identifiers).
[0101] Step 205: Create the mapping table.
[0102] Step 206: Check if it has been updated. If so, automatically update the completion mechanism and return to step 201; otherwise, proceed to step 207.
[0103] Step 207: Generate the final result for testing.
[0104] Reference Figure 3 The diagram illustrates a flowchart of another application testing method provided by some embodiments of the present invention, which may specifically include the following steps:
[0105] Step 301: Obtain relevant information about page elements in the application.
[0106] During development or testing, specific methods or tools can be used to identify and collect relevant information about various elements on the application interface (such as buttons, text boxes, images, etc.), thereby helping developers better understand and optimize the application's interface layout and interaction design. Alternatively, it can provide testers with necessary element information to write and execute automated test scripts, ensuring the application's quality and stability.
[0107] For example, automated testing tools can be used to perform a global scan of the code in an application or the pages generated by that code, extracting element IDs, classes, dimensions, and page structure information (such as HTML information, HyperText Markup Language, a standard markup language used to create and design web pages).
[0108] Among these, automated testing tools (such as Selenium and Appium) provide APIs for locating and manipulating page elements in an application. These tools support various location methods (such as ID, CLASS, XPath, etc.) and allow testers to write scripts to simulate user actions and verify the application's behavior.
[0109] In some embodiments of the present invention, the relevant information includes visual information, and obtaining the relevant information of page elements in the application includes: obtaining the visual information of the page elements by parsing the UI interaction diagram of the application.
[0110] Visual information refers to the various visual characteristics of page elements presented on the user interface. These characteristics may include, but are not limited to, the element's color, shape, size, border, shadow, transparency, font style and size, and the resolution of images or icons.
[0111] A UI interaction diagram is a diagram or model used to describe the layout and interaction logic of an application's user interface. It can include various page elements, their arrangement, the ways users interact with these elements (such as clicking, swiping, etc.), and the events and responses triggered by these interactions.
[0112] In practical applications, UI interaction diagrams can be parsed using parsing scripts to extract visual information of each element, such as color, size, position, function description, and user interaction behavior.
[0113] In some embodiments of the present invention, the visual information includes any one or more of the following: UI style, element size, element position, function description, and user interaction process information.
[0114] UI style refers to the appearance and style of the user interface, including colors, fonts, layout, icons, etc. Element size refers to the size of each element on the UI interface (such as buttons, text boxes, images, etc.). Element position refers to the positional relationship of each element on the UI interface relative to other elements or the entire interface. Functional description refers to the functional information of the elements conveyed to the user through visual means (such as text, icons, etc.).
[0115] User interaction process information refers to the interaction process information generated when a user operates the UI interface, such as actions like clicking, swiping, and dragging, as well as the interface changes triggered by these actions.
[0116] In some embodiments of the present invention, the relevant information includes non-visual information, and obtaining the relevant information of page elements in the application includes: obtaining the non-visual information of the page elements by scanning the page elements of the application.
[0117] Non-visual information refers to information that cannot be directly perceived through vision, and may include, but is not limited to, element attributes (such as whether it is clickable, whether it is selected, whether it is disabled, etc.), status (such as loading, error, success, etc.), relationships with other elements (such as parent-child relationships, sibling relationships, etc.), and functional descriptions (such as what the button does).
[0118] As examples, automated testing tools can be used to scan application page elements, extract non-visual information from these elements, and store it in a structured manner.
[0119] In some embodiments of the present invention, the non-visual information includes any one or more of the following: element identifier, element class name, element path, and page structure information.
[0120] The element identifier refers to a unique identifier (such as an ID) for each page element, used to uniquely identify the element in the code.
[0121] An element class name (such as CLASS) refers to the class (or style sheet class) assigned to a page element, which can be used to define the element's style and behavior.
[0122] An element path (such as XPath) refers to the path from the root element of the page to the target element, and it is used to describe the position of the element in the page structure.
[0123] Page structure information (such as HTML information) refers to the hierarchical structure and relationships of page elements. It is used to describe the parent-child relationship, sibling relationship, etc. between elements, as well as the overall layout and composition of the page.
[0124] As examples, after obtaining relevant information about page elements in an application, the scanned and parsed information about page elements can be aggregated to build a database containing all relevant information about the elements, and the database will continuously collect and update information.
[0125] Step 302: Generate the positioning identifier of the page element based on the relevant information.
[0126] As some examples, a location identifier can be a unique, independent identifier, referring to a string or data structure that can uniquely identify a page element. It can be built based on the page element's attributes (such as ID, CLASS, XPath, etc.) and used to accurately locate the element in subsequent operations.
[0127] In some embodiments of the present invention, generating the positioning identifier of the page element based on the relevant information includes: combining multiple pieces of information in the relevant information to obtain a string; and generating the positioning identifier of the page element based on the string.
[0128] In practical applications, relevant information can be analyzed and multiple pieces of information related to page elements can be combined to form a more complete and specific description.
[0129] Here, a string refers to a text sequence obtained by combining multiple relevant information, which contains enough information to generate a unique identifier.
[0130] For example, through automated testing tools, all the identifiers of an element (ID+CLASS+XPath) can be obtained, combined into a complete string through an algorithm, encrypted through hash conversion, and then converted into base64 to form a unique and independent identifier, i.e., a unique signature.
[0131] For example, a page element has the ID: Pow-Button, the CLASS: Pow-text-blue-500, and the XPath: asdx123466.
[0132] Combined into a string using an algorithm:
[0133] ˋPow-Button\n+Pow-text-blue-500\n+asdx123466\n+${p configuration information}\n+${UI style}\nˋ.
[0134] After hashing and encrypting the combined string, a base64 conversion is performed to generate a unique string identifier (location identifier / unique independent identifier).
[0135] Step 303: Establish the mapping relationship between the page elements and the positioning identifiers.
[0136] In this context, mapping refers to a correspondence that connects page elements with positioning tags, allowing page elements to be indirectly referenced through positioning tags.
[0137] For example, a mapping relationship can be a simple set of key-value pairs (where the key is a location identifier and the value is a page element) or a more complex data structure (such as a hash table, dictionary, etc.).
[0138] In practical applications, features can be extracted from each element in the database by traversing it. The unique features of each element (such as ID+CLASS+XPath) are extracted to form a unique independent identifier (location identifier). Testers can customize the name of this key independent identifier and other relevant information. After the name is determined, a mapping is formed. This independent identifier uniquely represents an element and remains stable during page iteration, unaffected by code modifications. The mapping relationships of all elements are integrated and finally compiled into a mapping table and stored. This table will serve as a reference for element location during automated testing and will be updated and maintained as needed.
[0139] Step 304: When a triggering event is detected, update the scaling identifier of the page element.
[0140] In some embodiments of the present invention, the triggering event includes any one of the following: code update of the application, UI interaction graph update of the application.
[0141] In this context, application code updates refer to modifications or updates to the application's source code. Application UI / UX updates refer to modifications or updates to the application's user interface (UI) interaction logic, such as adjustments to page layout, or the addition or deletion of page elements.
[0142] As examples, when a triggering event is detected, the tagging identifiers of the affected page elements can be updated automatically or manually by the developers. After updating the tagging identifiers, validation can be performed to ensure that the new identifiers accurately locate the corresponding page elements.
[0143] As examples, when the business code iteration (application code update) is committed, it triggers an automated program on GitLab (a Git-based open-source code hosting and management platform) to notify testers and automatically captures changes in information such as ID / CLASS in the code through a workflow. Similarly, when the UI interaction diagram (application UI interaction diagram update) is updated, it triggers the upload script analysis to update the basic information of the elements and synchronously update the location identifiers in the mapping table.
[0144] Among them, ID / CLASS information changes refer to changes that may occur due to developers modifying code, product modifications, etc. For example, the original ID: Pow-text-1 will be changed to Pow-new-text-2.
[0145] In some examples, code development uses Git, a code management tool. After product updates are completed, such as changing the button color from dark blue to light blue, the corresponding class in the code will be changed from "Pow-blue-1" to "Pow-blue-2". After committing code to Git, the new commit and its update content can be detected. The AI workflow deployed on Git can then compare the new commit and the updated content. If the update involves changes to identifier elements such as ID / CLASS, the updated element and its corresponding related information are determined based on the update content. After being combined into a complete string by an algorithm, it is hashed and encrypted into base64 as a new location identifier for that element, and then updated in the latest mapping table.
[0146] Step 305: Generate test cases for the location identifier, and during the automated testing process, call the test cases to test the page elements based on the mapping relationship.
[0147] In this context, a test case refers to a script or code snippet written for a specific testing purpose. It includes the test input, expected output, and the steps required to execute the test. Test cases can be used to verify whether a function of a system or application works as expected.
[0148] As examples, test cases can be generated for page elements based on location identifiers. That is, test cases can use location identifiers to refer to the corresponding page elements and set test information, such as test operations, for the location identifier.
[0149] During automated testing, based on the established mapping relationship, the corresponding test cases are invoked to test page elements. For example, by looking up the mapping table, the page element corresponding to the location identifier in the test case can be determined, and then the page element can be tested without having to focus on the code level.
[0150] When writing test cases, testers only need to focus on the mapping of independent element location identifiers and write the test cases accordingly, without needing to concern themselves with the specific implementation of the elements at the code level. Through this embodiment of the invention, test cases do not need to be modified when the code-level identifiers change.
[0151] After testing is complete, the test results can be analyzed. For example, the actual output can be compared with the expected output to determine whether the page elements work as expected. If the test results do not meet expectations, debugging and repair can be performed.
[0152] In this embodiment of the invention, by obtaining relevant information about page elements in the application; generating location identifiers for page elements based on the relevant information; establishing a mapping relationship between page elements and location identifiers; updating the location identifiers of page elements when a trigger event is detected; generating test cases for the location identifiers; and calling the test cases to test the page elements based on the mapping relationship during automated testing, this invention achieves rapid location and testing of page elements through location identifiers and mapping relationships, reducing the time and errors of manual element location and improving the efficiency and accuracy of automated testing.
[0153] Reference Figure 4 The diagram illustrates a flowchart of another application testing method provided by some embodiments of the present invention, which may specifically include the following steps:
[0154] Step 401: Obtain relevant information about page elements in the application.
[0155] During development or testing, specific methods or tools can be used to identify and collect relevant information about various elements on the application interface (such as buttons, text boxes, images, etc.), thereby helping developers better understand and optimize the application's interface layout and interaction design. Alternatively, it can provide testers with necessary element information to write and execute automated test scripts, ensuring the application's quality and stability.
[0156] For example, automated testing tools can be used to perform a global scan of the code in an application or the pages generated by that code, extracting element IDs, classes, dimensions, and page structure information (such as HTML information, HyperText Markup Language, a standard markup language used to create and design web pages).
[0157] Among these, automated testing tools (such as Selenium and Appium) provide APIs for locating and manipulating page elements in an application. These tools support various location methods (such as ID, CLASS, XPath, etc.) and allow testers to write scripts to simulate user actions and verify the application's behavior.
[0158] In some embodiments of the present invention, the relevant information includes visual information, and obtaining the relevant information of page elements in the application includes: obtaining the visual information of the page elements by parsing the UI interaction diagram of the application.
[0159] Visual information refers to the various visual characteristics of page elements presented on the user interface. These characteristics may include, but are not limited to, the element's color, shape, size, border, shadow, transparency, font style and size, and the resolution of images or icons.
[0160] A UI interaction diagram is a diagram or model used to describe the layout and interaction logic of an application's user interface. It can include various page elements, their arrangement, the ways users interact with these elements (such as clicking, swiping, etc.), and the events and responses triggered by these interactions.
[0161] In practical applications, UI interaction diagrams can be parsed using parsing scripts to extract visual information of each element, such as color, size, position, function description, and user interaction behavior.
[0162] In some embodiments of the present invention, the visual information includes any one or more of the following: UI style, element size, element position, function description, and user interaction process information.
[0163] UI style refers to the appearance and style of the user interface, including colors, fonts, layout, icons, etc. Element size refers to the size of each element on the UI interface (such as buttons, text boxes, images, etc.). Element position refers to the positional relationship of each element on the UI interface relative to other elements or the entire interface. Functional description refers to the functional information of the elements conveyed to the user through visual means (such as text, icons, etc.).
[0164] User interaction process information refers to the interaction process information generated when a user operates the UI interface, such as actions like clicking, swiping, and dragging, as well as the interface changes triggered by these actions.
[0165] In some embodiments of the present invention, the relevant information includes non-visual information, and obtaining the relevant information of page elements in the application includes: obtaining the non-visual information of the page elements by scanning the page elements of the application.
[0166] Non-visual information refers to information that cannot be directly perceived through vision, and may include, but is not limited to, element attributes (such as whether it is clickable, whether it is selected, whether it is disabled, etc.), status (such as loading, error, success, etc.), relationships with other elements (such as parent-child relationships, sibling relationships, etc.), and functional descriptions (such as what the button does).
[0167] As examples, automated testing tools can be used to scan application page elements, extract non-visual information from these elements, and store it in a structured manner.
[0168] In some embodiments of the present invention, the non-visual information includes any one or more of the following: element identifier, element class name, element path, and page structure information.
[0169] The element identifier refers to a unique identifier (such as an ID) for each page element, used to uniquely identify the element in the code.
[0170] An element class name (such as CLASS) refers to the class (or style sheet class) assigned to a page element, which can be used to define the element's style and behavior.
[0171] An element path (such as XPath) refers to the path from the root element of the page to the target element, and it is used to describe the position of the element in the page structure.
[0172] Page structure information (such as HTML information) refers to the hierarchical structure and relationships of page elements. It is used to describe the parent-child relationship, sibling relationship, etc. between elements, as well as the overall layout and composition of the page.
[0173] As examples, after obtaining relevant information about page elements in an application, the scanned and parsed information about page elements can be aggregated to build a database containing all relevant information about the elements, and the database will continuously collect and update information.
[0174] Step 402: Combine multiple pieces of information from the relevant information to obtain a string.
[0175] In practical applications, relevant information can be analyzed and multiple pieces of information related to page elements can be combined to form a more complete and specific description.
[0176] Here, a string refers to a text sequence obtained by combining multiple relevant information, which contains enough information to generate a unique identifier.
[0177] Step 403: Generate the positioning identifier of the page element based on the string.
[0178] As some examples, a location identifier can be a unique, independent identifier, referring to a string or data structure that can uniquely identify a page element. It can be built based on the page element's attributes (such as ID, CLASS, XPath, etc.) and used to accurately locate the element in subsequent operations.
[0179] For example, through automated testing tools, all the identifiers of an element (ID+CLASS+XPath) can be obtained, combined into a complete string through an algorithm, encrypted through hash conversion, and then converted into base64 to form a unique and independent identifier, i.e., a unique signature.
[0180] For example, a page element has the ID: Pow-Button, the CLASS: Pow-text-blue-500, and the XPath: asdx123466.
[0181] Combined into a string using an algorithm:
[0182] `Pow-Button\n+Pow-text-blue-500\n+asdx123466\n+${p configuration information}\n+${UI style}\n`.
[0183] After hashing and encrypting the combined string, a base64 conversion is performed to generate a unique string identifier (location identifier / unique independent identifier).
[0184] Step 404: Establish the mapping relationship between the page elements and the positioning identifiers.
[0185] In this context, mapping refers to a correspondence that connects page elements with positioning tags, allowing page elements to be indirectly referenced through positioning tags.
[0186] For example, a mapping relationship can be a simple set of key-value pairs (where the key is a location identifier and the value is a page element) or a more complex data structure (such as a hash table, dictionary, etc.).
[0187] In practical applications, features can be extracted from each element in the database by traversing it. The unique features of each element (such as ID+CLASS+XPath) are extracted to form a unique independent identifier (location identifier). Testers can customize the name of this key independent identifier and other relevant information. After the name is determined, a mapping is formed. This independent identifier uniquely represents an element and remains stable during page iteration, unaffected by code modifications. The mapping relationships of all elements are integrated and finally compiled into a mapping table and stored. This table will serve as a reference for element location during automated testing and will be updated and maintained as needed.
[0188] Step 405: When a triggering event is detected, the scaling identifier of the page element is updated.
[0189] In some embodiments of the present invention, the triggering event includes any one of the following: code update of the application, UI interaction graph update of the application.
[0190] In this context, application code updates refer to modifications or updates to the application's source code. Application UI / UX updates refer to modifications or updates to the application's user interface (UI) interaction logic, such as adjustments to page layout, or the addition or deletion of page elements.
[0191] As examples, when a triggering event is detected, the tagging identifiers of the affected page elements can be updated automatically or manually by the developers. After updating the tagging identifiers, validation can be performed to ensure that the new identifiers accurately locate the corresponding page elements.
[0192] As examples, when the business code iteration (application code update) is committed, it triggers an automated program on GitLab (a Git-based open-source code hosting and management platform) to notify testers and automatically captures changes in information such as ID / CLASS in the code through a workflow. Similarly, when the UI interaction diagram (application UI interaction diagram update) is updated, it triggers the upload script analysis to update the basic information of the elements and synchronously update the location identifiers in the mapping table.
[0193] Among them, ID / CLASS information changes refer to changes that may occur due to developers modifying code, product modifications, etc. For example, the original ID: Pow-text-1 will be changed to Pow-new-text-2.
[0194] In some examples, code development uses Git, a code management tool. After product updates are completed, such as changing the button color from dark blue to light blue, the corresponding class in the code will be changed from "Pow-blue-1" to "Pow-blue-2". After committing code to Git, the new commit and its update content can be detected. The AI workflow deployed on Git can then compare the new commit and the updated content. If the update involves changes to identifier elements such as ID / CLASS, the updated element and its corresponding related information are determined based on the update content. After being combined into a complete string by an algorithm, it is hashed and encrypted into base64 as a new location identifier for that element, and then updated in the latest mapping table.
[0195] Step 406: Generate test cases for the location identifier, and during the automated testing process, call the test cases to test the page elements based on the mapping relationship.
[0196] In this context, a test case refers to a script or code snippet written for a specific testing purpose. It includes the test input, expected output, and the steps required to execute the test. Test cases can be used to verify whether a function of a system or application works as expected.
[0197] As examples, test cases can be generated for page elements based on location identifiers. That is, test cases can use location identifiers to refer to the corresponding page elements and set test information, such as test operations, for the location identifier.
[0198] During automated testing, based on the established mapping relationship, the corresponding test cases are invoked to test page elements. For example, by looking up the mapping table, the page element corresponding to the location identifier in the test case can be determined, and then the page element can be tested without having to focus on the code level.
[0199] When writing test cases, testers only need to focus on the mapping of independent element location identifiers and write the test cases accordingly, without needing to concern themselves with the specific implementation of the elements at the code level. Through this embodiment of the invention, test cases do not need to be modified when the code-level identifiers change.
[0200] After testing is complete, the test results can be analyzed. For example, the actual output can be compared with the expected output to determine whether the page elements work as expected. If the test results do not meet expectations, debugging and repair can be performed.
[0201] In this embodiment of the invention, by obtaining relevant information about page elements in an application; combining multiple pieces of information from the relevant information to obtain a string; generating a location identifier for the page element based on the string; establishing a mapping relationship between the page element and the location identifier; updating the location identifier of the page element when a trigger event is detected; generating test cases for the location identifier; and calling the test cases to test the page element based on the mapping relationship during automated testing, this invention achieves rapid location and testing of page elements through location identifiers and mapping relationships, reducing the time and errors of manual element location and improving the efficiency and accuracy of automated testing.
[0202] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0203] Reference Figure 5 The diagram illustrates a structural schematic of an application testing apparatus provided in some embodiments of the present invention, which may specifically include the following modules:
[0204] The relevant information acquisition module 501 is used to acquire relevant information about page elements in the application;
[0205] The location identifier generation module 502 is used to generate the location identifier of the page element based on the relevant information;
[0206] The mapping relationship establishment module 503 is used to establish the mapping relationship between the page element and the positioning identifier;
[0207] The automated testing module 504 is used to generate test cases for the location identifier, and during the automated testing process, it calls the test cases to test the page elements based on the mapping relationship.
[0208] In some embodiments of the present invention, the apparatus further includes:
[0209] The trigger event detection module is used to update the calibration identifier of the page element when a trigger event is detected.
[0210] In some embodiments of the present invention, the triggering event includes any one of the following: code update of the application, UI interaction graph update of the application.
[0211] In some embodiments of the present invention, the location identifier generation module 502 includes:
[0212] The information combining submodule is used to combine multiple pieces of information from the relevant information to obtain a string;
[0213] The positioning identifier generation module is used to generate the positioning identifier of the page element based on the string.
[0214] In some embodiments of the present invention, the relevant information includes visual information, and the relevant information acquisition module 501 includes:
[0215] The interaction diagram parsing submodule is used to obtain the visual information of the page elements by parsing the UI interaction diagram of the application.
[0216] In some embodiments of the present invention, the visual information includes any one or more of the following: UI style, element size, element position, function description, and user interaction process information.
[0217] In some embodiments of the present invention, the relevant information includes non-visual information, and the relevant information acquisition module 501 includes:
[0218] The page element scanning submodule is used to obtain non-visual information about the page elements by scanning the page elements of the application.
[0219] In some embodiments of the present invention, the non-visual information includes any one or more of the following: element identifier, element class name, element path, and page structure information.
[0220] In this embodiment of the invention, by obtaining relevant information about page elements in the application; generating location identifiers for page elements based on the relevant information; establishing a mapping relationship between page elements and location identifiers; generating test cases for the location identifiers; and calling the test cases to test the page elements during automated testing based on the mapping relationship, it is possible to quickly locate and test page elements through location identifiers and mapping relationships, reducing the time and errors of manually locating elements and improving the efficiency and accuracy of automated testing.
[0221] Some embodiments of the present invention also provide an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the method described above.
[0222] Some embodiments of the present invention also provide a computer-readable storage medium on which a computer program is stored, and which, when executed by a processor, implements the method described above.
[0223] Some embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the method described above.
[0224] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0225] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.
[0226] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0227] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0228] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0229] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0230] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0231] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.
[0232] 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 terminal device 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 terminal device. 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 terminal device that includes the aforementioned element.
[0233] The above provides a detailed description of the method, apparatus, device, medium, and product for application testing. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for testing an application, characterized in that, The method includes: Obtain relevant information about page elements in the application, including visual and non-visual information; Based on the relevant information, generate the positioning identifier of the page element; Establish a mapping relationship between the page elements and the location identifiers; Generate test cases for the location identifier, and during automated testing, call the test cases to test the page elements based on the mapping relationship; The step of obtaining relevant information about page elements in the application includes: Using automated testing tools, a global scan is performed on the code or code-generated pages in the application to extract the ID, CLASS, Xpth information and page structure information of the page elements; The step of generating the location identifier of the page element based on the relevant information includes: The automated testing tool obtains the ID, CLASS, and Xpth information of the page element, combines them into a complete string using an algorithm, encrypts it through hash conversion, and then converts it to base64 to form a unique identifier. The step of obtaining relevant information about page elements in the application also includes: By parsing the UI interaction diagram of the application, the visual information of the page elements is obtained. The visual information includes one or more of the following: UI style, element size, element position, function description, and user interaction process information. By scanning the page elements of the application, non-visual information of the page elements is obtained. The non-visual information includes one or more of the following: element identifier, element class name, element path, and page structure information.
2. The method according to claim 1, characterized in that, Before generating test cases for the location identifier, the method further includes: When a triggering event is detected, the scaling identifier of the page element is updated.
3. The method according to claim 2, characterized in that, The triggering event includes any one of the following: code update of the application, UI interaction graph update of the application.
4. The method according to any one of claims 1 to 3, characterized in that, The step of generating the location identifier of the page element based on the relevant information includes: Multiple pieces of information from the aforementioned related information are combined to obtain a string; Based on the string, generate the positioning identifier of the page element.
5. An apparatus for testing applications, characterized in that, The device includes: The relevant information acquisition module is used to acquire relevant information about page elements in the application, including visual information and non-visual information. A location identifier generation module is used to generate a location identifier for the page element based on the relevant information. A mapping relationship establishment module is used to establish a mapping relationship between the page elements and the positioning identifiers; An automated testing module is used to generate test cases for the location identifier, and during the automated testing process, it calls the test cases to test the page elements based on the mapping relationship. The relevant information acquisition module includes: Using automated testing tools, a global scan is performed on the code or code-generated pages in the application to extract the ID, CLASS, Xpth information and page structure information of the page elements; The location identifier generation module includes: The automated testing tool obtains the ID, CLASS, and Xpth information of the page element, combines them into a complete string using an algorithm, encrypts it through hash conversion, and then converts it to base64 to form a unique identifier. The relevant information acquisition module further includes: The interaction diagram parsing submodule is used to obtain the visual information of the page elements by parsing the UI interaction diagram of the application. The visual information includes any one or more of the following: UI style, element size, element position, function description, and user interaction process information. The page element scanning submodule is used to obtain non-visual information of the page elements by scanning the page elements of the application. The non-visual information includes any one or more of the following: element identifier, element class name, element path, and page structure information.
6. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the method as described in any one of claims 1 to 4.
8. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Test script generation method and device, electronic equipment and storage medium
CN117667741A
Interface element processing method and device and storage medium
CN117806942A