A Web application testing and repair method based on semantic path search
Through a method based on semantic path search, the text information of the click event sequence is recorded and analyzed, a keyword sequence is generated, and the semantic information of the business process is integrated to guide the path search for new pages, locate the target GUI elements, and solve the problem of GUI caused by the addition or deletion of pages. The problem of element positioning failure has improved the repair rate of web application test scripts.
Patent Information
- Application Number
- CN202110435076.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-22
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2041-04-22
AI Technical Summary
Existing web application test repair methods are difficult to effectively solve the problem of GUI element positioning failure caused by page addition or deletion, and the degree of automation repair is low and the cost is high.
A web application testing and repair method based on semantic path search is adopted. By recording and analyzing the text information of the click event sequence, a keyword sequence describing the business process is generated, and the semantic information of the business process is integrated to guide the path search for new pages and locate the target GUI element.
It effectively solves the problem of GUI element positioning failure caused by adding or deleting pages, significantly improves the repair rate of web application test scripts, and improves the repair effect.
Smart Images

Figure CN113032279B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of software analysis and testing in software engineering, in particular to the field of Web application testing, and specifically relates to a Web application testing and repairing method based on semantic path search. Background Art
[0002] In recent years, with the popularization of network technology and the development of new technologies for Web application development, the use of Web applications has become increasingly widespread. From the initial simple information publishing and information sharing to e-commerce, information management, search engines, service computing, multimedia, etc., Web applications have gradually penetrated into various fields of people's production and life, playing an increasingly important role. With the rapid development of Web applications, quality issues of Web applications have also arisen, which have a significant impact on people's production and life. As an important means of software quality assurance, Web application testing has become an important research direction.
[0003] Errors in Web applications can be found through testing. After errors are found, they need to be modified. After the modifications, regression testing is required to verify the correctness of the modifications. In fact, the evolution process of Web application versions can be regarded as a process of constantly finding errors, modifying and performing regression testing. In the process of Web application regression testing, most test scripts can be selected from the original test script set, but due to changes in Web applications, especially changes in the structure and content of some pages, some test scripts cannot be run directly and need to be repaired to a certain extent before they can be used. At present, script repair work is generally completed by manual analysis, which is costly and has a low degree of automation. Therefore, there is an urgent need for the support of Web application test repair methods, technologies and tools to improve the quality and productivity of Web application software.
[0004] Empirical studies have shown that the main reasons for the failure of Web application test scripts include failure to locate graphical user interface (GUI) elements, value anomalies, page reload, user session anomalies, dynamic script pop-up anomalies, etc. The most important reason is element location failure, accounting for 74% of the total number of failed scripts. At present, the research on Web application test script repair mainly focuses on the repair of script failures caused by GUI element location failure. Most of its Web application repair methods adopt a differential testing strategy, that is, based on the comparison of GUI element information in the pages of the new and old versions of the application, such as comparing the attribute information of the GUI element itself, or comparing the edit distance of the GUI element on the DOM tree, or comparing the visual image of the GUI element, to locate the target GUI element. Choudhary et al. proposed a Web application failure repair method based on GUI element attribute comparison and a corresponding tool - WATER. This method can semi-automatically provide suggestions for repairing scripts by analyzing the differences in GUI element attributes during the execution of the new and old versions of the test script. Stocco et al. proposed a Web application repair method and tool based on GUI element image comparison - VISTA. This method improves the repair rate to a certain extent, but if the element style changes significantly or the page layout is greatly modified, the method is almost ineffective.
[0005] In the process of Web application evolution, new pages are often added or outdated pages are deleted. Since the existing methods only consider finding similar GUI elements in the current page, they cannot solve the problem of script invalidation repair caused by page addition or deletion. Considering that simply adding page paths cannot guarantee the effectiveness of repair, it is necessary to integrate the semantic information of business processes to guide path search, improve the repair effect, and thus improve the repair rate of Web application test scripts. Summary of the invention
[0006] In view of the shortcomings of the above repair methods, the present invention proposes a Web application test repair method based on semantic path search. Compared with the existing methods, the method of the present invention guides the path search for new pages by integrating the semantic information of the business process to be tested during the test script repair process, and finds and locates the target GUI element on the new page. The method of the present invention can effectively solve the problem of GUI element positioning failure caused by adding or deleting pages, and significantly improve the repair rate of Web application test scripts.
[0007] The technical solution of the present invention is:
[0008] A web application test and repair method based on semantic path search, the method comprising the following steps:
[0009] Step (1) Given a Web application test script, run the test script on the original version, and analyze and extract the GUI elements operated by each script statement and the keyword sequence information describing the business process to be tested in the page in turn;
[0010] Step (2) runs the test script on the new version to check whether each GUI element operated by it is correctly positioned. If the positioning fails, a method based on element similarity calculation is first used to find and locate the target GUI element on the current page;
[0011] Step (3) If step (2) fails, the keyword sequence semantic information is integrated, and the backtracking heuristic method is used to guide the path search for new related pages, and the method based on element similarity calculation is used on the new version to find and locate the target GUI element;
[0012] Step (4) repairs, generates and verifies the test script of the new version of the Web application based on the target GUI element and semantic path information.
[0013] Furthermore, the step (1) specifically includes the following steps:
[0014] 2.1 Given a Web application test script, run the test script on the original version of the application, and obtain the main attributes and text information of the GUI elements operated by each test script statement. The main attributes include tag, id, class, name, value, type, title, text and XPath path;
[0015] 2.2 For each clickable event in the test script, record the text in the text, title, name, value, id and class attribute values of the corresponding GUI element as keyword text information, and generate a key text sequence based on the execution order of the events.
[0016] Furthermore, the step (2) specifically includes the following steps:
[0017] 3.1 Run the original test script on the new version of the Web application. For the script statements where GUI element positioning fails, calculate the structural and semantic comprehensive similarity between the original GUI element and each GUI element in the current page, and select the current page GUI element with the highest similarity score as the candidate element;
[0018] 3.2 If the structural and semantic similarity of the candidate GUI element in the current page is greater than a given threshold, it will be returned and used as the target GUI element.
[0019] Furthermore, the step (3) specifically includes the following steps:
[0020] 4.1 If the target GUI element is not found in the current page of the application, the keyword corresponding to the current page is taken out from the keyword sequence, and the backtracking heuristic method is used to search for the user interface page state that is semantically related to the current keyword;
[0021] 4.2 During the search process, the event with the highest semantic similarity to the current keyword in the state of the page to be expanded is selected for expansion, a new page is generated, the event execution sequence is updated, the structural and semantic comprehensive similarity between the original GUI element and each GUI element in the new page is calculated, and based on this, GUI elements with a similarity higher than a given threshold are searched as candidate GUI elements; if a candidate GUI element is found, it is returned;
[0022] During the search process, if all events in the current page to be expanded have been triggered, then go back to the previous page and search for other paths; if the generated new page is semantically related to the current keyword, then a trial is performed. When the trial similarity is greater than a certain threshold, the trial is successful and the path is repaired according to the event execution sequence; otherwise, go back to the previous page and try again;
[0023] If the current event is semantically related to the previous keyword, and the new page after the current event is expanded is also related to the keyword, then the search continues along the new page, that is, the new page is set as the current page to be expanded; if the new page after the current event is expanded is not related to the previous keyword, then go back to the previous page and select other paths for search;
[0024] 4.3 If there are no pages to continue searching, the page status search is continued using the breadth-first search strategy. When the set maximum search time or maximum search depth is reached and no similar elements are found, the path is considered to have been deleted. At this time, return and continue to repair the next statement.
[0025] Furthermore, the step (4) specifically includes the following steps:
[0026] 5.1 For the target GUI elements and path information found during the repair process, obtain the event sequence on the path, convert it into Selenium script statement format, and regenerate the Web application test script;
[0027] 5.2 Verify the regenerated web application test script. If it can run successfully on the Selenium automated testing framework, the repair is successful.
[0028] The beneficial effects of the present invention are as follows: the present invention generates a keyword sequence describing the business process by recording and analyzing the text information of click sequence events, and on this basis integrates the business process semantic information to guide the path search for new pages, and locates the target GUI element on the new page, thereby effectively solving the problem of GUI element positioning failure caused by adding or deleting pages, improving the repair effect, and increasing the repair rate of Web application test scripts. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a flow chart for implementing the method of the present invention.
[0030] Figure 2 This is a test script for the "Add Account" business process of PPMA v5.12 and v5.13. DETAILED DESCRIPTION
[0031] The present invention generates a keyword sequence describing the business process by extracting text sequences of GUI elements and click events, and then integrates the business process semantic information to guide the path search for new pages and locate the target GUI element on the new page, thereby effectively solving the problem of GUI element positioning failure caused by page addition or deletion, improving the repair effect, and increasing the repair rate of Web application test scripts.
[0032] The present invention mainly includes an embedded browser module, an information extraction module, a GUI element positioning module, a script repair verification module, and a semantic path search module. The embedded browser module is used to simulate the interaction between a user and a browser, the information extraction module is used to extract information such as GUI elements and keyword sequences of a business process to be tested, the GUI element positioning module is used to locate a target GUI element, the script repair verification module is used to repair the script and verify its validity, and the semantic path search module is used to search for new pages related to the business process to be tested. The information extraction module executes the test case script on the original version V, intercepts and extracts relevant structure and semantic information using aspect-oriented programming technology, and outputs an XML file that records GUI element information and keyword sequence information of the business to be tested. The element positioning module calculates the structural and semantic comprehensive similarity of the GUI element to find similar GUI elements in the pages in the new version V'. If a similar GUI element is found, the target GUI element is output for repairing the invalid script. The script repair verification module replaces the original GUI element with the target GUI element, supplements the relevant test script statement with the path information obtained by the semantic search, repairs the invalid script, and executes the test script on the new version V' in a single step to verify the validity of the test repair script. The semantic path search module integrates the keyword sequence information of the business to be tested and uses the backtracking heuristic method to guide the path search for new related pages.
[0033] Password Manager (PPMA) is a typical Web application, whose main function is a password management system, including functions such as adding new accounts, deleting accounts, and modifying account passwords. The following "adding new accounts" business process is used as an example to illustrate the method of the present invention. Figure 2 (a) and (b) are the test scripts for the "Add Account" business process in PPMA v5.12 and PPMA v5.13, respectively. In the original version of PPMA v5.12, after the tester verifies the login, he enters the main function interface to input relevant information and clicks the Submit button to complete the "Add Account" function. In the new version of PPMA v5.13, the layout of the main function interface has changed significantly. After clicking the "Add Entry" menu button at the top of the page, you enter the newly added information filling page, enter relevant information on this page, and then click the Add button to complete the "Add Account" function. The original test script failed to run on the new version. The specific process of repairing the script using the method of the present invention is as follows:
[0034] 1. Extract GUI element information and click event text information
[0035] Run the original test script on PPMA v5.12 and record the GUI element information operated by each script statement, including the element attributes and text information. The attributes include tag, id, class, name, value, type, title, text and XPath path.
[0036] For each clickable event in the script statement, the text in the text, title, name, value, id and class attribute values of the GUI element is recorded as the keyword text information. The filtered keyword sequence is<Login, Add anew Account> . Then, the commonly used Chinese / English processing tools such as FundanNLP / StandFord CoreNLP are used to segment and filter the words in the keyword sequence, and the result is <{login}, {add, new, account}>. For each keyword, the word2vec technology is used to expand the segmentation results, and each word is expanded to 5 words with the highest semantic similarity. The results are: <{login (logon, logins, logout, password, passwords)}>, <{add(adding, create, incorporate, generate, give)}, {new (pxnew, bynew,australianew, myrth, actornew)}, {account (accounts, explanation, insight,enquiry, consideration)}>.
[0037] 2. Find and locate candidate target GUI elements on the current page
[0038] (1) Run the original test script on the new version of the application. When running script statement 5, due to the addition of a new page, the GUI element with the id newiteminput cannot be located on the current page, and the test run is terminated.
[0039] (2) Using the information of the GUI element with the id newiteminput collected on version v5.12, the comprehensive similarity between the original GUI element and each GUI element in the current main function interface is calculated. Due to the low similarity value, no candidate GUI element is found.
[0040] 3. Use backtracking heuristics to guide the path search for the new page and locate the target GUI element on the new page
[0041] Take the keyword {add, new, account} corresponding to the current test script statement from the keyword sequence as the current keyword, set the current page to the page to be expanded, obtain the DOM elements of all clickable events in the current page, extract the text information in each DOM element, and perform word segmentation and filtering. Then calculate the semantic similarity between these texts and the current keyword {add, new, account}, sort them, select the clickable event "add item" with the highest semantic similarity, simulate clicking on the event, and enter the new information filling page. At this time, calculate the comprehensive similarity between the original GUI element and each GUI element in the current page, and find the GUI element with the id newiteminput.
[0042] 4. Repair invalid scripts and verify
[0043] According to the path information searched in step 5, obtain the event sequence on the path and save it in Selenium script format. Fix statement 5 and rerun it. The operation is successful.
[0044] 5. Check the remaining statements in the script one by one and make sure they run normally.
[0045] Experimental results show that compared with the existing repair methods WATER and VISTA, the method of the present invention can significantly improve the effectiveness of Web semantic testing and increase the repair rate.
[0046] The above embodiments are only preferred implementation modes of the present invention. It should be pointed out that ordinary technicians in this technical field can make several improvements and equivalent substitutions without departing from the principles of the present invention. These technical solutions after improvements and equivalent substitutions to the claims of the present invention all fall within the protection scope of the present invention.
Claims
1. A Web application testing and repairing method based on semantic path search, characterized in that: The method comprises the following steps: Step (1) Given a Web application test script, run the test script on the original version, and sequentially analyze and extract the GUI elements operated by each script statement and the keyword sequence information describing the business process to be tested in the page; Step (2) runs the test script on the new version to check whether each GUI element operated by it is correctly positioned. If the positioning fails, a method based on element similarity calculation is first used to search and locate the target GUI element on the current page; Step (3) If step (2) fails, the keyword sequence semantic information is integrated, and a backtracking heuristic method is used to guide the path search for new related pages, and a method based on element similarity calculation is used on the new version to find and locate the target GUI element; Step (4) repairing, generating and verifying the test script of the new version of the Web application according to the target GUI element and the semantic path information; Wherein, the step (1) specifically The following steps are involved: 2.1 Given a Web application test script, run the test script on the original version of the application, and perform the main attributes and text information of the GUI elements operated by each test script statement. The main attributes include tag, id, class, name, value, type, title, text and XPath path; 2.2 For each clickable event in the test script, record the text in the text, title, name, value, id and class attribute values of the corresponding GUI element as keyword text information, and generate a key text sequence based on the execution order of the event; in, The step (2) specifically comprises the following steps: 3.1 Run the original test script on the new version of the Web application, and for the script statements where GUI element positioning fails, calculate the structural and semantic comprehensive similarity between the original GUI element and each GUI element in the current page, and use the current page GUI element with the highest similarity score as the candidate element; 3.2 If the structural and semantic similarity of the candidate GUI element in the current page is greater than the given threshold, it will be returned and used as the target GUI element. Wherein, the step (3) specifically comprises the following steps: 4.1 If the target GUI element is not found in the current page of the application, the keyword corresponding to the current page is taken out from the keyword sequence, and the backtracking heuristic method is used to search for the user interface page state semantically related to the current keyword; 4.2 During the search process, the event with the highest semantic similarity to the current keyword in the state of the page to be expanded is selected for expansion, a new page is generated, the event execution sequence is updated, the structural and semantic comprehensive similarity between the original GUI element and each GUI element in the new page is calculated, and based on this, GUI elements with a similarity higher than a given threshold are searched as candidate GUI elements; if a candidate GUI element is found, it is returned; During the search process, if all events in the current page to be expanded have been triggered, then go back to the previous page and search for other paths; if the generated new page is semantically related to the current keyword, then a trial is performed. When the trial similarity is greater than a certain threshold, the trial is successful and the path is repaired according to the event execution sequence; otherwise, go back to the previous page and try again; If the current event is semantically related to the previous keyword, and the new page after the current event is expanded is also related to the keyword, then the search continues along the new page, that is, the new page is set as the current page to be expanded; if the new page after the current event is expanded is not related to the previous keyword, then go back to the previous page and select other paths for search; 4.3 If there is no page to continue searching, the page status search is continued using the breadth-first search strategy. When the set maximum search time or maximum search depth is reached and no similar elements are found, the path is considered to have been deleted. At this time, return and continue to repair the next statement. Wherein, the step (4) specifically comprises the following steps: 5.1 For the target GUI elements and path information found during the repair process, obtain the event sequence on the path, convert it into Selenium script statement format, and regenerate the Web application test script; 5.2 Verify the regenerated Web application test script. If it can run successfully on the Selenium automated testing framework, the repair is successful.
Citation Information
Patent Citations
Web application test case generation method based on keyword sequence guided search
CN111694731A