CN113032280A - Web application testing and repairing method based on GUI element similarity calculation - Google Patents

Web application testing and repairing method based on GUI element similarity calculation Download PDF

Info

Publication number
CN113032280A
CN113032280A CN202110435080.3A CN202110435080A CN113032280A CN 113032280 A CN113032280 A CN 113032280A CN 202110435080 A CN202110435080 A CN 202110435080A CN 113032280 A CN113032280 A CN 113032280A
Authority
CN
China
Prior art keywords
gui element
similarity
web application
script
gui
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110435080.3A
Other languages
Chinese (zh)
Inventor
戚晓芳
贺黎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Southeast University
Original Assignee
Southeast University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Southeast University filed Critical Southeast University
Priority to CN202110435080.3A priority Critical patent/CN113032280A/en
Publication of CN113032280A publication Critical patent/CN113032280A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Abstract

The invention discloses a Web application testing and repairing method based on GUI element similarity calculation. Given a certain Web application test script, firstly running and recording GUI element information of each script statement operation on an original edition application; then, running an original test case script on the new version application, calculating the comprehensive similarity of the structure and the semantics of the GUI elements in the original version and each GUI element in the current Web page for the script statements failed in the GUI element positioning, and selecting the GUI elements with high comprehensive similarity as target candidate GUI elements; and finally, replacing the failed GUI elements with the target candidate GUI elements, repairing the test script, and running the repaired test script on the Web application new version to verify the effectiveness of repair. According to the method, the similarity of the GUI elements is calculated, the target GUI elements are positioned, the Web application test script is automatically repaired, and the repair rate of the Web application test script can be remarkably improved.

Description

Web application testing and repairing method based on GUI element similarity calculation
Technical Field
The invention belongs to the field of software analysis and test in software engineering, particularly relates to the field of Web application test, and particularly relates to a Web application test repairing method based on GUI element similarity calculation.
Background
With the popularization of network technology and the development of new Web application development technology, Web applications have the advantages of being capable of using latest version software without installation, maintenance and upgrade, being durable in data, safe and easy to share and access, and the like, are increasingly widely developed and used, and have increasingly important roles from initial simple information distribution and information sharing to electronic commerce, information management, search engines, service calculation, multimedia and the like, and the Web applications gradually permeate into various fields of production and life of people. With the rapid development of the Web application, the quality problem of the Web application also occurs, and the quality problem has important influence on the production and the life of people. As an important software quality assurance means, Web application testing has become an important research direction.
As known, errors in Web applications can be found through testing, and after the errors are found, modification is needed, and after the modification, in order to verify the correctness of the modification, regression testing is needed. In fact, the evolution process of the Web application version can be regarded as a process of continuously finding errors, modifying and performing regression testing. In the regression testing process of the Web application, most of the test scripts can be selected from the original test scripts in a centralized manner, but due to the change of the Web application, particularly the change of the structure and the content of some pages, part of the test scripts cannot be directly operated and can be used only after being repaired to a certain degree, but the existing script repairing work is generally completed by manual analysis, so that the cost is high, and the automation degree is low. Therefore, support of Web application test repair methods, techniques and tools is urgently needed to improve the quality and productivity of Web application software.
Empirical research shows that the main reasons for the failure of the Web application test script include element positioning failure, value abnormality, page reloading, User session abnormality, dynamic script box bouncing abnormality and the like based on a Graphical User Interface (GUI for short), wherein the main reasons are element positioning failure which accounts for 74% of the total failure script. Currently, research on repairing Web application test scripts mainly focuses on repairing script failures caused by GUI element positioning failures, and most of Web application repairing methods thereof adopt a difference test strategy, that is, target GUI elements are positioned based on comparison of GUI element information in application new and old version pages, such as comparison of attribute information of the GUI elements, comparison of editing distances of the GUI elements on a DOM tree, or comparison of visual images of the GUI elements. Choudhury et al propose a Web application failure repair method based on GUI element attribute comparison and a corresponding tool, WATER, which can semi-automatically provide a suggestion for repairing a script by analyzing the difference of GUI element attributes of a test script in the execution process of a new version and an old version. Stocco et al propose a Web application repair method based on GUI element image contrast and a tool, VISTA, that improves the repair rate to some extent, but the method almost fails if large changes in element style or large modifications in page layout are encountered.
Since the method only positions the target GUI element from the attribute or image contrast of the GUI element in the repair process, semantic information of the GUI element itself is not considered, and once the attribute or image of the GUI element is slightly changed, effective repair cannot be performed. Therefore, semantic information of the GUI elements needs to be fused, the accuracy of positioning analysis of the GUI elements is improved, and the repair rate of the Web application test script is further improved.
Disclosure of Invention
Aiming at the defects of the repairing method, the invention provides a Web application testing repairing method based on GUI element similarity calculation. Compared with the prior art, the method provided by the invention has the advantages that in the test script repairing process, the comprehensive similarity of the structure and the semantics of the GUI elements is calculated by fusing the GUI element semantic information, the accuracy of the GUI element positioning analysis is improved, the repairing effect of the Web application test script is improved, and the repairing rate is improved.
The technical scheme of the invention is as follows:
a Web application testing and repairing method based on GUI element similarity calculation comprises the following three steps:
step (1) a certain Web application test script is given, the test script is operated on the original Web application version, and the structure and semantic information of the GUI element of each test script statement operation are sequentially analyzed and extracted;
step (2) positioning a target GUI element, running an original test script on the Web application new version, checking whether each operated GUI element is correctly positioned, if the positioning fails, calculating the comprehensive similarity of the structure and the semantics of the original GUI element and the GUI element in the Web application new version page by using the information recorded in the step (1), and searching similar GUI elements as candidate target GUI elements according to the comprehensive similarity;
and (3) replacing the GUI element with the candidate target GUI element, repairing the test script, running and verifying the effectiveness of repair.
Further, the step (1) specifically includes the steps of:
and giving a certain Web application test script, executing the test script on the original Web application version, and analyzing and extracting main attributes and text information of GUI elements of each script statement operation, wherein the main attributes specifically comprise tag, id, class, name, value, type, title, text and XPath.
Further, the step (2) specifically includes the following steps:
3.1 executing the original test script on the new version Web application, and sequentially checking whether the GUI element operated by each script statement is successfully positioned;
3.2 for the script statement with the failed GUI element positioning, calculating 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 selecting the GUI element with the comprehensive similarity larger than a given threshold value as a candidate target GUI element;
the integrated similarity sim (e, e') is the structural similarity simdom(e, e') and semantic similarity simsem(e, e') is calculated using equation (1):
sim(e,e′)=simdom(e,e′)*ω+simsem(e,e′)*(1-ω) (1)
where ω represents a weight, simdom(e, e') denotes structural similarity, simsem(e, e') representing semantic similarity;
structural similarity simdom(e, e ') calculating the similarity between the positions of e and e' in the DOM tree and the attribute values of other elements by adopting the formula (2):
simdom(e,e′)=2*d*r/(d+r) (2)
wherein r represents the ratio of the number of the same attributes of e and e 'to the total attribute number, d represents the XPath editing distance between e and e', simdom(e, e') is the harmonic mean of r and d;
semantic similarity simsem(e, e ') calculating semantic similarity of the descriptive text information of e and e', and calculating by adopting formula (3):
Figure BDA0003032866120000031
wherein, WS (e) and WS (e ') respectively represent word sets generated after the text describing e and e' is subjected to word segmentation and stop word removal, sim (w, w ') represents cosine similarity values between word vectors w and w', N represents the number of words in WS (e), simsem(e, e ') is the average value of the cosine similarity value of the maximum word vector of the words in WS (e) and WS (e');
3.3 selecting the GUI elements with the comprehensive similarity value larger than a given threshold value as candidate target GUI elements and sorting according to the size of the comprehensive similarity value.
Further, the step (3) specifically includes the following steps:
4.1, sequentially selecting candidate target GUI elements with large comprehensive similarity value to replace failed GUI elements in the script statement, and repairing the failed script;
4.2, running the repaired script statement, and if the repaired script statement is successfully run, entering the next script statement; otherwise, selecting the next candidate target GUI element for repairing and verifying.
The invention has the beneficial effects that: by fusing the semantic information of the GUI elements, the comprehensive similarity of the structure and the semantics of the GUI elements is calculated, and the accuracy of the positioning analysis of the GUI elements is improved, so that the repairing effect of the Web application test script is improved, and the repairing rate is improved.
Drawings
FIG. 1 is a flow chart of an embodiment of the method of the present invention.
Fig. 2 is a test case script of an Address Book of an information management system of an open source, which is used to explain the method of the present invention, wherein fig. 2(a) is a test script for testing a service flow of "new packet" of version 3.0, and fig. 2(b) is a test script for testing a service flow of "new packet" of version 4.0.
Detailed Description
The invention provides a Web application testing and repairing method based on GUI element similarity calculation, which is characterized in that the structure and semantic comprehensive similarity of GUI elements are calculated by fusing the semantic information of the GUI elements, the accuracy of GUI element positioning analysis is improved, the GUI elements with high comprehensive similarity are selected as target candidate GUI elements for script statements with failed GUI element positioning, and failure scripts are repaired, so that the repairing effectiveness is ensured, and the repairing rate is improved.
The invention mainly comprises an embedded browser module, an information extraction module, a GUI element positioning module, a script restoration verification module and the like. The embedded browser module is used for simulating interaction between a user and a browser, the information extraction module is used for extracting GUI element information, the GUI element positioning module is used for positioning a target GUI element, and the script restoration verification module is used for restoring a script and verifying the effectiveness of the script. The information extraction module intercepts and extracts related structure and semantic information by executing the test case script on the original version V and utilizing a section-oriented programming technology, and outputs an XML file recorded with GUI element information. And the element positioning module searches similar GUI elements in the new version V' page by calculating the comprehensive similarity of the structure and the semantics of the GUI elements, and if the similar GUI elements are found, outputs the target GUI elements for repairing the failure script. And the script repairing and verifying module replaces the original GUI element with the target GUI element, repairs the failure script, and executes the test script on the new version V' in a single step to verify the effectiveness of the test and repair script.
The Addressbook is a typical Web application, and has a main function of address book information management, and can manage personal information in groups, including names, birthdays, addresses, contact information, mailboxes and the like. The method of the present invention is described below by taking the test of the "new packet" service flow as an example. Fig. 2 is a test script of a "new packet" service flow when the address book evolves from version 3.0 to 4.0. In version 3.0, firstly clicking a "management groups" hyperlink to enter a group management interface, then clicking a new group button, filling information of a new group in an interface input box, and finally clicking an information submitting button to complete group creation. In version 4.0, the initial interface is changed greatly, the group management function is shifted from the left side of the interface to the upper part of the interface, and the link text is changed from "management groups" to "groups". The operation fails with the original test script. The method comprises the following specific implementation steps:
1. extracting original GUI element information
And running the original test script on version 3.0, and recording the GUI element information of each script statement operation, wherein the GUI element information comprises the attributes of the elements and the text information thereof, and the attributes comprise tag, id, class, name, value, type, title, text and XPath.
2. Finding candidate target GUI elements and repairing failure test scripts
(1) And (3) running the original test script on the version 4.0, and when a script statement (i) is run, because the page layout is changed, the link of the 'management groups' cannot be positioned on the current page, and the test running is stopped.
(2) With the "management groups" link attribute and its text collected only when run on top of version 3.0, XPath is "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 "management groups". And searching for similar GUI elements in the current page according to the link attribute, wherein the similar GUI elements are not found in the current page.
(3) And calculating the comprehensive similarity of the structure and the semantics of the original GUI element and each GUI element in the current page, and selecting the GUI elements with the similarity greater than a given threshold value as candidate target GUI elements.
Let the original GUI element be e, and the GUI element with the text of "group" in the current page be e ', and use e and e' as examples to explain how to perform the calculation of the comprehensive similarity. The specific process is as follows:
a) calculating structural similarity
XPath for e' in version 4.0 is "/html [1]/body[1]/div[1]/div[3]/ul[1]/li[3]/a[1]", split the XPath structure of e and e' into two arrays of strings (" html [1 ]) according to the tag of the element]","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]"), the two arrays are 11 and 7 in length, respectively, and are editedAnd the distance is 8, so that d is 1-8/11-0.27. Both elements are hyperlink text, and no other tag attribute exists, so that the number of the same attribute is 0, and r is 0/1 is 0. Sim calculation according to equation (2)dom(e,e′)=(2*0.27*0)/(0.27+0)=0。
b) Calculating semantic similarity
Respectively putting the attribute values of e and e' after text segmentation into the set WS1And WS2In, WS1={"groups"},WS2{ "management", "groups" }. Calculating cosine similarity values of word vectors of groups and word vectors of manage and groups respectively, and selecting a maximum value 1 as the similarity value of the word vectors of groups, because the WS sets1There is only one word, so the semantic similarity values for e and e' are 1.
c) Calculating the comprehensive similarity
Assuming that ω in equation (1) is 0.4, and sim (e, e ') -0.4 + 0+1 (1-0.4) -0.6 is calculated according to equation (1), the overall similarity between e and e' is 0.6. And if the similarity threshold is 0.5 and the comprehensive similarity value of e and e 'is greater than or equal to 0.5, then e' can be used as a candidate target GUI element. And (5) calculating the comprehensive similarity value of the e and all other GUI elements in the current page by the same method, and finding that the comprehensive similarity value of only e' is greater than 0.5.
3. Repairing failed scripts and validating
(1) And e' is used for replacing the failed e, the 1 st script statement is repaired and is re-run, and the running is successful.
(2) And continuously executing the step II to the step V in the original test case, and successfully operating.
The experimental result shows that compared with other Web application test repair methods, namely the WATER and VISTA, the method disclosed by the invention can obviously improve the effectiveness of Web application test repair and improve the repair rate.
The above examples are only preferred embodiments of the present invention, it should be noted that: it will be apparent to those skilled in the art that various modifications and equivalents can be made without departing from the spirit of the invention, and it is intended that all such modifications and equivalents fall within the scope of the invention as defined in the claims.

Claims (4)

1. A Web application testing and repairing method based on GUI element similarity calculation is characterized by comprising the following three steps:
step (1) a certain Web application test script is given, the test script is operated on the original Web application version, and the structure and semantic information of the GUI element of each test script statement operation are sequentially analyzed and extracted;
step (2) positioning a target GUI element, running an original test script on the Web application new version, checking whether each operated GUI element is correctly positioned, if the positioning fails, calculating the comprehensive similarity of the structure and the semantics of the original GUI element and the GUI element in the Web application new version page by using the information recorded in the step (1), and searching similar GUI elements as candidate target GUI elements according to the comprehensive similarity;
and (3) replacing the GUI element with the candidate target GUI element, repairing the test script, running and verifying the effectiveness of repair.
2. The method for testing and repairing the Web application based on the GUI element similarity calculation according to claim 1, wherein the step (1) comprises the following steps:
and giving a certain Web application test script, executing the test script on the original Web application version, and analyzing and extracting main attributes and text information of GUI elements of each script statement operation, wherein the main attributes specifically comprise tag, id, class, name, value, type, title, text and XPath.
3. The method for testing and repairing the Web application based on the GUI element similarity calculation according to claim 1, wherein the step (2) comprises the following steps:
3.1 executing the original test script on the new version Web application, and sequentially checking whether the GUI element operated by each script statement is successfully positioned;
3.2 for the script statement with the failed GUI element positioning, calculating 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 selecting the GUI element with the comprehensive similarity larger than a given threshold value as a candidate target GUI element;
the integrated similarity sim (e, e') is the structural similarity simdom(e, e') and semantic similarity simsem(e, e') is calculated using equation (1):
sim(e,e′)=simdom(e,e′)*ω+simsem(e,e′)*(1-ω) (1)
where ω represents a weight, simdom(e, e') denotes structural similarity, simsem(e, e') representing semantic similarity;
structural similarity simdom(e, e ') calculating the similarity between the positions of e and e' in the DOM tree and the attribute values of other elements by adopting the formula (2):
simdom(e,e′)=2*d*r/(d+r) (2)
wherein r represents the ratio of the number of the same attributes of e and e 'to the total attribute number, d represents the XPath editing distance between e and e', simdom(e, e') is the harmonic mean of r and d;
semantic similarity simsem(e, e ') calculating semantic similarity of the descriptive text information of e and e', and calculating by adopting formula (3):
Figure FDA0003032866110000021
wherein, WS (e) and WS (e ') respectively represent word sets generated after the text describing e and e' is subjected to word segmentation and stop word removal, sim (w, w ') represents cosine similarity values between word vectors w and w', N represents the number of words in WS (e), simsem(e, e ') is the average value of the cosine similarity value of the maximum word vector of the words in WS (e) and WS (e');
3.3 selecting the GUI elements with the comprehensive similarity value larger than a given threshold value as candidate target GUI elements and sorting according to the size of the comprehensive similarity value.
4. The method for testing and repairing the Web application based on the GUI element similarity calculation according to claim 1, wherein the step (3) comprises the following steps:
4.1, sequentially selecting candidate target GUI elements with large comprehensive similarity value to replace failed GUI elements in the script statement, and repairing the failed script;
4.2, running the repaired script statement, and if the repaired script statement is successfully run, entering the next script statement; otherwise, selecting the next candidate target GUI element for repairing and verifying.
CN202110435080.3A 2021-04-22 2021-04-22 Web application testing and repairing method based on GUI element similarity calculation Pending CN113032280A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110435080.3A CN113032280A (en) 2021-04-22 2021-04-22 Web application testing and repairing method based on GUI element similarity calculation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110435080.3A CN113032280A (en) 2021-04-22 2021-04-22 Web application testing and repairing method based on GUI element similarity calculation

Publications (1)

Publication Number Publication Date
CN113032280A true CN113032280A (en) 2021-06-25

Family

ID=76457318

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110435080.3A Pending CN113032280A (en) 2021-04-22 2021-04-22 Web application testing and repairing method based on GUI element similarity calculation

Country Status (1)

Country Link
CN (1) CN113032280A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116627807A (en) * 2023-05-12 2023-08-22 南京数睿数据科技有限公司 Mobile application test repair method integrating interface element semantics and structural information

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100318970A1 (en) * 2009-06-11 2010-12-16 Mark Grechanik Assessment system for choosing maintenance approaches for gui-directed test scripts
CN102411538A (en) * 2011-11-22 2012-04-11 南京大学 Method for restoring test script of graphical user interface based on event reachability mode
CN107451065A (en) * 2017-08-18 2017-12-08 郑州云海信息技术有限公司 A kind of method and system of reparation web automatic test scripts

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100318970A1 (en) * 2009-06-11 2010-12-16 Mark Grechanik Assessment system for choosing maintenance approaches for gui-directed test scripts
CN102411538A (en) * 2011-11-22 2012-04-11 南京大学 Method for restoring test script of graphical user interface based on event reachability mode
CN107451065A (en) * 2017-08-18 2017-12-08 郑州云海信息技术有限公司 A kind of method and system of reparation web automatic test scripts

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116627807A (en) * 2023-05-12 2023-08-22 南京数睿数据科技有限公司 Mobile application test repair method integrating interface element semantics and structural information
CN116627807B (en) * 2023-05-12 2024-04-09 南京数睿数据科技有限公司 Mobile application test repair method integrating interface element semantics and structural information

Similar Documents

Publication Publication Date Title
CN109144882B (en) Software fault positioning method and device based on program invariants
CN111459799B (en) Software defect detection model establishing and detecting method and system based on Github
CN110347598B (en) Test script generation method and device, server and storage medium
Corley et al. Recovering traceability links between source code and fixed bugs via patch analysis
CN105824718A (en) Automatic repairing method and automatic repairing system for software configuration fault based on question and answer website knowledge
Ayari et al. Threats on building models from cvs and bugzilla repositories: the mozilla case study
CN105335246B (en) A kind of program crashing defect self-repairing method based on question and answer web analytics
CN106649557B (en) Semantic association mining method for defect report and mail list
Li et al. Classification of software defect detected by black-box testing: An empirical study
CN109710518A (en) Script checking method and device
CN111813443B (en) Method and tool for automatically filling code sample by using Java FX
CN111460401B (en) Product automatic tracking method combining software product process information and text similarity
CN111783460A (en) Enterprise abbreviation extraction method and device, computer equipment and storage medium
JP4588037B2 (en) Document consistency check support system and method, and program thereof
CN113032279A (en) Web application testing and repairing method based on semantic path search
Cheng et al. A similarity integration method based information retrieval and word embedding in bug localization
CN113032280A (en) Web application testing and repairing method based on GUI element similarity calculation
CN112286799B (en) Software defect positioning method combining sentence embedding and particle swarm optimization algorithm
CN112241370B (en) API interface class checking method, system and device
US10846059B2 (en) Automated generation of software bindings
CN113268470A (en) Efficient database rollback scheme verification method
CN113127445A (en) Domestic substitution migration method of foreign technology application system
Shao et al. Webevo: taming web application evolution via detecting semantic structure changes
Lavoie et al. A case study of TTCN-3 test scripts clone analysis in an industrial telecommunication setting
US11366742B2 (en) Automated identification of lines of code related to errors field

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination