Automatic test method and device of webpage, storage medium and electronic equipment
By automatically detecting the update of web page function and obtaining target test cases, and performing automated testing and event monitoring, the problem of low testing efficiency in the existing technology is solved and more efficient web page testing is achieved.
Patent Information
- Application Number
- CN202311764379.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-20
- Publication Date
- 2025-06-27
AI Technical Summary
The prior art has low testing efficiency in web page testing, single operation path, difficult to simulate user operation behavior, and difficult to find problems in routine automation testing.
By detecting the update of the target page function of the web page, the target test case is obtained, and the automated test is carried out based on the use case, and preset events during the automated test process are monitored, event information is stored, and abnormal information is output.
It realizes automatic testing and event monitoring after the web page is updated, avoids the annotation and quality inspection process, improves the testing efficiency, and can more effectively discover problems in the web page.
Smart Images

Figure CN120216346A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer testing, and in particular, to an automated testing method, device, storage medium, and electronic device for web pages. Background Art
[0002] Currently, during the testing of web pages, it is necessary to first annotate the web pages through an annotation engineering platform. Due to the long operation link and complex operation path branches of the annotation engineering platform, most common functional anomalies of web pages occur along with console error messages. To ensure the accuracy of the final delivered results, after the annotator annotates the web pages, a series of actions such as data quality inspection, cross-acceptance, and final acceptance are also required for the data. For this series of actions, conventional methods usually have a single operation path and can only simulate the operation behavior of users under specific circumstances. After simulating the operation behavior of users, problems existing in the web pages are discovered by judging whether page elements exist and whether data calculations meet the threshold. The operation actions of the entire test are complex, the operation link is variable, and it is difficult for conventional automated testing to discover problems, resulting in low testing efficiency when testing web pages.
[0003] In response to the above problems, no effective solution has been proposed yet. Summary of the Invention
[0004] Embodiments of the present invention provide an automated testing method, device, storage medium, and electronic device for web pages to at least solve the technical problem of low testing efficiency when testing web pages.
[0005] According to one aspect of the embodiments of the present invention, an automated testing method for web pages is provided, including: in response to detecting an update of a target page function corresponding to a web page, obtaining a target test case corresponding to the target page function; performing automated testing on the web page based on the target test case, and monitoring a preset event occurring during the automated testing process, and storing event information of the preset event; in response to the end of the automated testing, determining whether there is abnormal event information in the stored target event information; in response to the existence of abnormal event information in the target event information, outputting the abnormal event information.
[0006] Optionally, performing automated testing on the web page based on the target test case includes: obtaining at least one page element in the web page; determining a preset operation corresponding to the at least one page element; and operating on the at least one page element based on the target test case and the preset operation corresponding to the at least one page element.
[0007] Optionally, determining a preset operation corresponding to at least one page element includes: classifying at least one page element to obtain a classification result of at least one element; and determining a preset operation corresponding to at least one page element based on the classification result of at least one element.
[0008] Optionally, operating on at least one page element based on a target test case and a preset operation corresponding to at least one page element includes: determining a target page element among at least one page element based on the target test case; and operating on the target page element based on the preset operation corresponding to the target page element.
[0009] Optionally, monitoring a preset event occurring during an automated test and storing event information of the preset event includes: during the automated test, monitoring an access request, an access response, and an output event of a web page console, where the console is used to operate on the web page; in response to monitoring an access request, obtaining a request method, a request body, and a request header of the access request to obtain event information, and storing the event information in an event information list; in response to monitoring an access response, obtaining a response header, a response body, and a status code of the access response to obtain event information, and storing the event information in the event information list; in response to monitoring an output event, obtaining an output content and an information level of the output event to obtain event information, and storing the event information in the event information list.
[0010] Optionally, determining whether there is abnormal event information in the target event information that has been stored includes: determining whether there is an abnormal status code in the target storage information, or whether there is an abnormal information level in the target storage information; in response to the existence of an abnormal status code or an abnormal information level in the target storage information, determining that there is abnormal event information in the target event information; in response to the non-existence of an abnormal status code and an abnormal information level in the target storage information, determining that there is no abnormal event information in the target event information.
[0011] Optionally, in response to the existence of abnormal event information in the target event information, outputting the abnormal event information includes: obtaining identification information corresponding to the target page function and use case information of the target test case; generating a test report of the web page based on the abnormal event information, the identification information, and the use case information; and outputting the test report through a preset output method.
[0012] Optionally, the method further includes: displaying a plurality of test cases and a plurality of page functions of a web page in an interaction interface; determining a to-be-bound test case among the plurality of test cases and a to-be-bound page function among the plurality of page functions in response to a binding instruction acting on the interaction interface; and binding the to-be-bound test case and the to-be-bound page function.
[0013] According to another aspect of the embodiments of the present invention, there is also provided an automated testing device for web pages, including: an acquisition module, configured to acquire a target test case corresponding to a target page function in response to detecting an update of the target page function corresponding to the web page; a testing module, configured to perform automated testing on the web page based on the target test case and monitor preset events occurring during the automated testing process, and store the event information of the preset events; a first determination module, configured to determine whether there is abnormal event information in the stored target event information in response to the end of the automated testing; and an output module, configured to output the abnormal event information in response to the existence of abnormal event information in the target event information.
[0014] Optionally, the testing module includes: a first acquisition unit, configured to acquire at least one page element in the web page; a first determination unit, configured to determine preset operations corresponding to the at least one page element; and an operation unit, configured to perform operations on the at least one page element based on the target test case and the preset operations corresponding to the at least one page element.
[0015] Optionally, the determination unit includes: a classification subunit, configured to classify the at least one page element to obtain a classification result of the at least one element; and a first determination subunit, configured to determine preset operations corresponding to the at least one page element based on the classification result of the at least one element.
[0016] Optionally, the operation unit includes: a second determination subunit, configured to determine a target page element among the at least one page element based on the target test case; and an operation subunit, configured to perform an operation on the target page element based on the preset operation corresponding to the target page element.
[0017] Optionally, the testing module includes: a monitoring unit, configured to monitor access requests, access responses, and output events of the console during the automated testing process, where the console is used to operate the web page; a first storage unit, configured to acquire the request method, request body, and request headers of the access request to obtain event information in response to detecting the access request, and store the event information in an event information list; a second storage unit, configured to acquire the response headers, response body, and status code of the access response to obtain event information in response to detecting the access response, and store the event information in the event information list; and a third storage unit, configured to acquire the output content and information level of the output event to obtain event information in response to detecting the output event, and store the event information in the event information list.
[0018] Optionally, the first determination module includes: a judgment unit, configured to determine whether there is an abnormal status code in the target storage information, or whether there is an abnormal information level in the target storage information; a second determination unit, configured to determine that there is abnormal event information in the target event information in response to the existence of an abnormal status code or an abnormal information level in the target storage information; and a third determination unit, configured to determine that there is no abnormal event information in the target event information in response to the non-existence of an abnormal status code and an abnormal information level in the target storage information.
[0019] Optionally, the output module includes: a second acquisition unit, configured to acquire identification information corresponding to the target page function and use case information of the target test case; a generation unit, configured to generate a test report of the web page based on the abnormal event information, the identification information, and the use case information; and an output unit, configured to output the test report through a preset output manner.
[0020] Optionally, the apparatus further includes: a display module, configured to display a plurality of test cases and a plurality of page functions of the web page in an interaction interface; a second determination module, configured to determine a test case to be bound and a page function to be bound among the plurality of test cases in response to a binding instruction acting on the interaction interface; and a binding module, configured to bind the test case to be bound and the page function to be bound.
[0021] According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, where the computer-readable storage medium includes a stored program, and when the program runs, it controls a processor of the device where it is located to execute the method in any one of the above.
[0022] According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including: one or more processors; a storage device, configured to store one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors execute the method in any one of the above.
[0023] In an embodiment of the present invention, in response to detecting an update of a target page function corresponding to a web page, a target test case corresponding to the target page function is obtained; the web page is automatically tested based on the target test case, and a preset event occurring during the automatic test is monitored, and event information of the preset event is stored; in response to the automatic test having ended, it is determined whether there is abnormal event information in the target event information that has been stored; in response to there being abnormal event information in the target event information, the abnormal event information is output. It is easy to notice that after the web page is updated, the web page can be tested, and event listening can be performed during the test, avoiding a series of actions such as annotating the web page during the test and performing quality inspection, cross-acceptance, and final acceptance on the data after annotation, and also avoiding simulating user behavior, realizing an automated method of covering user behavior with random page operations, thereby improving the test efficiency of the web page, and further solving the technical problem of low test efficiency when testing the web page. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present invention, form a part of this application, and the illustrative embodiments and descriptions of the present invention are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0025] Figure 1 is a flowchart of an automated test method for a web page according to an embodiment of the present invention;
[0026] Figure 2 is a schematic diagram of a test report output method according to an embodiment of the present invention;
[0027] Figure 3 is a schematic diagram of the binding of a test case and a page function according to an embodiment of the present invention;
[0028] Figure 4 is a schematic diagram of an automated test method according to an embodiment of the present invention;
[0029] Figure 5 is a schematic diagram of an automated test device for a web page according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0030] In order to enable those skilled in the art of the present technology to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0031] It should be noted that the terms "first", "second", etc. in the description, claims and above-mentioned drawings of the present invention are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present invention described here can be implemented in an order different from those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0032] Embodiment 1
[0033] According to an embodiment of the present invention, an embodiment of an automated test method for a web page is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.
[0034] Figure 1 is a flowchart of an automated test method for a web page according to an embodiment of the present invention. As Figure 1 shown, the user can input a test instruction in any form of instruction input in the graphical user interface on the client 10, and the network transmits the test instruction to the server 12, so that the server 12 can test the web page based on the test instruction. As Figure 1 shown, the method includes the following steps:
[0035] Step S102, in response to detecting that the target page function corresponding to the web page is updated, obtain the target test case corresponding to the target page function.
[0036] The above-mentioned web page can be the web content displayed in the browser, which is used to display the information and functions of the website, and is the interface for users to interact with the website, obtain information and perform operations. Optionally, the web page can include elements such as text, pictures, audio, video, links, etc. Different pages can be jumped through hyperlinks, and users can enter the web page for browsing and operation by entering the website address through the browser or through search engines, etc.
[0037] The above-mentioned target page function refers to various interactive functions and operation methods on the web page. Optionally, the target page function may include:
[0038] Navigation menu: Optional. There is usually a navigation menu on a web page for navigating to different pages or sections of the website.
[0039] Search function: Optional. There is usually a search box on a web page for users to search for content on the website.
[0040] Content display: Optional. Various types of content such as articles, pictures, videos, etc. are displayed on the web page.
[0041] Pagination function: Optional. If there is a large amount of web page content, the pagination function can be used to allow users to view content on different pages.
[0042] Form function: Optional. Forms on a web page can be used for users to submit information or perform interactive operations such as logging in, registering, submitting comments, etc.
[0043] Payment function: Optional. If it is an e-commerce website, there may be a payment function for users to purchase goods or services.
[0044] Social sharing function: Optional. Social sharing buttons can be added to a web page to allow users to easily share content to social media platforms.
[0045] Comment function: Optional. Users can be allowed to comment or leave messages on the content on a web page.
[0046] Scrolling function: Optional. A web page can support scrolling operations so that users can view the content of a long page.
[0047] Button and link functions: Optional. Buttons and links on a web page can be used to jump to other pages or perform specific operations.
[0048] In an optional embodiment, these functions can be combined and customized according to different web page requirements to achieve specific interaction and operation requirements.
[0049] The above-mentioned target test cases can be test cases designed to verify the functions and performance of a web page. Among them, the target test cases include the steps and expected results for testing various functions, interactions, and interfaces of the web page. Web page test cases can involve testing aspects such as page layout, link correctness, form validation, interactive functions, response time, etc. By executing the target test cases, it can be ensured that the web page can work as expected and provide a good user experience.
[0050] In an optional embodiment, when it is detected that the web page function corresponding to a web page is updated, the target test cases corresponding to the web page function can be obtained through the following steps:
[0051] Determine the updated content of the web page: Carefully read the update instructions, change logs, or relevant documents of the web page to understand the updated content and changed functional points, so as to determine the updated content of the web page.
[0052] Locate the functional points of the web page: Based on the updated content of the web page, communicate with developers or product owners to obtain more detailed information, so as to determine which functional points have changed or been added, and locate the functional points of the web page.
[0053] Check the existing test cases: Check the existing test case library to see if there are already test cases covering the functions of the web page. If there are existing test cases, they need to be updated or revised to adapt to the changes in the web page.
[0054] Create new test cases: If the existing test cases cannot cover the new functions of the web page, new test cases need to be created. Based on the functional points of the web page, consider different test scenarios and boundary conditions, and write new test cases.
[0055] Execute the test cases: According to the updated functions of the web page and the corresponding test cases, execute the test cases to verify whether the functions of the web page are working properly, and ensure that the test cases can cover all functional points and possible usage scenarios of the web page.
[0056] Update the test case library: Update and revise the test cases according to the test results and feedback to ensure that the test case library is synchronized with the functions of the web page.
[0057] It should be noted that obtaining the target test cases corresponding to the functions of the web page is a dynamic process. Therefore, it is necessary to maintain good communication and cooperation with the development team and product team, and update and adjust the test cases in a timely manner to adapt to the changes and requirements of the web page.
[0058] Step S104, perform automated testing on the web page based on the target test cases, monitor the preset events occurring during the automated testing process, and store the event information of the preset events.
[0059] The above-mentioned preset events can be events related to the needs of automated testing, such as access requests, access responses, output events, etc.
[0060] In an optional embodiment, during the process of performing automated testing on the web page using the target test cases, the following steps can be carried out:
[0061] Analyze the target test cases: Carefully read the target test cases to understand the functions to be tested and the expected results.
[0062] Environmental preparation: Set up a test environment, including installing test tools and configuring the test environment.
[0063] Write test scripts: According to the target test cases, use an automated test tool to write test scripts. The test scripts should include test steps and expected results.
[0064] Execute test scripts: Run the test scripts. The automated tool will simulate user operations and execute the test steps.
[0065] Check test results: The automated tool will automatically check whether the test results are consistent with the expectations. If the test fails, the automated tool will generate a failure report and record the failed test steps and actual results.
[0066] Analyze the reasons for failure: For the test cases that fail, it is necessary to analyze the reasons for failure. It may be code errors, environment configuration problems, page element positioning errors, etc. Fix according to the reasons for failure.
[0067] Re-execute test scripts: After fixing the errors, re-execute the test scripts to verify whether the fix is successful.
[0068] Generate test reports: After the test is completed, the automated tool will generate test reports, including information such as the execution results of test cases, pass rates, and failed test cases.
[0069] Manual verification: Automated testing can only verify specific test cases, and manual verification is also required to ensure the normal overall function of the web page.
[0070] Update test scripts: According to the results of manual verification, update the test scripts, add new test cases or fix existing target test cases.
[0071] In an optional embodiment, during the test, the automated test process can be monitored to determine whether there is a preset event on the web page. If there is a preset event on the web page, the information of the preset event existing on the web page can be stored.
[0072] Step S106, in response to the end of the automated test, determine whether there is abnormal event information in the stored target event information.
[0073] The above-mentioned target event information can be the event information of all preset events stored during the automated test process.
[0074] In an alternative embodiment, during the automated testing process, it is necessary to record and store the testing process in real time. After the testing is completed, all the recorded target event information is analyzed to determine whether there is any abnormal event information in the target event information, so as to implement the abnormal function testing of the web page. Optionally, compared with analyzing the event information of the preset event every time the preset event is monitored, by the above method, it is only necessary to analyze the target event information after the testing is completed, thereby improving the testing efficiency of the web page and solving the technical problem of low testing efficiency when testing the web page in the prior art.
[0075] Step S108, in response to the existence of abnormal event information in the target event information, output the abnormal event information.
[0076] In an alternative embodiment, if there is abnormal event information in the target event information, it can be considered that there is a functional abnormality in the web page. Therefore, it is necessary to output the abnormal event information so that the web page can be adjusted according to the abnormal event information. Optionally, the server 12 can send the abnormal event information to the client 10, and the client 10 can display the abnormal event information in text form on the graphical user interface or remind the user of the existence of abnormal event information in the form of an indicator light on the graphical user interface, so that the user can be prompted to send a retrieval instruction in any form, and after receiving the retrieval instruction, display the abnormal event information on the graphical user interface. Optionally, in the present invention, there is no specific limitation on the output method of the abnormal event information.
[0077] In the embodiment of the present invention, by responding to the detection of the update of the target page function corresponding to the web page, obtaining the target test case corresponding to the target page function; performing automated testing on the web page based on the target test case and monitoring the preset events occurring during the automated testing process, storing the event information of the preset events; responding to the end of the automated testing, determining whether there is any abnormal event information in the stored target event information; and in response to the existence of abnormal event information in the target event information, outputting the abnormal event information, it can be easily noticed that the web page can be tested after the web page is updated, and event listening can be performed during the testing, avoiding a series of actions such as annotating the web page during the testing process and performing quality inspection, cross-acceptance, and final acceptance on the data after annotation, and also avoiding simulating user behavior, realizing an automated method of covering user behavior by random page operations, thereby improving the testing efficiency of the web page and further solving the technical problem of low testing efficiency when testing the web page.
[0078] Optionally, perform automated testing on a web page based on a target test case, including: obtaining at least one page element in the web page; determining a preset operation corresponding to the at least one page element; and operating on the at least one page element based on the target test case and the preset operation corresponding to the at least one page element.
[0079] The above-mentioned at least one page element may be a Hyper Text Markup Language element (also known as an html element). An html element is the basic building block of an html document. An html element consists of a start tag and an end tag, with the content of the element in between. The content between the start tag and the end tag is the content of the element. Optionally, html elements are used to define the structure and content of a document. By using different elements, headings, paragraphs, links, images, etc. can be created.
[0080] The above-mentioned preset operation can specify an operation that can be performed on a page element, such as specifying click, double-click, long-press, etc. operations, or specifying zoom in, zoom out, drag, etc. operations.
[0081] In an optional embodiment, during the process of performing automated testing on a web page, a list of page elements corresponding to the web page can be obtained first, and the executable operations corresponding to the page elements included in the list can be determined. Further, based on the target test case and the executable operations corresponding to the at least one page element, the at least one page element can be operated on through playwright. Playwright is an automated testing tool. Using playwright can simulate user operation behaviors, avoiding the need to obtain real user operation behaviors, thereby improving the efficiency of automated testing.
[0082] Optionally, determining a preset operation corresponding to at least one page element includes: classifying the at least one page element to obtain a classification result of the at least one element; and determining a preset operation corresponding to the at least one page element based on the classification result of the at least one element.
[0083] In an optional embodiment, after determining at least one page element, the page elements can be classified. For example, the page elements can be classified into button, canvas, span, and the attributes of different page elements can be counted, such as whether the page element is visible, whether it is operable, etc. Further, the preset operation corresponding to the page element can be determined. For example, button specifies click, double-click, long-press, etc. operations, and canvas specifies zoom in, zoom out, drag, etc. operations, so that the at least one page element can be operated on using the preset operation corresponding to the at least one page element.
[0084] Among them, a button is an interactive element used to trigger specific operations on a web page, usually presented in a clickable form. After a user clicks the button, functions related to the button can be executed or specific events can be triggered. Among them, a canvas is used to draw graphics, animations, games, etc. on a web page. It provides a blank area where graphics can be drawn through JavaScript. Optionally, JavaScript can be a language used for graphic drawing. Developers can create various visual effects by drawing various shapes, lines, texts, images, etc. on the canvas. Among them, a span is used to represent an inline element in a document. It can be used to mark specific parts of the text.
[0085] Optionally, based on the target test case and the preset operations corresponding to at least one page element, operate on at least one page element, including: determining the target page element among at least one page element based on the target test case; operating on the target page element based on the preset operation corresponding to the target page element.
[0086] The above-mentioned target page element can be a page element that needs to be tested.
[0087] In an optional embodiment, after determining the page elements, it is necessary to determine the target page elements that need to be tested from the page elements. Optionally, the target page elements can be determined from at least one page element based on the target test case, and the target page elements can be operated on based on the preset operations corresponding to the target page elements.
[0088] Among them, when determining the target page element, the following steps can be taken:
[0089] First, it is necessary to determine the characteristics of the target page element, such as tags, attributes, text content, etc. These characteristics will become the assertion conditions in the test case. Second, use an appropriate test tool, such as playwright, to execute the target test case. The test tool can find the target page element by methods of locating page elements, such as addresses, class names, etc. Third, it is necessary to verify the target page element. After executing the test case, the test tool will return the target page element and verify whether the target page element is correct. It can be judged whether the returned page element is consistent with the expectation through assertions. Finally, adjust the test case. If the test case fails to accurately determine the target page element, the characteristics in the test case can be adjusted or more assertion conditions can be added to improve the accuracy.
[0090] Optionally, monitor preset events occurring during the automated test process and store the event information of the preset events, including: during the automated test process, monitor the access requests, access responses, and output events of the console for a web page, where the console is used to operate the web page; in response to detecting an access request, obtain the request method, request body, and request headers of the access request to obtain event information, and store the event information in the event information list; in response to detecting an access response, obtain the response headers, response body, and status code of the access response to obtain event information, and store the event information in the event information list; in response to detecting an output event, obtain the output content and information level of the output event to obtain event information, and store the event information in the event information list.
[0091] In an alternative embodiment, during the testing process, it is possible to monitor the access requests, access responses, and output events of the console for a web page. Specifically, it is possible to monitor whether the following access events occur:
[0092] First, the output event, that is, it is possible to monitor the output events of the console. When an output event occurs on the console is detected, it is possible to obtain the output content and output information level, such as log (also known as log), information (also known as info), warning (also known as warn), error (also known as error). Further, it is possible to determine whether a preset event has occurred based on the obtained output content, output information level, and other information.
[0093] Second, the access request, that is, when a network request occurs, it is possible to obtain the request method (also known as method), request body, and request headers.
[0094] Third, the access response, that is, when a network return occurs, it is possible to obtain the returned response headers (also known as headers), response body, and status code. Among them, the status code is used to represent the result monitored when monitoring preset events occurring during the automated test process. Optionally, assuming that the monitored result is that there is a preset event on the web page, a normal code can be displayed. Assuming that the monitored result is that there is no preset event on the web page, an abnormal code can be displayed, thereby reminding the user.
[0095] Among them, when an access request is detected, it is necessary to obtain the request method, request body, and request headers of the access request to obtain event information, and store the event information in the event information list. When an access response is detected, it is possible to obtain the response headers, response body, and status code of the access response to obtain event information, and store the event information in the event information list. When an output event is detected, it is possible to obtain the output content and information level of the output event to obtain event information, and store the event information in the event information list.
[0096] Optionally, determine whether there is abnormal event information in the stored target event information, including: determining whether there is an abnormal status code in the target storage information, or whether there is an abnormal information level in the target storage information; in response to the existence of an abnormal status code or abnormal information level in the target storage information, determine that there is abnormal event information in the target event information; in response to the non-existence of an abnormal status code and abnormal information level in the target storage information, determine that there is no abnormal event information in the target event information.
[0097] In an alternative embodiment, it is possible to determine whether there is abnormal event information in the target event information by detecting whether there is an abnormal status code in the target storage information, or whether there is an abnormal information level in the target storage information. Optionally, if there is an abnormal status code or abnormal information level in the target storage information, it can be determined that there is abnormal event information in the target event information. If there is no abnormal status code and no abnormal information level in the target storage information, it can be determined that there is no abnormal event information in the target event information. Further, when it is determined that there is abnormal event information in the target event information, a notification can be sent to the user through the corresponding application software.
[0098] Optionally, in response to the existence of abnormal event information in the target event information, output the abnormal event information, including: obtaining the identification information corresponding to the target page function and the use case information of the target test case; generating a test report for the web page based on the abnormal event information, identification information, and use case information; outputting the test report through a preset output method.
[0099] The above-mentioned preset output method can be the output method of the test report. Optionally, the output method can include displaying the test report on the graphical user interface of the client 10 based on the user's instruction, outputting the test report through a data connection line, and uploading the test report to the relevant application software, so as to pop up the corresponding test report through the application software, etc. Optionally, in the present invention, no specific limitation is imposed on the preset output method. In the present invention, taking the output of the test report through the relevant application software as an example for illustration.
[0100] The above-mentioned target page function can be the function abnormal situation corresponding to the abnormal event.
[0101] In an alternative embodiment, it is possible to obtain the identification information corresponding to the target page function and the use case information of the target test case, so as to be able to generate the corresponding test report for the web page based on the abnormal event information, identification information, and use case information, and output the test report through a preset output method.
[0102] Figure 2 It is a schematic diagram of a test report output method according to an embodiment of the present invention, asFigure 2 As shown, the test report can be uploaded to the relevant application software, which can feedback the results of the automated test. After each test is completed, the error situation of this test can be popped up by the feedback progress statistics box, and the corresponding test report can be popped up.
[0103] Optionally, the method further includes: displaying multiple test cases and multiple page functions of the web page in the interaction interface; responding to the binding instruction acting on the interaction interface, determining the to-be-bound test case among the multiple test cases and the to-be-bound page function among the multiple page functions; and binding the to-be-bound test case and the to-be-bound page function.
[0104] The above-mentioned interaction interface can be the graphical user interface of the client 10.
[0105] In an alternative embodiment, multiple test cases and multiple page functions of the web page can be displayed on the graphical user interface of the client 10. Further, the user can send a binding instruction to the server 12 in any instruction sending manner. Optionally, after receiving the binding instruction, the server 12 can determine the to-be-bound test case among the multiple test cases, that is, determine the test case that needs to be bound to the web page among the multiple test cases. At the same time, it can also determine the to-be-bound page function among the multiple page functions, that is, determine the page function that needs to be bound to the test case among the multiple page functions, so as to bind the to-be-bound test case and the to-be-bound page function.
[0106] Figure 3 It is a schematic diagram of binding a test case and a page function according to an embodiment of the present invention. As Figure 3 shown, after receiving the binding instruction, the test case to be bound can be selected from the to-be-bound test cases through a click operation, and the required page function can be determined from the to-be-bound page functions through a click operation. Further, the binding button can be clicked to bind the to-be-bound test case and the to-be-bound page function.
[0107] Figure 4 It is a schematic diagram of an automated test method according to an embodiment of the present invention. As Figure 4 shown, case testing can be performed by calling a hook service in the automated business pipeline, that is, calling the hook service to test the web page. After the test is completed, a corresponding test report can be generated, and the test report can be output by using the corresponding application software, so as to notify the user of the result of this test.
[0108] Embodiment 2
[0109] According to another aspect of the embodiments of the present invention, an automated test device for a web page is further provided.Figure 5 is a schematic diagram of an automated test device for a web page according to an embodiment of the present invention. As Figure 5 shown, the device includes:
[0110] An acquisition module 502, configured to acquire a target test case corresponding to a target page function in response to detecting an update of the target page function corresponding to the web page.
[0111] A test module 504, configured to perform an automated test on the web page based on the target test case, monitor a preset event occurring during the automated test, and store event information of the preset event.
[0112] A first determination module 506, configured to determine whether there is abnormal event information in the stored target event information in response to the end of the automated test.
[0113] An output module 508, configured to output the abnormal event information in response to the existence of the abnormal event information in the target event information.
[0114] Optionally, the test module 504 includes: a first acquisition unit, configured to acquire at least one page element in the web page; a first determination unit, configured to determine a preset operation corresponding to the at least one page element; and an operation unit, configured to operate on the at least one page element based on the target test case and the preset operation corresponding to the at least one page element.
[0115] Optionally, the determination unit includes: a classification subunit, configured to classify the at least one page element to obtain a classification result of the at least one element; and a first determination subunit, configured to determine a preset operation corresponding to the at least one page element based on the classification result of the at least one element.
[0116] Optionally, the operation unit includes: a second determination subunit, configured to determine a target page element among the at least one page element based on the target test case; and an operation subunit, configured to operate on the target page element based on the preset operation corresponding to the target page element.
[0117] Optionally, the test module 504 further includes: a monitoring unit, configured to monitor access requests, access responses, and output events of the console during the automated test process, where the console is used to operate on the web page; a first storage unit, configured to obtain the request method, request body, and request headers of the access request in response to monitoring the access request, obtain event information, and store the event information in the event information list; a second storage unit, configured to obtain the response headers, response body, and status code of the access response in response to monitoring the access response, obtain event information, and store the event information in the event information list; a third storage unit, configured to obtain the output content and information level of the output event in response to monitoring the output event, obtain event information, and store the event information in the event information list.
[0118] Optionally, the first determination module includes: a judgment unit, configured to determine whether there is an abnormal status code in the target stored information, or whether there is an abnormal information level in the target stored information; a second determination unit, configured to determine that there is abnormal event information in the target event information in response to the existence of an abnormal status code or an abnormal information level in the target stored information; a third determination unit, configured to determine that there is no abnormal event information in the target event information in response to the non-existence of an abnormal status code and an abnormal information level in the target stored information.
[0119] Optionally, the output module 508 includes: a second acquisition unit, configured to acquire the identification information corresponding to the target page function and the use case information of the target test case; a generation unit, configured to generate a test report of the web page based on the abnormal event information, identification information, and use case information; an output unit, configured to output the test report through a preset output method.
[0120] Optionally, the apparatus further includes: a display module, configured to display a plurality of test cases and a plurality of page functions of the web page in the interaction interface; a second determination module, configured to determine the to-be-bound test case among the plurality of test cases and the to-be-bound page function among the plurality of page functions in response to a binding instruction acting on the interaction interface; a binding module, configured to bind the to-be-bound test case and the to-be-bound page function.
[0121] Embodiment 3
[0122] On the other hand, according to an embodiment of the present invention, there is also provided a computer-readable storage medium, where the computer-readable storage medium includes a stored program, and when the program runs, it controls a processor of the device where it is located to execute the method in any one of the above.
[0123] Embodiment 4
[0124] According to another aspect of the embodiments of the present invention, an electronic device is further provided, including: one or more processors; a storage device for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors execute the method of any one of the above.
[0125] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0126] In the above embodiments of the present invention, the descriptions of the respective embodiments have their own emphases. For parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0127] In the several embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the units or modules can be in an electrical or other form.
[0128] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0129] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0130] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs.
[0131] The foregoing is only the preferred embodiment of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. An automated testing method for a web page, characterized in that, Including: In response to detecting an update to the target page function corresponding to the web page, obtain the target test case corresponding to the target page function; Based on the target test case, perform automated testing on the web page, monitor preset events occurring during the automated testing process, and store the event information of the preset events; In response to the end of the automated testing, determine whether there is abnormal event information in the target event information that has been stored; In response to the presence of the abnormal event information in the target event information, output the abnormal event information.
2. The method according to claim 1, characterized in that, Based on the target test case, performing automated testing on the web page includes: Obtain at least one page element in the web page; Determine the preset operations corresponding to the at least one page element; Based on the target test case and the preset operations corresponding to the at least one page element, perform operations on the at least one page element.
3. The method according to claim 2, characterized in that, Determining the preset operations corresponding to the at least one page element includes: Classify the at least one page element to obtain the classification result of the at least one element; Based on the classification result of the at least one element, determine the preset operations corresponding to the at least one page element.
4. The method according to claim 2, characterized in that Based on the target test case and the preset operations corresponding to the at least one page element, performing operations on the at least one page element includes: Based on the target test case, determine the target page element among the at least one page element; Based on the preset operation corresponding to the target page element, perform an operation on the target page element.
5. The method according to claim 1, wherein Monitoring preset events occurring during the automated testing process and storing the event information of the preset events includes: During the automated testing process, monitor the access requests, access responses, and output events of the console for the web page, where the console is used to operate the web page; In response to monitoring the access request, obtain the request method, request body, and request headers of the access request to obtain the event information, and store the event information in the event information list; In response to monitoring the access response, obtain the response headers, response body, and status code of the access response to obtain the event information, and store the event information in the event information list; In response to monitoring the output event, obtain the output content and information level of the output event to obtain the event information, and store the event information in the event information list.
6. The method according to claim 5, characterized in that, Determining whether there is abnormal event information in the target event information that has been stored includes: Determine whether there is an abnormal status code in the target stored information, or whether there is an abnormal information level in the target stored information; In response to the presence of the abnormal status code or the abnormal information level in the target stored information, determine that there is the abnormal event information in the target event information; In response to the absence of the abnormal status code and the abnormal information level in the target stored information, determine that there is no abnormal event information in the target event information.
7. The method according to claim 1, characterized in that, In response to the presence of the abnormal event information in the target event information, outputting the abnormal event information includes: Obtain the identification information corresponding to the target page function and the use case information of the target test case; Generate a test report for the web page based on the exception event information, the identification information, and the use case information; Output the test report through a preset output method.
8. The method according to claim 1, characterized in that, It further includes: Display multiple test cases and multiple page functions of the web page in the interaction interface; Respond to the binding instruction acting on the interaction interface, and determine the test case to be bound among the multiple test cases and the page function to be bound among the multiple page functions; Bind the test case to be bound and the page function to be bound.
9. An automated test device for a web page, characterized in that, It includes: An acquisition module, configured to obtain the target test case corresponding to the target page function in response to detecting an update of the target page function corresponding to the web page; A test module, configured to perform an automated test on the web page based on the target test case, monitor a preset event occurring during the automated test, and store the event information of the preset event; A first determination module, configured to determine whether there is exception event information in the stored target event information in response to the end of the automated test; An output module, configured to output the exception event information in response to the existence of the exception event information in the target event information.
10. An electronic device, characterized in that, It includes: One or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors execute the method according to any one of claims 1 to 8.