Application program testing method and device, equipment, medium and product
By generating independent positioning identifiers and establishing mapping relationships, the problem of frequent failure of test cases in the prior art is solved, and the efficiency and accuracy of automated testing are improved.
Patent Information
- Application Number
- CN202411872618.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2044-12-18
AI Technical Summary
Existing automated testing tools rely on code-level positioning identification, resulting in frequent failure of test cases when application page iteration or code changes, increasing the workload and error rate of testers.
By obtaining relevant information about page elements in the application, generating independent positioning identifiers, and establishing a mapping relationship between page elements and positioning identifiers, generating test cases for positioning identifiers, and realizing automated testing.
Reduces time and errors in manually positioning elements, improves the efficiency and accuracy of automated testing, and reduces the impact of page iteration on test cases.
Smart Images

Figure CN119862118A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of application testing, and in particular to a method, device, equipment, medium and product for application testing. Background Art
[0002] In the field of software development and testing, automated testing tools are often used to test applications. The application of automated testing tools has become an important means to improve testing efficiency and quality.
[0003] In the prior art, current mainstream automated testing tools generally use location tags to identify elements on the page in order to perform corresponding test operations. However, existing location tags are closely dependent on the code level. When the page code in the application is changed, they may be affected, thereby causing the test case to fail.
[0004] Moreover, with the rapid development of mobile Internet, the iteration speed of pages in applications is accelerating, and the page structure and element identification need to be frequently modified and adjusted during the development process. For testers, they need to constantly update the element positioning information in the test cases to adapt to the changes in the pages. This process is not only tedious and time-consuming, but also prone to errors, which seriously affects the efficiency and accuracy of testing. Summary of the invention
[0005] In view of the above problems, a method, device, equipment, medium and product for application testing are proposed to overcome the above problems or at least partially solve the above problems, including:
[0006] A method for testing an application program, the method comprising:
[0007] Get information about page elements in the application;
[0008] Generate a location identifier of the page element according to the relevant information;
[0009] Establishing a mapping relationship between the page element and the positioning identifier;
[0010] A test case for the positioning identifier is generated, and during the automated testing process, the test case is called based on the mapping relationship to test the page element.
[0011] Optionally, before generating a test case for the positioning identifier, the method further includes:
[0012] When a trigger event is detected, the calibration identifier of the page element is updated.
[0013] Optionally, the triggering event includes any one of the following: code update of the application, update of the UI interaction diagram of the application.
[0014] Optionally, generating a location identifier of the page element according to the relevant information includes:
[0015] Combining multiple pieces of information in the related information to obtain a character string;
[0016] A location identifier of the page element is generated according to the character string.
[0017] Optionally, the relevant information includes visual information, and obtaining relevant information of page elements in the application includes:
[0018] By parsing the UI interaction diagram of the application, 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 of 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, page structure information.
[0023] A device for testing an application program, the device comprising:
[0024] Related information acquisition module, used to obtain relevant information of page elements in the application;
[0025] A positioning mark generating module, used for generating a positioning mark of the page element according to the relevant information;
[0026] A mapping relationship establishing module, used to establish a mapping relationship between the page element and the positioning identifier;
[0027] The automated testing module is used to generate a test case for the positioning identifier, and in the process of automated testing, based on the mapping relationship, call the test case to test the page element.
[0028] An electronic device comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the method described above when executed by the processor.
[0029] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0030] A computer program product comprises a computer program, wherein when the computer program is executed by a processor, the computer program implements the method as described above.
[0031] The embodiments of the present invention have the following advantages:
[0032] In an embodiment of the present invention, by obtaining relevant information of page elements in an application; generating a location identifier of the page element based on the relevant information; establishing a mapping relationship between the page element and the location identifier; generating a test case for the location identifier, and in the process of automated testing, calling the test case to test the page element based on the mapping relationship, it is achieved that the page element can be quickly located and tested through the location identifier and the mapping relationship, thereby reducing the time and errors of manually locating the elements and improving the efficiency and accuracy of automated testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0034] Figure 1 is a flowchart of the steps of a method for testing an application program provided by some embodiments of the present invention;
[0035] Figure 2 is a flowchart of a method for testing an application program provided by some embodiments of the present invention;
[0036] Figure 3 is a flowchart of steps of another method for application testing provided by some embodiments of the present invention;
[0037] Figure 4 is a flowchart of steps of another method for application testing provided by some embodiments of the present invention;
[0038] Figure 5 It is a structural block diagram of an application testing device provided by some embodiments of the present invention. DETAILED DESCRIPTION
[0039] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0040] In the related art, since element location identifiers (ID, CLASS, Xpath) are too dependent on the code level, test cases need to frequently adjust element locations during page iteration, which increases the workload of testers.
[0041] Among them, ID identification positioning: ID is the unique identifier of an element in an HTML or XML document, which has a high degree of specificity and stability. During the development process, the ID is explicitly bound and generated by the developer in the code.
[0042] CLASS identification positioning: CLASS is another element positioning method, which allows the same class name to be assigned to multiple elements, thereby achieving batch operations. Unlike ID, the generation and management of CLASS is relatively flexible, but this also leads to relatively low stability in its positioning. When the page structure or style changes, the CLASS identification may be affected, requiring testers to update test cases.
[0043] Xpath identification positioning: Xpath is an element positioning method based on the page hierarchy. It generates a path expression based on the position of the element in the DOM tree. Although Xpath provides powerful positioning capabilities, it relies on the page hierarchy generated by user operations. Therefore, when the page element hierarchy changes, the Xpath path will also change, resulting in unreliable positioning.
[0044] In an embodiment of the present invention, a method for independently mapping element location identifiers is proposed. By establishing a mapping table, combining a UI (User Interface) interaction diagram with a configuration file to extract a page structure, location identifiers such as ID, CLASS, and Xpath are mapped to a location identifier independent of the code level, and the independent identifier is associated with the original location identifier to form a mapping table. When the page is iterated or the original identifier changes, the mapping table is automatically updated to ensure the accuracy of element positioning. In subsequent tests, only independent mapping identifiers need to be used, and the development code level is separated.
[0045] Through the embodiments of the present invention, when writing test cases, testers only need to pay attention to the mapped independent element positioning identifiers and write according to the independent identifiers without paying attention to the specific implementation of the elements at the code level; when the identifiers at the code level are changed, the test cases do not need to be modified. This can effectively reduce the impact of page iterations on automated test cases, improve test efficiency, and reduce the workload of testers. At the same time, it can also improve the accuracy and stability of element positioning, ensuring the smooth progress of automated testing.
[0046] The present invention will be further described below in conjunction with the accompanying drawings:
[0047] Reference Figure 1 , shows a flowchart of a method for testing an application program provided by some embodiments of the present invention, which may specifically include the following steps:
[0048] Step 101, obtaining relevant information of page elements in the application.
[0049] During the development or testing process, 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, pictures, etc.), thereby helping developers better understand and optimize the interface layout and interactive design of the application. Or provide testers with necessary element information to write and execute automated test scripts to ensure the quality and stability of the application.
[0050] For example, you can use automated testing tools to perform a global scan of the code in the application or the page generated by the code to extract the element's ID, CLASS, Xpth information, and page structure information (such as HTML information, HyperText Markup Language, a standard markup language for creating and designing web pages)
[0051] Among them, automated testing tools (such as Selenium, Appium, etc.) can provide APIs for locating and operating page elements in applications. These tools can support multiple positioning methods (such as ID, CLASS, XPath, etc.) and allow testers to write scripts to simulate user operations and verify the behavior of the application.
[0052] In some embodiments of the present invention, the relevant information includes visual information, and obtaining the relevant information of the page elements in the application includes: obtaining the visual information of the page elements by parsing the UI interaction diagram of the application.
[0053] Among them, visual information refers to the various visual features presented by page elements on the user interface. These features may include but are not limited to the element's color, shape, size, border, shadow, transparency, font style and size, and resolution of pictures 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, how users interact with these elements (such as clicking, sliding, etc.), and the events and responses triggered by these interactions.
[0055] In practical applications, the UI interaction diagram can be parsed through parsing scripts to extract the 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] Among them, UI style refers to the appearance and style of the user interface, including color, font, layout, icons, etc. Element size refers to the size of each element on the UI interface (such as buttons, text boxes, pictures, etc.). Element position refers to the position relationship of each element on the UI interface relative to other elements or the entire interface. Functional description refers to the element function information conveyed to users through visual means (such as text, icons, etc.).
[0058] User interaction process information refers to the interaction process information generated when the user operates the UI interface, such as click, slide, drag and other actions and 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 the page elements in the application includes: obtaining the non-visual information of the page elements by scanning the page elements of the application.
[0060] Among them, non-visual information refers to information that cannot be directly perceived through vision, which may include but is not limited to element attributes (such as whether it is clickable, selected, disabled, etc.), status (such as loading, error, success, etc.), association with other elements (such as parent-child relationship, sibling relationship, etc.) and functional description (such as what is the function of the button), etc.
[0061] As some examples, the page elements of the application may be scanned using an automated testing tool, and the non-visual information of the page elements may be extracted through the automated testing tool and stored 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, page structure information.
[0063] The element identifier refers to a unique identifier (such as ID) of each page element, which is 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 a page to the target element. It is used to describe the location of an element in the page structure.
[0066] Page structure information (such as HTML information) refers to the hierarchy and relationship 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 some examples, after obtaining relevant information about page elements in an application, the relevant information about the page elements obtained by scanning and parsing can be summarized to build a database containing all relevant information about the elements, and the database will continue to collect and update information.
[0068] Step 102: Generate a location identifier of the page element according to the relevant information.
[0069] As some examples, a location identifier can be a unique independent identifier, which refers to a string or data structure that can uniquely identify a page element. It can be constructed based on the attributes of the page element (such as ID, CLASS, Xpath, etc.) and is used to accurately locate the element in subsequent operations.
[0070] In some embodiments of the present invention, generating the location identifier of the page element according to the relevant information includes: combining multiple information in the relevant information to obtain a character string; and generating the location identifier of the page element according to the character string.
[0071] In practical applications, relevant information can be analyzed and multiple information related to page elements can be combined together to form a more complete and specific description.
[0072] Here, a string refers to a text sequence obtained by combining multiple related information, and this string contains enough information to generate a unique independent identifier.
[0073] For example, through automated testing tools, all identifiers of an element (ID+CLASS+Xpath) can be obtained, combined into a complete string through an algorithm, encrypted through hash conversion, and converted to base64 to form a unique independent identifier, that is, a unique signature.
[0074] For example, the ID of a page element is: Pow-Button, the CLASS is: Pow-text-blue-500, and the Xpath is: asdx123466.
[0075] Combine into a string using the algorithm:
[0076] ˋPow-Button\n+Pow-text-blue-500\n+asdx123466\n+${p configuration information}\n+${UI style}\nˋ.
[0077] After the above combined string is hashed and encrypted, base64 conversion is performed to generate a unique string identifier (location identifier / unique independent identifier).
[0078] Step 103: Establish a mapping relationship between the page element and the positioning identifier.
[0079] The mapping relationship refers to a corresponding relationship, which allows the page element to be indirectly referenced through the positioning identifier by connecting the page element with the positioning identifier.
[0080] For example, the mapping relationship can be a simple key-value pair set (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, a dictionary, etc.).
[0081] In actual applications, the database can be traversed to extract features for each element in the database, and the unique features of each element (such as ID+CLASS+Xpath) can be extracted to form a unique independent identifier (positioning identifier). Testers can customize the name of the key independent identifier and other related information. After the name is determined, a mapping is formed. This independent identifier uniquely represents an element and remains stable during the page iteration process and is not affected by code modifications. The mapping relationships of all elements are integrated and finally compiled into a mapping table and stored. The table will be used as a reference for element positioning during automated testing and will be updated and maintained when necessary.
[0082] Step 104: Generate a test case for the positioning identifier, and in the process of automated testing, call the test case based on the mapping relationship to test the page element.
[0083] A test case is a script or code snippet written for a specific test purpose, which contains the test input, expected output, and the steps required to execute the test. A test case can be used to verify whether a certain function of a system or application works as expected.
[0084] As some examples, corresponding test cases can be generated for page elements based on location identifiers, that is, location identifiers can be used in test cases to refer to corresponding page elements, and test information for the location identifiers, such as test operations, can be set.
[0085] During the automated testing process, based on the established mapping relationship, the corresponding test case is called to test the 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 paying attention to the code level.
[0086] When writing test cases, the testers only need to pay attention to the mapped independent element location identifiers and write according to the independent identifiers without paying attention to the specific implementation of the elements at the code level. Through the embodiments of the present invention, when the code level identifier changes, the test cases do not need to be modified.
[0087] After the test is completed, 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 a test case for the positioning 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 program, update of a UI interaction diagram of the application program.
[0090] Among them, the application code update refers to the modification or update of the application source code. The application UI interaction diagram update refers to the modification or update of the application user interface (UI) interaction logic, such as the adjustment of the page layout, the addition or deletion of page elements, etc.
[0091] As some examples, when a trigger event is detected, the calibration mark of the affected page element can be updated automatically or manually by the developer. After updating the calibration mark, verification can also be performed to ensure that the new mark can accurately locate the corresponding page element.
[0092] As some examples, when a business code iteration (code update of the application) is submitted, the automated program of gitlab (an open source code hosting and management platform based on Git) will be triggered to notify the tester, and the changes of information such as ID / CLASS in the code will be automatically captured through the workflow. When the UI interaction diagram (UI interaction diagram of the application is updated) is updated, the upload script analysis is also triggered to update the basic information of the element and synchronously update the location identifier in the mapping table.
[0093] Among them, ID / CLASS information changes refer to changes that may occur due to developers modifying codes, product modifications, etc. For example, the original ID: Pow-text-1 will be changed to Pow-new-text-2.
[0094] In some examples, the code development tool Git is used for code management. After the product is developed and business updates are completed, such as changing the color of a button from dark blue to light blue, the Class will be changed in the corresponding code from the original "Pow-blue-1" to "Pow-blue-2". After the code is submitted to Git, it can be learned that there are new submissions and code updates. The AI workflow deployed on Git can be compared with the new submissions and code updates. If the updated content involves changes to identification elements such as ID / CLASS, the updated elements and their corresponding related information are determined based on the updated content. After being combined into a complete string through an algorithm, they are encrypted into base64 through hash conversion as a new positioning identifier for the element, and updated to the latest mapping table.
[0095] In an embodiment of the present invention, by obtaining relevant information of page elements in an application; generating a location identifier of the page element based on the relevant information; establishing a mapping relationship between the page element and the location identifier; generating a test case for the location identifier, and in the process of automated testing, calling the test case to test the page element based on the mapping relationship, it is achieved that the page element can be quickly located and tested through the location identifier and the mapping relationship, thereby reducing the time and errors of manually locating the elements and improving the efficiency and accuracy of automated testing.
[0096] The following is combined with Figure 2 The present invention is exemplified as follows:
[0097] Step 201, page element scanning and information extraction.
[0098] Step 202, extract the ID, CLASS, and Xpth of the page element, and extract the visual features (visual information) of the element.
[0099] Step 203: element information (related information) is summarized.
[0100] Step 204: an independent element location identifier (location identifier) is generated.
[0101] Step 205: Establish a mapping table.
[0102] Step 206 , checking whether it is updated, if yes, automatically updating the completion mechanism and returning to step 201 , otherwise proceeding to step 207 .
[0103] Step 207, generating a final result for testing.
[0104] Reference Figure 3 , shows a flowchart of another method for testing an application program provided by some embodiments of the present invention, which may specifically include the following steps:
[0105] Step 301, obtaining relevant information of page elements in the application.
[0106] During the development or testing process, 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, pictures, etc.), thereby helping developers better understand and optimize the interface layout and interactive design of the application. Or provide testers with necessary element information to write and execute automated test scripts to ensure the quality and stability of the application.
[0107] For example, you can use automated testing tools to perform a global scan of the code in the application or the page generated by the code to extract the element's ID, CLASS, Xpth information, and page structure information (such as HTML information, HyperText Markup Language, a standard markup language for creating and designing web pages)
[0108] Among them, automated testing tools (such as Selenium, Appium, etc.) can provide APIs for locating and operating page elements in applications. These tools can support multiple positioning methods (such as ID, CLASS, XPath, etc.) and allow testers to write scripts to simulate user operations and verify the behavior of the application.
[0109] In some embodiments of the present invention, the relevant information includes visual information, and obtaining the relevant information of the page elements in the application includes: obtaining the visual information of the page elements by parsing the UI interaction diagram of the application.
[0110] Among them, visual information refers to the various visual features presented by page elements on the user interface. These features may include but are not limited to the element's color, shape, size, border, shadow, transparency, font style and size, and resolution of pictures 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, how users interact with these elements (such as clicking, sliding, etc.), and the events and responses triggered by these interactions.
[0112] In practical applications, the UI interaction diagram can be parsed through parsing scripts to extract the 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] Among them, UI style refers to the appearance and style of the user interface, including color, font, layout, icons, etc. Element size refers to the size of each element on the UI interface (such as buttons, text boxes, pictures, etc.). Element position refers to the position relationship of each element on the UI interface relative to other elements or the entire interface. Functional description refers to the element function information conveyed to users through visual means (such as text, icons, etc.).
[0115] User interaction process information refers to the interaction process information generated when the user operates the UI interface, such as click, slide, drag and other actions and 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 the page elements in the application includes: obtaining the non-visual information of the page elements by scanning the page elements of the application.
[0117] Among them, non-visual information refers to information that cannot be directly perceived through vision, which may include but is not limited to element attributes (such as whether it is clickable, selected, disabled, etc.), status (such as loading, error, success, etc.), association with other elements (such as parent-child relationship, sibling relationship, etc.) and functional description (such as what is the function of the button), etc.
[0118] As some examples, the page elements of the application may be scanned using an automated testing tool, and the non-visual information of the page elements may be extracted through the automated testing tool and stored 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, page structure information.
[0120] The element identifier refers to a unique identifier (such as ID) of each page element, which is 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 a page to the target element. It is used to describe the location of an element in the page structure.
[0123] Page structure information (such as HTML information) refers to the hierarchy and relationship 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 some examples, after obtaining relevant information about page elements in an application, the relevant information about the page elements obtained by scanning and parsing can be summarized to build a database containing all relevant information about the elements, and the database will continue to collect and update information.
[0125] Step 302: Generate a location identifier of the page element according to the relevant information.
[0126] As some examples, a location identifier can be a unique independent identifier, which refers to a string or data structure that can uniquely identify a page element. It can be constructed based on the attributes of the page element (such as ID, CLASS, Xpath, etc.) and is used to accurately locate the element in subsequent operations.
[0127] In some embodiments of the present invention, generating the location identifier of the page element according to the relevant information includes: combining multiple information in the relevant information to obtain a character string; and generating the location identifier of the page element according to the character string.
[0128] In practical applications, relevant information can be analyzed and multiple information related to page elements can be combined together to form a more complete and specific description.
[0129] Here, a string refers to a text sequence obtained by combining multiple related information, and this string contains enough information to generate a unique independent identifier.
[0130] For example, through automated testing tools, all identifiers of an element (ID+CLASS+Xpath) can be obtained, combined into a complete string through an algorithm, encrypted through hash conversion, and converted to base64 to form a unique independent identifier, that is, a unique signature.
[0131] For example, the ID of a page element is: Pow-Button, the CLASS is: Pow-text-blue-500, and the Xpath is: asdx123466.
[0132] Combine into a string using the algorithm:
[0133] ˋPow-Button\n+Pow-text-blue-500\n+asdx123466\n+${p configuration information}\n+${UI style}\nˋ.
[0134] After the above combined string is hashed and encrypted, base64 conversion is performed to generate a unique string identifier (location identifier / unique independent identifier).
[0135] Step 303: Establish a mapping relationship between the page element and the positioning identifier.
[0136] The mapping relationship refers to a corresponding relationship, which allows the page element to be indirectly referenced through the positioning identifier by connecting the page element with the positioning identifier.
[0137] For example, the mapping relationship can be a simple key-value pair set (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, a dictionary, etc.).
[0138] In actual applications, the database can be traversed to extract features for each element in the database, and the unique features of each element (such as ID+CLASS+Xpath) can be extracted to form a unique independent identifier (positioning identifier). Testers can customize the name of the key independent identifier and other related information. After the name is determined, a mapping is formed. This independent identifier uniquely represents an element and remains stable during the page iteration process and is not affected by code modifications. The mapping relationships of all elements are integrated and finally compiled into a mapping table and stored. The table will be used as a reference for element positioning during automated testing and will be updated and maintained when necessary.
[0139] Step 304: When a triggering event is detected, the calibration identifier of the page element is updated.
[0140] In some embodiments of the present invention, the triggering event includes any one of the following: code update of the application program, update of a UI interaction diagram of the application program.
[0141] Among them, the application code update refers to the modification or update of the application source code. The application UI interaction diagram update refers to the modification or update of the application user interface (UI) interaction logic, such as the adjustment of the page layout, the addition or deletion of page elements, etc.
[0142] As some examples, when a trigger event is detected, the calibration mark of the affected page element can be updated automatically or manually by the developer. After updating the calibration mark, verification can also be performed to ensure that the new mark can accurately locate the corresponding page element.
[0143] As some examples, when a business code iteration (code update of the application) is submitted, the automated program of gitlab (an open source code hosting and management platform based on Git) will be triggered to notify the tester, and the changes of information such as ID / CLASS in the code will be automatically captured through the workflow. When the UI interaction diagram (UI interaction diagram of the application is updated) is updated, the upload script analysis is also triggered to update the basic information of the element and synchronously update the location identifier in the mapping table.
[0144] Among them, ID / CLASS information changes refer to changes that may occur due to developers modifying codes, product modifications, etc. For example, the original ID: Pow-text-1 will be changed to Pow-new-text-2.
[0145] In some examples, the code development tool Git is used for code management. After the product is developed and business updates are completed, such as changing the color of a button from dark blue to light blue, the Class will be changed in the corresponding code from the original "Pow-blue-1" to "Pow-blue-2". After the code is submitted to Git, it can be learned that there are new submissions and code updates. The AI workflow deployed on Git can be compared with the new submissions and code updates. If the updated content involves changes to identification elements such as ID / CLASS, the updated elements and their corresponding related information are determined based on the updated content. After being combined into a complete string through an algorithm, they are encrypted into base64 through hash conversion as a new positioning identifier for the element, and updated to the latest mapping table.
[0146] Step 305: Generate a test case for the positioning identifier, and in the process of automated testing, call the test case based on the mapping relationship to test the page element.
[0147] A test case is a script or code snippet written for a specific test purpose, which contains the test input, expected output, and the steps required to execute the test. A test case can be used to verify whether a certain function of a system or application works as expected.
[0148] As some examples, corresponding test cases can be generated for page elements based on location identifiers, that is, location identifiers can be used in test cases to refer to corresponding page elements, and test information for the location identifiers, such as test operations, can be set.
[0149] During the automated testing process, based on the established mapping relationship, the corresponding test case is called to test the 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 paying attention to the code level.
[0150] When writing test cases, the testers only need to pay attention to the mapped independent element location identifiers and write according to the independent identifiers without paying attention to the specific implementation of the elements at the code level. Through the embodiments of the present invention, when the code level identifier changes, the test cases do not need to be modified.
[0151] After the test is completed, 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 an embodiment of the present invention, relevant information of a page element in an application is obtained; a location identifier of the page element is generated based on the relevant information; a mapping relationship between the page element and the location identifier is established; when a trigger event is detected, the calibration identifier of the page element is updated; a test case for the location identifier is generated, and during an automated test, the test case is called to test the page element based on the mapping relationship, thereby achieving rapid location and testing of the page element through the location identifier and the mapping relationship, reducing the time and errors of manually locating the element, and improving the efficiency and accuracy of automated testing.
[0153] Reference Figure 4 , shows a flowchart of the steps of another method for application testing provided by some embodiments of the present invention, which may specifically include the following steps:
[0154] Step 401, obtaining relevant information of page elements in the application.
[0155] During the development or testing process, 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, pictures, etc.), thereby helping developers better understand and optimize the interface layout and interactive design of the application. Or provide testers with necessary element information to write and execute automated test scripts to ensure the quality and stability of the application.
[0156] For example, you can use automated testing tools to perform a global scan of the code in the application or the page generated by the code to extract the element's ID, CLASS, Xpth information, and page structure information (such as HTML information, HyperText Markup Language, a standard markup language for creating and designing web pages)
[0157] Among them, automated testing tools (such as Selenium, Appium, etc.) can provide APIs for locating and operating page elements in applications. These tools can support multiple positioning methods (such as ID, CLASS, XPath, etc.) and allow testers to write scripts to simulate user operations and verify the behavior of the application.
[0158] In some embodiments of the present invention, the relevant information includes visual information, and obtaining the relevant information of the page elements in the application includes: obtaining the visual information of the page elements by parsing the UI interaction diagram of the application.
[0159] Among them, visual information refers to the various visual features presented by page elements on the user interface. These features may include but are not limited to the element's color, shape, size, border, shadow, transparency, font style and size, and resolution of pictures 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, how users interact with these elements (such as clicking, sliding, etc.), and the events and responses triggered by these interactions.
[0161] In practical applications, the UI interaction diagram can be parsed through parsing scripts to extract the 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] Among them, UI style refers to the appearance and style of the user interface, including color, font, layout, icons, etc. Element size refers to the size of each element on the UI interface (such as buttons, text boxes, pictures, etc.). Element position refers to the position relationship of each element on the UI interface relative to other elements or the entire interface. Functional description refers to the element function information conveyed to users through visual means (such as text, icons, etc.).
[0164] User interaction process information refers to the interaction process information generated when the user operates the UI interface, such as click, slide, drag and other actions and 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 the page elements in the application includes: obtaining the non-visual information of the page elements by scanning the page elements of the application.
[0166] Among them, non-visual information refers to information that cannot be directly perceived through vision, which may include but is not limited to element attributes (such as whether it is clickable, selected, disabled, etc.), status (such as loading, error, success, etc.), association with other elements (such as parent-child relationship, sibling relationship, etc.) and functional description (such as what is the function of the button), etc.
[0167] As some examples, the page elements of the application may be scanned using an automated testing tool, and the non-visual information of the page elements may be extracted through the automated testing tool and stored 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, page structure information.
[0169] The element identifier refers to a unique identifier (such as ID) of each page element, which is 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 a page to the target element. It is used to describe the location of an element in the page structure.
[0172] Page structure information (such as HTML information) refers to the hierarchy and relationship 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 some examples, after obtaining relevant information about page elements in an application, the relevant information about the page elements obtained by scanning and parsing can be summarized to build a database containing all relevant information about the elements, and the database will continue to collect and update information.
[0174] Step 402: Combine multiple pieces of information in the related information to obtain a character string.
[0175] In practical applications, relevant information can be analyzed and multiple information related to page elements can be combined together to form a more complete and specific description.
[0176] Here, a string refers to a text sequence obtained by combining multiple related information, and this string contains enough information to generate a unique independent identifier.
[0177] Step 403: Generate a location identifier of the page element according to the character string.
[0178] As some examples, a location identifier can be a unique independent identifier, which refers to a string or data structure that can uniquely identify a page element. It can be constructed based on the attributes of the page element (such as ID, CLASS, Xpath, etc.) and is used to accurately locate the element in subsequent operations.
[0179] For example, through automated testing tools, all identifiers of an element (ID+CLASS+Xpath) can be obtained, combined into a complete string through an algorithm, encrypted through hash conversion, and converted to base64 to form a unique independent identifier, that is, a unique signature.
[0180] For example, the ID of a page element is: Pow-Button, the CLASS is: Pow-text-blue-500, and the Xpath is: asdx123466.
[0181] Combine into a string using the algorithm:
[0182] `Pow-Button\n+Pow-text-blue-500\n+asdx123466\n+${p configuration information}\n+${UI style}\n`.
[0183] After the above combined string is hashed and encrypted, base64 conversion is performed to generate a unique string identifier (location identifier / unique independent identifier).
[0184] Step 404: Establish a mapping relationship between the page element and the positioning identifier.
[0185] The mapping relationship refers to a corresponding relationship, which allows the page element to be indirectly referenced through the positioning identifier by connecting the page element with the positioning identifier.
[0186] For example, the mapping relationship can be a simple key-value pair set (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, a dictionary, etc.).
[0187] In actual applications, the database can be traversed to extract features for each element in the database, and the unique features of each element (such as ID+CLASS+Xpath) can be extracted to form a unique independent identifier (positioning identifier). Testers can customize the name of the key independent identifier and other related information. After the name is determined, a mapping is formed. This independent identifier uniquely represents an element and remains stable during the page iteration process and is not affected by code modifications. The mapping relationships of all elements are integrated and finally compiled into a mapping table and stored. The table will be used as a reference for element positioning during automated testing and will be updated and maintained when necessary.
[0188] Step 405: When a triggering event is detected, the calibration mark 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 program, update of a UI interaction diagram of the application program.
[0190] Among them, the application code update refers to the modification or update of the application source code. The application UI interaction diagram update refers to the modification or update of the application user interface (UI) interaction logic, such as the adjustment of the page layout, the addition or deletion of page elements, etc.
[0191] As some examples, when a trigger event is detected, the calibration mark of the affected page element can be updated automatically or manually by the developer. After updating the calibration mark, verification can also be performed to ensure that the new mark can accurately locate the corresponding page element.
[0192] As some examples, when a business code iteration (code update of the application) is submitted, the automated program of gitlab (an open source code hosting and management platform based on Git) will be triggered to notify the tester, and the changes of information such as ID / CLASS in the code will be automatically captured through the workflow. When the UI interaction diagram (UI interaction diagram of the application is updated) is updated, the upload script analysis is also triggered to update the basic information of the element and synchronously update the location identifier in the mapping table.
[0193] Among them, ID / CLASS information changes refer to changes that may occur due to developers modifying codes, product modifications, etc. For example, the original ID: Pow-text-1 will be changed to Pow-new-text-2.
[0194] In some examples, the code development tool Git is used for code management. After the product is developed and business updates are completed, such as changing the color of a button from dark blue to light blue, the Class will be changed in the corresponding code from the original "Pow-blue-1" to "Pow-blue-2". After the code is submitted to Git, it can be learned that there are new submissions and code updates. The AI workflow deployed on Git can be compared with the new submissions and code updates. If the updated content involves changes to identification elements such as ID / CLASS, the updated elements and their corresponding related information are determined based on the updated content. After being combined into a complete string through an algorithm, they are encrypted into base64 through hash conversion as a new positioning identifier for the element, and updated to the latest mapping table.
[0195] Step 406: Generate a test case for the positioning identifier, and in the process of automated testing, call the test case based on the mapping relationship to test the page element.
[0196] A test case is a script or code snippet written for a specific test purpose, which contains the test input, expected output, and the steps required to execute the test. A test case can be used to verify whether a certain function of a system or application works as expected.
[0197] As some examples, corresponding test cases can be generated for page elements based on location identifiers, that is, location identifiers can be used in test cases to refer to corresponding page elements, and test information for the location identifiers, such as test operations, can be set.
[0198] During the automated testing process, based on the established mapping relationship, the corresponding test case is called to test the 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 paying attention to the code level.
[0199] When writing test cases, the testers only need to pay attention to the mapped independent element location identifiers and write according to the independent identifiers without paying attention to the specific implementation of the elements at the code level. Through the embodiments of the present invention, when the code level identifier changes, the test cases do not need to be modified.
[0200] After the test is completed, 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 an embodiment of the present invention, relevant information of a page element in an application is obtained; multiple information in the relevant information is combined to obtain a character string; a location identifier of the page element is generated according to the character string; a mapping relationship between the page element and the location identifier is established; when a trigger event is detected, the calibration identifier of the page element is updated; a test case for the location identifier is generated, and during the automated testing process, the test case is called to test the page element based on the mapping relationship, thereby achieving rapid location and testing of the page element through the location identifier and the mapping relationship, reducing the time and errors of manually locating the element, and improving the efficiency and accuracy of the automated testing.
[0202] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0203] Reference Figure 5 , shows a schematic diagram of the structure of an application testing device provided by some embodiments of the present invention, which may specifically include the following modules:
[0204] Related information acquisition module 501, used to acquire related information of page elements in the application;
[0205] A positioning mark generating module 502 is used to generate a positioning mark of the page element according to the relevant information;
[0206] A mapping relationship establishing module 503, used to establish a mapping relationship between the page element and the positioning identifier;
[0207] The automated testing module 504 is used to generate a test case for the positioning identifier, and in the process of automated testing, based on the mapping relationship, call the test case to test the page element.
[0208] In some embodiments of the present invention, the device further comprises:
[0209] The trigger event detection module is used to update the calibration mark 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 program, update of a UI interaction diagram of the application program.
[0211] In some embodiments of the present invention, the positioning identifier generating module 502 includes:
[0212] An information combining submodule, used for combining multiple information in the related information to obtain a character string;
[0213] The positioning mark generating module is used to generate the positioning mark of the page element according to the character 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 graph parsing submodule is used to obtain the visual information of the page elements by parsing the UI interaction graph 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 of 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, page structure information.
[0220] In an embodiment of the present invention, by obtaining relevant information of page elements in an application; generating a location identifier of the page element based on the relevant information; establishing a mapping relationship between the page element and the location identifier; generating a test case for the location identifier, and in the process of automated testing, calling the test case to test the page element based on the mapping relationship, it is achieved that the page element can be quickly located and tested through the location identifier and the mapping relationship, thereby reducing the time and errors of manually locating the elements and improving the efficiency and accuracy of automated testing.
[0221] Some embodiments of the present invention further provide an electronic device, comprising a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the above method is implemented when the computer program is executed by the processor.
[0222] Some embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, and the computer program implements the above method when executed by a processor.
[0223] Some embodiments of the present invention further provide a computer program product, including a computer program, which implements the above method when executed by a processor.
[0224] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial 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, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0226] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0227] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product 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 codes.
[0228] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0229] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0230] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable terminal device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0231] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0232] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the above elements.
[0233] The above is a detailed introduction to the provided method, device, equipment, medium and product for application testing. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for application testing, characterized in that: The method comprises: Get information about page elements in the application; Generate a location identifier of the page element according to the relevant information; Establishing a mapping relationship between the page element and the positioning identifier; A test case for the positioning identifier is generated, and during the automated testing process, the test case is called based on the mapping relationship to test the page element.
2. The method according to claim 1, characterized in that Before generating a test case for the positioning identifier, the method further includes: When a trigger event is detected, the calibration 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 program, update of the UI interaction diagram of the application program.
4. The method according to any one of claims 1 to 3, characterized in that: Generating the location identifier of the page element according to the relevant information includes: Combining multiple pieces of information in the related information to obtain a character string; A location identifier of the page element is generated according to the character string.
5. The method according to claim 4, characterized in that The relevant information includes visual information, and obtaining relevant information of page elements in the application includes: By parsing the UI interaction diagram of the application, visual information of the page elements is obtained.
6. The method according to claim 5, characterized in that The visual information includes any one or more of the following: UI style, element size, element position, function description, and user interaction process information.
7. The method according to claim 4, characterized in that The relevant information includes non-visual information, and obtaining relevant information of page elements in the application includes: By scanning the page elements of the application, non-visual information of the page elements is obtained.
8. The method according to claim 7, characterized in that The non-visual information includes any one or more of the following: element identifier, element class name, element path, page structure information.
9. A device for application testing, characterized in that: The device comprises: Related information acquisition module, used to obtain relevant information of page elements in the application; A positioning mark generating module, used for generating a positioning mark of the page element according to the relevant information; A mapping relationship establishing module, used to establish a mapping relationship between the page element and the positioning identifier; The automated testing module is used to generate a test case for the positioning identifier, and in the process of automated testing, based on the mapping relationship, call the test case to test the page element.
10. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the method according to any one of claims 1 to 8 when executed by the processor.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
12. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
User interface test method and device, terminal and computer readable storage medium
CN113821453A
Test script generation method and device, electronic equipment and storage medium
CN117667741A
Interface element processing method and device and storage medium
CN117806942A
Automatic test frame assembly, method and electronic equipment
CN117971655A
Efficiently generating effective address translations for memory management test cases
US20180039579A1
Cited By
DOM (Document Object Model) element and visual element alignment and DOM element mapping method and device
CN121144180A