Page element automatic verification method, electronic equipment, readable medium and program product
Extracting and verifying the input tags of the Web page through automated verification methods solves the problem of cumbersome verification of required and optional items in the existing technology, realizes an efficient and accurate testing process, and ensures the functional consistency of page elements.
Patent Information
- Application Number
- CN202410759514.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-08-23
AI Technical Summary
In the existing technology, the verification process of required and optional items on a Web page is cumbersome and time-consuming, prone to errors, and lacks automated solutions, resulting in low testing efficiency and poor accuracy.
Provide an automatic verification method for page elements. By extracting all input tags of the target page, obtain the positioning path, search for the submit button layer by layer, verify the page elements, determine whether the required and optional items meet the expected functional requirements, generate a verification report, and achieve Automated verification.
It greatly improves the testing efficiency and accuracy, reduces manual intervention, reduces the error rate, and ensures the correctness of the required and optional functions of page elements.
Smart Images

Figure CN118535247A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of Web page testing, and in particular to a method for automatically verifying page elements, an electronic device, a computer-readable medium, and a computer program product. Background Art
[0002] Current application systems generally use web pages for parameter configuration. Each configuration item is usually divided into mandatory items and optional items. The system usually uses * to indicate mandatory items. For testers, it is necessary to ensure that all mandatory items marked with * on the page are indeed mandatory, and whether the optional items can pass the verification normally without filling in.
[0003] Manual testing is a very tedious and time-consuming task for a large system website. Therefore, there is an urgent need for a method and tool that can automatically traverse and determine whether all optional and required items on the page correspond. This method and tool should be able to automatically detect each required item marked with *, verify whether it is required, and detect whether the optional items can pass the verification without filling in, thereby greatly improving the efficiency and accuracy of the test. Summary of the invention
[0004] The embodiments of the present disclosure provide a method for automatic verification of page elements, an electronic device, and a computer-readable medium.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for automatically verifying page elements, including:
[0006] Extract all input tags of the target page;
[0007] Get the location path of an unprocessed input tag;
[0008] Searching for a submit button layer by layer in the location path of the unprocessed input tag to obtain the location path of the submit button;
[0009] Obtain all page elements between the location path of the submit button and the location path of the unprocessed input tag;
[0010] Verify all the page elements and obtain verification results;
[0011] Determine whether there are any unprocessed input tags among all the input tags, and if so, return to the step of obtaining a location path of an unprocessed input tag;
[0012] If all input tags are processed, a report containing all validation results is generated.
[0013] In some embodiments, the verifying all the page elements to obtain the verification result includes:
[0014] It is determined whether all the page elements meet the expected functional requirements, and the verification result is obtained.
[0015] In some embodiments, the determining whether all the page elements meet the expected functional requirements and obtaining the verification result includes:
[0016] Traverse all the page elements;
[0017] Determine the page elements as required elements and optional elements respectively according to whether they have required marks;
[0018] Verify whether the required elements and the optional elements meet their respective expected functional requirements to obtain the verification result.
[0019] In some embodiments, determining the page elements as required elements and optional elements respectively according to whether they have required marks includes:
[0020] If there is a required tag in the currently traversed page element, the element is determined as a required element;
[0021] If there is no required tag in the currently traversed page element, the element is determined as an optional element.
[0022] In some embodiments, the verifying whether the required elements and the optional elements meet their respective expected functional requirements to obtain the verification result includes:
[0023] For the required elements, fill in all other elements except the required elements and submit them. If the submission is successful, a verification result of verification failure will be obtained, and if the submission fails, a verification result of verification passed will be obtained; fill in all elements and submit them. If the submission is successful, a verification result of verification passed will be obtained, and if the submission fails, a verification result of verification failed will be obtained;
[0024] For optional elements, fill in all elements except the optional elements and submit. If the submission is successful, you will get a verification result of passed. If the submission fails, you will get a verification result of failed. Fill in all elements and submit. If the submission is successful, you will get a verification result of passed. If the submission fails, you will get a verification result of failed.
[0025] In some embodiments, if all input tags are processed, a report containing all verification results is generated, including:
[0026] If all the input tags are processed, searching for clickable elements in the page file of the target page;
[0027] If there is an unprocessed clickable element, perform a click operation on the currently selected unprocessed clickable element to enter a new page;
[0028] Treat the new page as the target page and return to the step of extracting all input tags of the target page;
[0029] After the input tags and clickable elements of the new page and all subpages of the new page are processed, return to the target page to continue searching for other unprocessed clickable elements;
[0030] After the input tags and the clickable elements of the target page and all subpages of the target page are processed, a report containing all verification results is generated.
[0031] In some embodiments, before extracting all input tags of the target page, the following steps are included:
[0032] Open the interface of the system to be verified;
[0033] Log in to the system to be verified;
[0034] Open the target page of the system to be verified;
[0035] Obtain the page file of the target page.
[0036] In some embodiments, searching for a submit button layer by layer in the location path of the unprocessed input tag to obtain the location path of the submit button includes:
[0037] Starting from the location path of the unprocessed input tag, searching for the submit button layer by layer in its parent path;
[0038] When the submit button is found, stop searching;
[0039] The location path of the submit button is recorded.
[0040] In a second aspect, an embodiment of the present disclosure provides an electronic device, including:
[0041] one or more processors;
[0042] A memory having one or more programs stored thereon, when the one or more programs are executed by the one or more processors, the one or more processors implement the page element automatic verification method described in the first aspect of the embodiment of the present disclosure.
[0043] In a third aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, and when the program is executed by a processor, the method for automatically verifying page elements described in the first aspect of the embodiment of the present disclosure is implemented.
[0044] In a fourth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the page element automatic verification method described in the first aspect of the embodiment of the present disclosure.
[0045] The disclosed embodiment verifies the required and optional items of a web page through an automated script. The program can automatically traverse all elements in the page, identify and verify each required item, and reduce the necessity of manual intervention. Automated verification not only improves work efficiency and saves a lot of labor costs, but also reduces the error rate of manual operation, making the testing process more reliable. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a flow chart of a method for automatic verification of page elements according to an embodiment of the present disclosure.
[0047] Figure 2 It is a schematic diagram of the composition of an electronic device in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0048] In order to enable those skilled in the art to better understand the technical solution of the present disclosure, the technical solution of the present disclosure is described in detail below with reference to the accompanying drawings.
[0049] Example embodiments will be described more fully below with reference to the accompanying drawings, but the example embodiments may be embodied in different forms and should not be construed as limited to the embodiments set forth herein. On the contrary, the purpose of providing these embodiments is to make the present disclosure thorough and complete and to enable those skilled in the art to fully understand the scope of the present disclosure.
[0050] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0051] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0052] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a", "an" and "the" are also intended to include the plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "comprising" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded.
[0053] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.
[0054] In web page testing, testers need to verify whether all mandatory items on the page are indeed mandatory, and whether optional items can be submitted normally without filling in. For a complex server system, there are many configuration items, and manual verification is time-consuming and error-prone. Due to the limitations of manual testing, as the version is iterated, testers may ignore the verification of certain mandatory and optional items, resulting in potential functional defects.
[0055] In order to overcome the shortcomings of the prior art, the present disclosure proposes a method for automatically verifying the required and optional items on a Web page. The method can automatically verify the required and optional items on a Web page after the version is released, reducing the time and effort of manual testing, while ensuring that the functions of all required and optional items on the page are consistent with actual needs.
[0056] The page element automatic verification method according to the embodiment of the present disclosure can automatically parse all elements on the current Web page and obtain the XPath paths of these elements, which can ensure that each input tag on the page can be accurately located and operated.
[0057] The page element automatic verification method according to the embodiment of the present disclosure can automatically identify the required items on the page (usually marked by *), and verify whether these required items have corresponding verification logic. This can ensure that each input tag marked as required is indeed required in actual operation.
[0058] The present disclosure provides a method for automatically verifying whether all mandatory and optional items on a web page are correct. Through the method disclosed in the present disclosure, all mandatory and optional items on the page can be automatically verified after a new version is released to ensure that the mandatory marks of these items are consistent with the functional requirements, reduce the time and energy consumption of manual testing, and improve the accuracy and efficiency of testing.
[0059] The present disclosure aims to solve the problem of manual verification of required and optional items in the current Web page testing process, and to provide an automated verification method to ensure the correctness of the functions of all required and optional items on the page.
[0060] Figure 1 It is a flow chart of a method for automatic verification of page elements according to an embodiment of the present disclosure.
[0061] First, refer to Figure 1 The present disclosure provides a method for automatically verifying page elements, including:
[0062] S11, extract all input tags of the target page;
[0063] S12, obtaining a location path of an unprocessed input tag;
[0064] S13, searching for a submit button layer by layer in the location path of the unprocessed input tag to obtain the location path of the submit button;
[0065] S14, acquiring all page elements between the location path of the submit button and the location path of the unprocessed input tag;
[0066] S15, verifying all the page elements and obtaining a verification result;
[0067] S16, determining whether there are any unprocessed input tags among all the input tags, and if so, returning to step S12;
[0068] S17. If all input tags are processed, a report containing all verification results is generated.
[0069] In some embodiments, before using the method of the present invention to perform automatic verification, users need to perform different operations for different types of systems. For systems that require login, users need to log in to the system in advance to ensure that the login is successful and that they can access various pages in the system normally. After a successful login, the user can continue to perform subsequent automatic verification steps to ensure that the required and optional items on the system page can be correctly verified. For systems that do not require login, users can directly open the target page for operation. After the page is successfully loaded, users can immediately perform subsequent automatic verification steps. By logging in in advance or directly opening the target page, it is ensured that the system page can be accessed normally, which provides a prerequisite for the automatic verification of the required and optional items of the Web page.
[0070] In the embodiment of the present disclosure, before extracting all input tags of the target page, the following steps are included:
[0071] Open the interface of the system to be verified;
[0072] Log in to the system to be verified;
[0073] Open the target page of the system to be verified;
[0074] Obtain the page file of the target page.
[0075] In some embodiments, the page is an HTML (Hypertext Markup Language) page, the page elements are HTML elements, and the page file is an HTML file.
[0076] In some embodiments, the page_source function of Selenium is used to obtain the HTML file of the target page. Selenium is a tool for automated testing, which can simulate user operations in a browser, such as clicking buttons, entering text, etc. It provides interfaces for multiple programming languages, including Python, Java, JavaScript, etc. In this disclosure, "selenuim" refers to the tool Selenium, which is particularly suitable for web pages that need to process dynamic content. The page_source function is a method in Selenium that is used to obtain the HTML source code of the target page. Simply put, it returns the HTML content of the target page as a string, which can be parsed or saved as a file.
[0077] In addition to using Selenium's page_source function, there are other functions and methods to achieve the same function. For example, you can use the requests library to send a get request to obtain the content of a web page, request a web page: response = requests.get(url), obtain the HTML content, html_content = reaction.text, html_content is the obtained html content; in addition, you can also use Urllib2's urlopen function to obtain the web page content, response = urllib2.urlopen(url), html_content = response.read() to obtain the html source code of the web page. Depending on the specific needs and the nature of the web page (static or dynamic), you can choose to use different methods. Here we choose to use Selenium, so that it will be more convenient to use Selenium directly to operate page elements in subsequent operations.
[0078] In the embodiment of the present disclosure, the step of extracting all input tags of the target page includes:
[0079] The HTML file is parsed, and all the input tags of the target page are extracted according to the parsed HTML file.
[0080] In some embodiments, BeautifulSoup is used to parse the acquired HTML file, and then the find_all('input') function is used to extract all input tags. Specifically, first, the acquired HTML file is passed to BeautifulSoup through the code soup=BeautifulSoup(html_content,'html.parser'), the HTML file is parsed using the html.parser parser, a BeautifulSoup object is generated, and it can be stored in a variable such as soup. Next, the code input_tags=soup.find_all('input') searches for all input tags in the parsed HTML document, and the results can be stored in a variable such as input_tags. The output input_tags is a list containing a set of nodes that match all input tags. For example, a portion of the output list may be as follows: <input name="reqURI"type="hidden"value=""> ;…… <input id="login"maxlength="30"name="tl_login"size="32"type="text"> ; ... The embodiment of the present disclosure may also adopt other methods to obtain the input tag, and the embodiment of the present disclosure does not make any special limitation on this.
[0081] In the embodiment of the present disclosure, extracting all input tags of the target page further includes: calculating the number of all input tags.
[0082] In some embodiments, the Len function is used to count the number of input tags. The number of input tags can be obtained by using the len function to obtain the length of the result set input_tags, and the final result is a number.
[0083] In some embodiments, lxml.etree.ElementTree can be used to traverse the input tags, and then the getpath function can be used to obtain the complete XPath path of each input tag. These paths can be used to accurately locate each input tag in automated testing or other operations. The XPath path can also be called a "location path", which refers to the location path that uniquely identifies an element in an HTML document (such as each input tag on a page). For example, the XPath path of the input tag obtained can be: ' / html / body / div[2] / form / p[1] / input', ' / html / body / div[2] / form / p[2] / input', etc. The embodiments of the present disclosure can also use other methods to obtain the location path, and the embodiments of the present disclosure do not specifically limit this.
[0084] In the embodiment of the present disclosure, searching for a submit button layer by layer in the location path of the unprocessed input tag to obtain the location path of the submit button includes:
[0085] Starting from the location path of the unprocessed input tag, searching for the submit button layer by layer in its parent path;
[0086] When the submit button is found, stop searching;
[0087] The location path of the submit button is recorded.
[0088] In some embodiments, find_element (by=By.XPATH, vlaue='current xpath parent / button') is used to determine whether there is a button under the parent path layer by layer, and the xpath path of the submit page button is finally found here. Since there is usually not only one module of content in an HTML page, it is necessary to search for submitted tags in the current input tag complete xpath path after obtaining the complete xpath path of the input tag. Specifically, if the current input tag complete xpath path is / html / body / div[2] / form / p[1] / input, it is necessary to determine whether the following paths exist: ① / html / body / div[2] / form / p[1] / input / button ② / html / body / div[2] / form / p[1] / button ③ / html / body / div[2] / form / / button ④ / html / body / div[2] / button ⑤ / html / body / / button. According to HTML specifications, the content generally starts from the body, so only the body is traversed here. If there is no submitted tag, it means that there is no need to perform a required item test, because it is only necessary to determine whether the required item is filled in when submitting. Here, button is used as a general term to refer to any button. In actual use, it is necessary to adapt to the current conventional definition method of button submit buttons, including the common button tag, input tag, a tag, p tag with type equal to submit, etc. For systems that do not meet the conventional definitions, it is necessary to add user-defined methods in actual implementation, or implement automatic judgment of buttons in the program.
[0089] In some embodiments, all HTML elements (e.g., 、 , <input> For example, if the full xpath of the input tag is / html / body / div[2] / form / p[1] / input, and the full xpath of the submit button is / html / body / div[2] / button, then you need to find all the elements between / html / body / div[2] / button and / html / body / div[2] / form / p[1] / input in the target page html.
[0090] In the embodiment of the present disclosure, the verifying all the HTML elements to obtain the verification result includes:
[0091] Determine whether all the HTML elements meet the expected functional requirements and obtain the verification result.
[0092] In the embodiment of the present disclosure, the determining whether all the HTML elements meet the expected functional requirements and obtaining the verification result includes:
[0093] Traverse all the HTML elements;
[0094] Determine the HTML element as a required element or an optional element according to whether it has a required mark;
[0095] Verify whether the required elements and the optional elements meet their respective expected functional requirements to obtain the verification result.
[0096] In the embodiment of the present disclosure, determining the HTML element as a required element and an optional element respectively according to whether it has a required mark includes:
[0097] If the currently traversed HTML element has a required tag (* tag), the element is determined as a required element;
[0098] If there is no required tag (* tag) in the currently traversed HTML element, the element is determined as an optional element.
[0099] In the embodiment of the present disclosure, the verifying whether the required elements and the optional elements meet their respective expected functional requirements to obtain the verification result includes:
[0100] For the required elements, fill in all other elements except the required elements and submit them. If the submission is successful, a verification result of verification failure will be obtained, and if the submission fails, a verification result of verification passed will be obtained; fill in all elements and submit them. If the submission is successful, a verification result of verification passed will be obtained, and if the submission fails, a verification result of verification failed will be obtained;
[0101] For optional elements, fill in all elements except the optional elements and submit. If the submission is successful, you will get a verification result of passed. If the submission fails, you will get a verification result of failed. Fill in all elements and submit. If the submission is successful, you will get a verification result of passed. If the submission fails, you will get a verification result of failed.
[0102] In the embodiment of the present disclosure, if all the input tags are processed, a report containing all the verification results is generated, including:
[0103] If all the input tags are processed, searching for clickable elements in the HTML file of the target page;
[0104] If there is an unprocessed clickable element, perform a click operation on the currently selected unprocessed clickable element to enter a new page;
[0105] Treat the new page as the target page and return to step S11;
[0106] After the input tags and clickable elements of the new page and all subpages of the new page are processed, return to the target page to continue searching for other unprocessed clickable elements;
[0107] After the input tags and the clickable elements of the target page and all subpages of the target page are processed, a report containing all verification results is generated.
[0108] In some embodiments, if all the input tags are processed, clickable elements are searched in the HTML file of the target page, including: searching for clickable elements such as clickable buttons or links in the HTML file from top to bottom and from outside to inside.
[0109] In some embodiments, a system may involve multiple modules, and the outermost traversal process only completes the judgment of a functional module. After the traversal process is completed, the judgment of the deepest module will be completed, and then the previous page will be returned to continue to judge the untraversed content. After judging the previous level, it will continue to return to the previous level until the content under the root directory is traversed. After all elements are traversed, the test results of all elements are recorded and counted to generate a verification report.
[0110] In some embodiments, the back function in Selenium can be used to return to the previous page.
[0111] Figure 2 It is a schematic diagram of the composition of an electronic device in an embodiment of the present disclosure.
[0112] Second, refer to Figure 2 , an embodiment of the present disclosure provides an electronic device, comprising:
[0113] One or more processors 201;
[0114] A memory 202 storing one or more programs, which, when executed by one or more processors, enables the one or more processors to implement the method for automatic verification of page elements according to the first aspect of the embodiment of the present disclosure;
[0115] One or more I / O interfaces 203 are connected between the processor and the memory and are configured to implement information exchange between the processor and the memory.
[0116] Among them, the processor 201 is a device with data processing capabilities, including but not limited to a central processing unit (CPU); the memory 202 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface (read-write interface) 203 is connected between the processor 201 and the memory 202, and can realize information interaction between the processor 201 and the memory 202, including but not limited to a data bus (Bus), etc.
[0117] In some embodiments, the processor 201 , the memory 202 , and the I / O interface 203 are connected to each other via a bus 204 , and further connected to other components of the computing device.
[0118] In a third aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, and when the program is executed by a processor, the method for automatically verifying page elements described in the first aspect of the embodiment of the present disclosure is implemented.
[0119] In a fourth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the page element automatic verification method described in the first aspect of the embodiment of the present disclosure.
[0120] In a fifth aspect, an embodiment of the present disclosure provides a device for automatically verifying page elements, including:
[0121] Tag extraction module, used to extract all input tags of the target page;
[0122] A positioning module is used to obtain a positioning path of an unprocessed input tag; search for a submit button layer by layer in the positioning path of the unprocessed input tag to obtain the positioning path of the submit button;
[0123] An element extraction module, used to obtain all page elements between the location path of the submit button and the location path of the unprocessed input tag;
[0124] A verification module, used to verify all the page elements and obtain verification results;
[0125] The reporting module is used to determine whether there are any unprocessed input tags. If so, the module returns to the step of obtaining a location path of an unprocessed input tag. If all the input tags are processed, a report containing all verification results is generated.
[0126] In some embodiments, the verification module is used to determine whether all the page elements meet the expected functional requirements and obtain the verification result.
[0127] In some embodiments, the verification module is also used to traverse all the page elements; determine the page elements as required elements and optional elements according to whether they have required marks; verify whether the required elements and the optional elements meet their respective expected functional requirements to obtain the verification results.
[0128] In some embodiments, the verification module is further used to: if the currently traversed page element has a required mark, determine the element as a required element; if the currently traversed page element does not have a required mark, determine the element as an optional element.
[0129] In some embodiments, the verification module is used to: for the required elements, fill in all elements except the required elements and submit them. If the submission is successful, a verification result of verification failure is obtained, and if the submission fails, a verification result of verification passed is obtained; fill in all elements and submit them. If the submission is successful, a verification result of verification passed is obtained, and if the submission fails, a verification result of verification failed is obtained; for optional elements, fill in all elements except the optional elements and submit them. If the submission is successful, a verification result of verification passed is obtained, and if the submission fails, a verification result of verification failed is obtained; fill in all elements and submit them. If the submission is successful, a verification result of verification passed is obtained, and if the submission fails, a verification result of verification failed is obtained.
[0130] In some embodiments, the reporting module is used to search for clickable elements in the page file of the target page if all the input tags are processed; if there are unprocessed clickable elements, perform a click operation on the currently selected unprocessed clickable element to enter a new page; treat the new page as the target page and return to the step of extracting all input tags of the target page; after the input tags and the clickable elements of the new page and all subpages of the new page are processed, return to the target page to continue searching for other unprocessed clickable elements; after the input tags and the clickable elements of the target page and all subpages of the target page are processed, generate a report containing all verification results.
[0131] In some embodiments, the automatic verification device for page elements also includes a login module, which is used to open the interface of the system to be verified; log in to the system to be verified; open the target page of the system to be verified; and obtain the page file of the target page.
[0132] In some embodiments, the positioning module is used to start from the positioning path of the unprocessed input tag and search for the submit button layer by layer in its parent path; stop searching when the submit button is found; and record the positioning path of the submit button.
[0133] In order to enable those skilled in the art to more clearly understand the technical solutions provided by the embodiments of the present disclosure, the technical solutions provided by the embodiments of the present disclosure are described in detail below through specific embodiments:
[0134] Embodiment 1
[0135] The present disclosure can be applied to Web page verification in big data security protection systems or database audit and protection systems. By using the present disclosure, automatic verification of required and optional items on Web pages can be achieved, reducing manual input and improving test efficiency and coverage.
[0136] The process of automatic verification of HTML elements described in the embodiments of the present disclosure is as follows:
[0137] 1. The user specifies the initial page of the system to be verified. For systems that require login, the user needs to log in to the server in advance and enter the normal operation page; for systems that do not require login, the user can directly open the corresponding page;
[0138] 2. Start the automatic verification program disclosed herein and specify the page to be verified;
[0139] 3. The system starts automatic traversal. The program traverses and analyzes the specified page layer by layer according to the preset algorithm logic. The system automatically parses the HTML code in the page, identifies all input tags and clickable elements, and verifies each input tag, including obtaining its XPath path and checking whether it is a required or optional item. The system will fall back to the previous page layer by layer and continue to find and process other untraversed elements until all elements on all pages are traversed and verified.
[0140] 4. Record each test point and its corresponding test results, and generate a verification report containing the verification results of all required and optional items;
[0141] 5. When users view the generated verification report, they only need to manually confirm and verify the error items marked in the report. Through the report, they can quickly locate the problems in the page and repair them.
[0142] Through the above steps, the present disclosure can effectively and automatically verify the required and optional items in the Web page, reduce manual operations, improve test efficiency and coverage, and ensure that the page functions are consistent with the requirements.
[0143] In the embodiments of the present disclosure, those skilled in the art should understand that the examples specifically given above are exemplary and various modifications may be made thereto according to the methods of the present disclosure.
[0144] This disclosure focuses on automatically traversing, judging and verifying the required options on a Web page. The technical points involved include:
[0145] First, by parsing the HTML source code of the page, obtain the XPath path of all input tags in the page. Use the find_element (by = By.XPATH, value = 'current XPath parent / button') method, starting from the XPath path of the current input tag, search upward layer by layer to determine whether there is a button under its parent tag. By searching layer by layer, the XPath path of the button used for submission in the page is finally determined. Once the XPath path of the submit button is determined, parse the entire form or module related to the submit button to obtain all input tags therein. Automatically check whether there is a required mark (such as an asterisk) before each input tag to determine whether the tag is required or optional. According to the above judgment results, the required items are automatically verified to ensure that all required items are filled in; at the same time, the optional items are verified to ensure that they can be empty and do not affect the submission operation.
[0146] Through the above steps, the present disclosure can automatically and accurately traverse and verify all required and optional items in a Web page, reducing manual operations and improving verification efficiency and accuracy. This technical key point is the core of realizing automated Web page verification, ensuring that each input box in the page can be correctly verified.
[0147] The present disclosure can also be applied to form verification in e-commerce websites. E-commerce websites usually contain a large number of user input forms, such as registration, login, payment information filling, etc. By using the present disclosure, automatic verification of the required and optional items in these forms can be achieved to ensure that the form information submitted by the user is complete and accurate. The present disclosure can effectively and automatically verify the forms in e-commerce websites, ensure that the information entered by the user meets the requirements, and improve the user experience and data accuracy of the website.
[0148] The present disclosure can also be applied to homework submission and examination systems in online education platforms. In online education platforms, students need to fill in personal information, submit homework, take examinations, etc. in different forms. By using the present disclosure, automatic verification of required and optional items in these forms can be achieved to ensure that the information submitted by students is complete and meets the requirements, thereby improving the efficiency of platform use and user experience.
[0149] The main beneficial effects of the present disclosure are as follows:
[0150] 1. Automatically verify the required items on the Web page to reduce manual input;
[0151] Traditional web page verification usually requires a lot of manual operations, and testers need to manually check whether each required and optional item is configured correctly. This is not only time-consuming and labor-intensive, but also prone to errors. The present disclosure implements verification of required and optional items on web pages through automated scripts. The program can automatically traverse all elements in the page, identify and verify each required item, reducing the necessity of manual intervention. Automated verification not only improves work efficiency and saves a lot of labor costs, but also reduces the error rate of manual operations, making the testing process more reliable.
[0152] 2. Use script verification, with high algorithm strength, fast verification speed and high accuracy.
[0153] The present disclosure adopts a high-intensity algorithm to automatically perform verification tasks through scripts. Compared with manual testing, script verification can process a large number of pages and elements more quickly. The algorithm design takes into account a variety of page layouts and element characteristics, and can accurately identify the required and optional items in the page and perform correct verification. After the verification process is automated, the system can quickly traverse the entire page and complete the verification task in a short time, greatly improving the verification speed. Since the script executes the preset logic, the subjectivity and errors of human operation are avoided, and the verification results are more accurate and reliable. Through detailed test reports, users can quickly locate problems in the page and repair them, improving the coverage and quality of the test.
[0154] In general, the present disclosure greatly reduces manual input and improves verification speed and accuracy through automated and efficient script verification, and provides an efficient and reliable solution for the verification of required and optional items on Web pages.
[0155] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0156] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. A method for automatic verification of page elements, include: Extract all input tags of the target page; Get the location path of an unprocessed input tag; Searching for a submit button layer by layer in the location path of the unprocessed input tag to obtain the location path of the submit button; Obtain all page elements between the location path of the submit button and the location path of the unprocessed input tag; Verify all the page elements and obtain verification results; Determine whether there are any unprocessed input tags, and if so, return to the step of obtaining a location path of an unprocessed input tag; If all input tags are processed, a report containing all validation results is generated.
2. The page element automatic verification method according to claim 1, in, The verifying all the page elements and obtaining the verification result includes: It is determined whether all the page elements meet the expected functional requirements, and the verification result is obtained.
3. The page element automatic verification method according to claim 2, in, The determining whether all the page elements meet the expected functional requirements and obtaining the verification result includes: Traverse all the page elements; Determine the page elements as required elements and optional elements respectively according to whether they have required marks; Verify whether the required elements and the optional elements meet their respective expected functional requirements to obtain the verification result.
4. The page element automatic verification method according to claim 3, in, The determining the page elements as required elements and optional elements respectively according to whether they have required marks includes: If there is a required tag in the currently traversed page element, the element is determined as a required element; If there is no required tag in the currently traversed page element, the element is determined as an optional element.
5. The page element automatic verification method according to claim 4, in, The verifying whether the required elements and the optional elements meet their respective expected functional requirements to obtain the verification result includes: For the required elements, fill in all other elements except the required elements and submit them. If the submission is successful, a verification result of verification failure will be obtained, and if the submission fails, a verification result of verification passed will be obtained; fill in all elements and submit them. If the submission is successful, a verification result of verification passed will be obtained, and if the submission fails, a verification result of verification failed will be obtained; For optional elements, fill in all elements except the optional elements and submit. If the submission is successful, you will get a verification result of passed. If the submission fails, you will get a verification result of failed. Fill in all elements and submit. If the submission is successful, you will get a verification result of passed. If the submission fails, you will get a verification result of failed.
6. The method for automatic verification of page elements according to any one of claims 1 to 5, in, If all input tags are processed, a report containing all verification results is generated, including: If all the input tags are processed, searching for clickable elements in the page file of the target page; If there is an unprocessed clickable element, perform a click operation on the currently selected unprocessed clickable element to enter a new page; Treat the new page as the target page and return to the step of extracting all input tags of the target page; After the input tags and clickable elements of the new page and all subpages of the new page are processed, return to the target page to continue searching for other unprocessed clickable elements; After the input tags and the clickable elements of the target page and all subpages of the target page are processed, a report containing all verification results is generated.
7. The page element automatic verification method according to claim 6, in, Before all input tags of the target page, include: Open the interface of the system to be verified; Log in to the system to be verified; Open the target page of the system to be verified; Obtain the page file of the target page.
8. The page element automatic verification method according to any one of claims 1 to 5, in, The step of searching for a submit button layer by layer in the location path of the unprocessed input tag to obtain the location path of the submit button includes: Starting from the location path of the unprocessed input tag, searching for the submit button layer by layer in its parent path; When the submit button is found, stop searching; The location path of the submit button is recorded.
9. An electronic device, include: one or more processors; A memory having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the page element automatic verification method according to any one of claims 1 to 8.
10. A computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the page element automatic verification method according to any one of claims 1 to 8.
11. A computer program product, comprising a computer program or instructions, wherein when the computer program or instructions are executed by a processor, the method for automatically verifying page elements according to any one of claims 1 to 8 is implemented.
