Web application testing and repair method based on GUI element similarity calculation

By combining the structure and semantic information of GUI elements in web application testing to calculate the comprehensive similarity, and finding and replacing the elements that failed to locate, the problem of low repair rate in the existing technology is solved, and the repair effect of web application test scripts is significantly improved.

CN113032280BActive Publication Date: 2024-11-15SOUTHEAST UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110435080.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-22
Publication Date
2024-11-15
Estimated Expiration
2041-04-22

AI Technical Summary

Technical Problem

Existing web application test repair methods fail to effectively utilize semantic information when GUI element positioning fails, resulting in low repair rate, especially when element style changes or page layout is greatly modified.

Method used

Using a comprehensive similarity calculation method based on GUI element structure and semantic information, the GUI element structure and semantic information of the test script in the original and new versions is analyzed, the comprehensive similarity between structure and semantics is calculated, and similar GUI elements are found to replace the positioning failure. elements, fix the test script.

Benefits of technology

It improves the accuracy of GUI element positioning analysis and the repair rate of web application test scripts, significantly improves the repair effect and improves the effectiveness of repair.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113032280B_ABST
    Figure CN113032280B_ABST
Patent Text Reader

Abstract

The present invention discloses a Web application test and repair method based on GUI element similarity calculation. Given a Web application test script, firstly, it is run on the original version application and the GUI element information operated by each script statement is recorded; then, the original test case script is run on the new version application, and for the script statements that fail to locate the GUI elements, the structural and semantic comprehensive similarity between the GUI elements in the original version and each GUI element in the current Web page is calculated, and the GUI elements with high comprehensive similarity are selected as target candidate GUI elements; finally, the failed GUI elements are replaced with the target candidate GUI elements, the test script is repaired, and the repaired test script is run on the new version of the Web application to verify the effectiveness of the repair. The present invention can significantly improve the repair rate of Web application test scripts by calculating the GUI element similarity, locating the target GUI element, and automatically repairing the Web application test script.
Need to check novelty before this filing date? Find Prior Art

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 GUI element similarity calculation. Background Art

[0002] With the popularization of network technology and the development of new technologies for Web application development, Web applications have been increasingly developed and used because they have many advantages, such as the ability to use the latest version of software without installation, maintenance and upgrades, and data persistence, security and easy sharing and access. 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] As we know, 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 elements based on the graphical user interface (GUI), value anomalies, page reload, user session anomalies, dynamic script pop-up anomalies, etc. The most important reason is failure to locate elements, 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 failure to locate GUI elements. 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 elements themselves, or comparing the edit distance of the GUI elements on the DOM tree, or comparing the visual images of the GUI elements, to locate the target GUI elements. 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 based on GUI element image comparison and a tool - 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, this method is almost ineffective.

[0005] Since the above methods only locate the target GUI element from the properties or image comparison of the GUI element during the repair process, without considering the semantic information of the GUI element itself, once the properties or images of the GUI element change slightly, it is impossible to perform effective repair. Therefore, it is necessary to integrate the semantic information of the GUI element to improve the accuracy of GUI element positioning analysis, thereby improving the repair rate of the Web application test script. 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 GUI element similarity calculation. Compared with the existing methods, the method of the present invention integrates GUI element semantic information during the test script repair process, calculates the structural and semantic comprehensive similarity of GUI elements, improves the accuracy of GUI element positioning analysis, improves the Web application test script repair effect, and increases the repair rate.

[0007] The technical solution of the present invention is:

[0008] A Web application testing and repairing method based on GUI element similarity calculation includes the following three steps:

[0009] Step (1) Given a Web application test script, run the test script on the original Web application version, and analyze and extract the structure and semantic information of the GUI elements operated by each test script statement in turn;

[0010] Step (2) locates the target GUI element, runs the original test script on the new version of the Web application, and checks whether each GUI element operated by it is correctly located. If the location fails, the information recorded in step (1) is used to calculate the structural and semantic comprehensive similarity between the original GUI element and the GUI element in the new version of the Web application page, and similar GUI elements are searched based on the similarity as candidate target GUI elements;

[0011] Step (3) replaces the GUI element that failed to be located with the candidate target GUI element, repairs the test script, and then runs it to verify the effectiveness of the repair.

[0012] Furthermore, the step (1) specifically includes the following steps:

[0013] Given a Web application test script, execute the test script on the original Web application version, analyze and extract the main attributes and text information of the GUI elements operated by each script statement. The main attributes include tag, id, class, name, value, type, title, text and XPath path.

[0014] Furthermore, the step (2) specifically includes the following steps:

[0015] 3.1 Execute the original test script on the new version of the Web application, and check whether the GUI elements operated by each script statement are located successfully;

[0016] 3.2 For the script statement that fails to locate the GUI element, calculate the comprehensive similarity sim(e,e′) between the original GUI element e in the script statement and each GUI element e′ in the current Web page, and select the GUI element whose comprehensive similarity value is greater than a given threshold as the candidate target GUI element;

[0017] The comprehensive similarity sim(e,e′) is the structural similarity sim dom (e,e′) and semantic similarity sim sem The linear combination of (e,e′) is calculated using formula (1):

[0018] sim(e,e′)=sim dom (e,e′)*ω+sim sem (e,e′)*(1-ω) (1)

[0019] Among them, ω represents the weight, sim dom(e,e′) represents the structural similarity, sim sem (e, e′) represents semantic similarity;

[0020] Structural similarity sim dom (e, e′) calculates the similarity between the positions of e and e′ in the DOM tree and other element attribute values, using formula (2):

[0021] sim dom (e,e′)=2*d*r / (d+r) (2)

[0022] Among them, r represents the ratio of the number of attributes that are the same as e and e′ to the total number of attributes, d represents the XPath edit distance between e and e′, and sim dom (e,e′) is the harmonic mean of r and d;

[0023] Semantic similarity sim sem (e, e′) calculates the semantic similarity of the description text information of e and e′, using formula (3):

[0024]

[0025] Among them, WS(e) and WS(e′) represent the word sets generated after the text describing e and e′ is segmented and stop words are removed, sim(w,w′) represents the cosine similarity value between word vectors w and w′, N represents the number of words in WS(e), and sim sem (e, e′) is the average value of the maximum word vector cosine similarity between the words in WS(e) and the words in WS(e′);

[0026] 3.3 Select GUI elements whose comprehensive similarity values ​​are greater than a given threshold as candidate target GUI elements, and sort them by comprehensive similarity values.

[0027] Furthermore, the step (3) specifically includes the following steps:

[0028] 4.1 Select candidate target GUI elements with large comprehensive similarity values ​​in turn to replace the invalid GUI elements in the script statements and repair the invalid scripts;

[0029] 4.2 Run the repaired script statement. If it runs successfully, proceed to the next script statement; otherwise, select the next candidate target GUI element for repair and verification.

[0030] The beneficial effects of the present invention are: by integrating the semantic information of GUI elements, calculating the structural and semantic comprehensive similarity of GUI elements, and improving the accuracy of GUI element positioning analysis, the effect of Web application test script repair is improved, and the repair rate is increased. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is a flow chart for implementing the method of the present invention.

[0032] Figure 2 This is a test case script for an open source information management system Address Book, which is used to illustrate the method of the present invention. Figure 2 (a) is the test script for testing the "Create a New Group" business process in version 3.0. Figure 2 (b) is the test script for testing the “Create New Group” business process in version 4.0. DETAILED DESCRIPTION

[0033] The present invention provides a Web application testing and repairing method based on GUI element similarity calculation. The present invention integrates the semantic information of GUI elements, calculates the structural and semantic comprehensive similarity of GUI elements, improves the accuracy of GUI element positioning analysis, selects GUI elements with high comprehensive similarity as target candidate GUI elements for script statements that fail to locate GUI elements, and repairs the failed scripts to ensure the effectiveness of the repair and improve the repair rate.

[0034] The present invention mainly includes an embedded browser module, an information extraction module, a GUI element positioning module, and a script repair verification module. The embedded browser module is used to simulate the interaction between the user and the browser, the information extraction module is used to extract the GUI element information, the GUI element positioning module is used to locate the target GUI element, and the script repair verification module is used to repair the script and verify its validity. The information extraction module executes the test case script on the original version V, intercepts and extracts the relevant structure and semantic information using the aspect-oriented programming technology, and outputs an XML file that records the GUI element information. The element positioning module calculates the structural and semantic comprehensive similarity of the GUI elements to find similar GUI elements in the new version V′ page. If similar GUI elements are found, the target GUI elements are output to repair the invalid script. The script repair verification module replaces the original GUI element with the target GUI element, 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.

[0035] Addressbook is a typical Web application, the main function of which is address book information management, which can manage personal information in groups, including name, birthday, address, contact information and email address, etc. The method of the present invention is described below by taking the test of the "Create New Group" business process as an example. Figure 2This is a test script for the "Create a new group" business process when Addressbook evolves from version 3.0 to 4.0. In version 3.0, first click the "manage groups" hyperlink to enter the group management interface, then click the "Create a new group" button, and fill in the information of the new group in the interface input box, and finally click the "Submit information" button to complete the group creation. In version 4.0, the initial interface has undergone major changes. The group management function has moved from the left side of the interface to the upper part of the interface, and the link text has also changed from "manage groups" to "groups". The original test script failed to run. The specific implementation steps of the method of the present invention are as follows:

[0036] 1. Extract original GUI element information

[0037] Run the original test script on version 3.0 and record the GUI element information operated by each script statement, including the element's attributes and its text information. The attributes include tag, id, class, name, value, type, title, text, and XPath path.

[0038] 2. Find candidate target GUI elements and fix failed test scripts

[0039] (1) Run the original test script on version 4.0. When running script statement ①, the page layout changes and the link to "manage groups" cannot be located on the current page, so the test run is terminated.

[0040] (2) When running on version 3.0, only the "manage groups" link attribute and its text are collected, XPath = "html[1] / body[1] / table[1] / tbody[1] / tr[2] / td[2] / table[1] / tbody[1] / tr

[12] / td[1] / a[1]", and the text is "manage groups". Based on the link attribute, similar GUI elements are searched in the current page, and no similar GUI elements are found in the current page.

[0041] (3) Calculate the comprehensive structural and semantic similarity between the original GUI element and each GUI element in the current page, and select GUI elements with a similarity greater than a given threshold as candidate target GUI elements.

[0042] Assume that the original GUI element is e, and the GUI element with the text "group" in the current page is e'. The following uses e and e' as examples to illustrate how to calculate the comprehensive similarity. The specific process is as follows:

[0043] a) Calculate structural similarity

[0044] In version 4.0, the XPath of e′ is " / html[1] / body[1] / div[1] / div[3] / ul[1] / li[3] / a[1]". The XPath structures of e and e′ are split into two string arrays according to the element tags ("html[1]", "body[1]", "table[1]", "tbody[1]", "tr[2]", "td[2]", "table[1]", "tbody[1]", "tr

[12] ", "td[1]", "a[1]") and ("html[1]", "body[1]", "div[1]", "div[3]", "ul[1]", "li[3]", "a[1]"), with the lengths of the two arrays being 11 and 7 respectively, and the edit distance being 8, then d=1-8 / 11=0.27. Both elements are hyperlink texts, and there are no other tag attributes, so the number of identical attributes is 0, r = 0 / 1 = 0. Calculate sim according to formula (2): dom (e,e′)=(2*0.27*0) / (0.27+0)=0.

[0045] b) Calculate semantic similarity

[0046] After the attribute value text of e and e′ is segmented, it is put into the set WS 1 and WS 2 Medium, W.S. 1 ={"groups"},WS 2 ={"manage","groups"}. The word vector of "groups" is calculated with the word vectors of "manage" and "groups" respectively to calculate the cosine similarity value between them. The maximum value 1 is selected as the similarity value. 1 There is only one word, so the semantic similarity value of e and e′ is 1.

[0047] c) Calculate the comprehensive similarity

[0048] Assume that ω in formula (1) is 0.4, and calculate sim(e,e′)=0.4*0+1*(1-0.4)=0.6 according to formula (1), then the comprehensive similarity between e and e′ is 0.6. Assume that the similarity threshold is 0.5, and the comprehensive similarity between e and e′ is greater than or equal to 0.5, then e′ can be used as a candidate target GUI element. The same method is used to calculate the comprehensive similarity between e and all other GUI elements in the current page, and it is found that only the comprehensive similarity of e′ is greater than 0.5.

[0049] 3. Repair invalid scripts and verify

[0050] (1) Replace the invalid e with e′, fix the first script statement, and rerun it. It runs successfully.

[0051] (2) Continue to execute steps ②-⑤ in the original test case and run successfully.

[0052] Experimental results show that compared with other Web application test and repair methods WATER and VISTA, the method of the present invention can significantly improve the effectiveness of Web application test and repair and increase the repair rate.

[0053] 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 GUI element similarity calculation, characterized in that: It includes the following three steps: Step (1) Given a Web application test script, run the test script on the original Web application version, and analyze and extract the structure and semantic information of the GUI elements operated by each test script statement in turn; Step (2) locates the target GUI element, runs the original test script on the new version of the Web application, and checks whether each GUI element operated by it is correctly located. If the location fails, the information recorded in step (1) is used to calculate the structural and semantic comprehensive similarity between the original GUI element and the GUI element in the new version of the Web application page, and similar GUI elements are searched based on the similarity as candidate target GUI elements; Step (3) replace the GUI element that failed to be located with the candidate target GUI element, repair the test script, and then run it to verify the effectiveness of the repair; The step (1) specifically comprises the following steps: Given a Web application test script, execute the test script on the original Web application version, analyze and extract the main attributes and text information of the GUI elements operated by each script statement, including tag, id, class, name, value, type, title, text and XPath path; The step (2) specifically comprises the following steps: 3.1 Execute the original test script on the new version of the Web application, and check whether the GUI elements operated by each script statement are located successfully; 3.2 For the script statement that fails to locate the GUI element, calculate the comprehensive similarity sim(e,e′) between the original GUI element e in the script statement and each GUI element e′ in the current Web page, and select the GUI element whose comprehensive similarity value is greater than a given threshold as the candidate target GUI element; The comprehensive similarity sim(e,e′) is the structural similarity sim dom (e,e′) and semantic similarity sim sem The linear combination of (e,e′) is calculated using formula (1): yes(and, and′)=yes dom (e, e′)*ω+sim sem (e, e′)*(1-ω) (1) Among them, ω represents the weight, sim dom (e,e′) represents the structural similarity, sim sem (e,e′) represents semantic similarity; Structural similarity sim dom (e, e′) calculates the similarity between the positions of e and e′ in the DOM tree and other element attribute values, using formula (2): Yes dom (e, e′)=2*d*r / (d+r) (2) Among them, r represents the ratio of the number of attributes that are the same as e and e′ to the total number of attributes, d represents the XPath edit distance between e and e′, and sim dom (e,e′) is the harmonic mean of r and d; Semantic similarity sim sem (e, e′) calculates the semantic similarity of the description text information of e and e′, using formula (3): Among them, WS(e) and WS(e′) represent the word sets generated after the text describing e and e′ is segmented and stop words are removed, sim(w,w′) represents the cosine similarity value between word vectors w and w′, N represents the number of words in WS(e), and sim sem (e, e′) is the average value of the maximum word vector cosine similarity between the words in WS(e) and the words in WS(e′); 3.3 Select GUI elements whose comprehensive similarity values ​​are greater than a given threshold as candidate target GUI elements, and sort them by comprehensive similarity value.

2. The Web application testing and repairing method based on GUI element similarity calculation as claimed in claim 1, characterized in that The step (3) specifically comprises the following steps: 4.1 Select candidate target GUI elements with large comprehensive similarity values ​​in turn to replace the invalid GUI elements in the script statements and repair the invalid scripts; 4.2 Run the repaired script statement. If it runs successfully, proceed to the next script statement; otherwise, select the next candidate target GUI element for repair and verification.