Browser page testing method and device, computer equipment and storage medium
The method of running test scripts through browser plug-ins solves the problems of high user threshold and high deployment cost in browser page testing, and realizes the testing ability and efficient testing efficiency of automatically adapting to different browsers.
Patent Information
- Application Number
- CN202311409562.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-27
- Publication Date
- 2025-04-29
AI Technical Summary
The existing automated testing tools have problems such as high user threshold, high deployment cost, inability to use out of the box, and need to write different test cases to adapt to different browsers in browser page testing.
The way to run test scripts through browser plug-ins does not need to install and configure the running environment of other programming languages. It provides a browser page testing method, including calling preset browser plug-ins to obtain the test script, displaying the target page, executing test cases, and displaying test information through the transparency window in the test page.
It realizes the ability to automatically adapt to different browsers, reduces the difficulty of user configuration and coding, improves testing efficiency, and enhances the visualization and intuitiveness of the test by displaying test information in real time.
Smart Images

Figure CN119902964A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer testing technology, and in particular to a browser page testing method, device, computer equipment and storage medium. Background Art
[0002] When we work and study online every day, there may be many times when we need to perform some repetitive operations on the browser, especially in the testing phase of the web development process. In order to ensure the quality of development, it is necessary to verify whether the functions meet expectations through actual operations very carefully. During this period, a large number of tedious and boring repetitive operations will be generated, which takes time and manpower, and is prone to errors over time.
[0003] In the field of web testing, there are many kinds of automated testing tools. Some are full-featured but expensive commercial software, such as Selenium, TestComplete, etc. There are also some large open source tools such as JMeter, some of which have clients and user interfaces, and some are operated through command lines. There is no doubt that these tools are very professional and can solve most problems, but their shortcomings are also very obvious, such as high user thresholds. In addition, there is a certain deployment cost. A lot of code deployment and configuration work must be done before use. It is difficult to use it out of the box. It is like a very high-tech instrument. First, it takes a long time to assemble and set it according to the instructions before it can be put into use. In the later stage, some adaptation work must be done according to the progress of the project, which increases the burden on users. In addition, due to the differences in browsers, developers need to write different test cases to test different browsers, which also increases the burden of testing work. Summary of the invention
[0004] Based on this, it is necessary to provide a browser page testing method, device, computer equipment and storage medium to address the above technical problems, and a browser plug-in to run the test script without the need to install and configure the operating environment of other programming languages.
[0005] In a first aspect, the present application provides a browser page testing method, comprising:
[0006] Calling a preset browser plug-in to obtain a test script to be executed by the browser, wherein the test script includes page information and test cases;
[0007] Displaying a target page according to the page information of the test script; wherein the target page is a test page used by the test script for testing;
[0008] The test case is executed, and test information of the test case is displayed in a first preset area of the target page through a window with a first preset transparency.
[0009] In some embodiments of the present application, before calling a preset browser plug-in to obtain a test script to be executed by the browser, the method further includes:
[0010] Calling the browser plug-in to display a script editing interface with a second preset transparency in a second preset area of the target page;
[0011] Receiving target information input by a user in the script editing interface, and generating a test case required for testing the target page according to the target information;
[0012] A test script for the target page is generated according to the test case and the page information of the target page.
[0013] In some embodiments of the present application, the receiving of target information input by the user in the script editing interface and generating a test case required for testing the target page according to the target information includes:
[0014] Receive target information input by a user in the script editing interface, the target information including a target element to be tested on the target page, a triggering event of the target element, and an expected result of executing the triggering event on the target element;
[0015] Determine a test event according to the target element and the trigger event;
[0016] Determining a test verification event for the test event according to the target element and the expected result;
[0017] Acquire the delay time between executing the test event and executing the test verification event through the script editing interface;
[0018] The test case is generated according to the test event, the test verification event and the delay time.
[0019] In some embodiments of the present application, receiving the target element to be tested of the target page input by the user in the script editing interface includes:
[0020] When the script editing interface is displayed on the target page, receiving a target input of a user to any element in the target page;
[0021] An element targeted by the target input is determined as the target element.
[0022] In some embodiments of the present application, when the test script includes multiple test cases, generating the test script of the target page according to the test cases and the page information of the target page includes:
[0023] Obtaining the number and type of target elements of the test event of each of the test cases;
[0024] If the number of target elements of at least two test cases is the same, sorting the at least two test cases according to the target element types of the at least two test cases to obtain a test case group;
[0025] Sort the test case group and the test cases outside the test case group in order of the number of target elements from small to large;
[0026] A test script for the target page is generated according to the sorted test cases and the page information of the target page.
[0027] In some embodiments of the present application, executing the test case and displaying the test information of the test case in a first preset area of the target page through a window of a first preset transparency includes:
[0028] Execute the test cases in sequence according to the order of the test cases in the test script;
[0029] When executing a certain test case, executing the test event of the certain test case, executing the test verification event of the certain test case after the delay time, and generating a test result of executing the test verification event;
[0030] The test information of the test case is displayed in a first preset area of the test page through a window of a first preset transparency, wherein the test information includes the test result.
[0031] In some embodiments of the present application, the test information further includes at least one of the target element of each test event in the test case, the test event, and the test progress of each test event.
[0032] In some embodiments of the present application, after generating the test script of the target page according to the test case and the page information of the target page, the method further includes:
[0033] Storing the test script of the target page in a script library in a first preset format;
[0034] When a script calling instruction is obtained through the browser plug-in, a test script to be called by the script calling instruction is determined from the script library according to the script calling instruction, and the test script to be called by the script calling instruction is converted into a test script of the target page in a second preset format.
[0035] In a second aspect, the present application provides a browser page testing device, comprising:
[0036] An information acquisition module, used to call a preset browser plug-in to obtain a test script to be executed by the browser, wherein the test script includes script information and a plurality of test cases;
[0037] A page display module, which is in communication with the information acquisition module, is used to determine the test page used for testing by the test script according to the script information of the test script; and jump to the test page of the browser;
[0038] The page test module is communicatively connected with the page display module, and is used for executing the plurality of test cases in sequence, and displaying the test information of the plurality of test cases in a first preset area of the test page through a window of a first preset transparency.
[0039] In some embodiments of the present application, the information acquisition module is also used to call the browser plug-in to display a script editing interface with a second preset transparency in a second preset area of the target page; receive target information input by the user in the script editing interface, and generate a test case required to test the target page based on the target information; and generate a test script for the target page based on the test case and page information of the target page.
[0040] In some embodiments of the present application, the information acquisition module is also used to receive target information input by a user in the script editing interface, the target information including the target element to be tested on the target page, the trigger event of the target element, and the expected result of executing the trigger event on the target element; determine a test event based on the target element and the trigger event; determine a test verification event for the test event based on the target element and the expected result; obtain the delay time between executing the test event and executing the test verification event through the script editing interface; and generate the test case based on the test event, the test verification event, and the delay time.
[0041] In some embodiments of the present application, the information acquisition module is also used to receive a user's target input for any element in the target page when the script editing interface is displayed on the target page; and determine the element targeted by the target input as the target element.
[0042] In some embodiments of the present application, the information acquisition module is also used to obtain the number of target elements and the target element type of the test event of each of the test cases; if at least two test cases have the same number of target elements, the at least two test cases are sorted according to the target element type of the at least two test cases to obtain a test case group; the test case group and test cases outside the test case group are sorted in order from small to large according to the number of target elements; and a test script for the target page is generated based on the sorted test cases and the page information of the target page.
[0043] In some embodiments of the present application, the page testing module is also used to execute the test cases in sequence according to the order of the test cases in the test script; when executing a test case, executing the test event of the test case, after the delay time, executing the test verification event of the test case, and generating a test result of executing the test verification event; displaying the test information of the test case in a first preset area of the test page through a window with a first preset transparency, and the test information includes the test result.
[0044] In some embodiments of the present application, the test information further includes at least one of the target element of each test event in the test case, the test event, and the test progress of each test event.
[0045] In some embodiments of the present application, the information acquisition module is also used to store the test script of the target page in a script library in a first preset format; when a script calling instruction is obtained through the browser plug-in, the test script to be called by the script calling instruction is determined from the script library according to the script calling instruction, and the test script to be called by the script calling instruction is converted into the test script of the target page in a second preset format.
[0046] In a third aspect, the present application further provides a computer device, the computer device comprising:
[0047] one or more processors;
[0048] A memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the browser page testing method.
[0049] In a fourth aspect, the present application also provides a computer-readable storage medium having a computer program stored thereon, and the computer program is loaded by a processor to execute the steps in the browser page testing method.
[0050] The above-mentioned browser page testing method, device, computer equipment and storage medium run the test script based on the browser plug-in, do not need to install and configure the operating environment of other programming languages, and can automatically adapt to different browsers. In addition, during the testing process, the test information is directly displayed in the test page through a window with a certain transparency, and the data and test information in the test page can be more intuitively displayed to the tester in the same interface, which is convenient for the tester to view and subsequent operations. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0052] Figure 1 It is a flowchart of the browser page testing method in an embodiment of the present application;
[0053] Figure 2 is a structural diagram of a browser page testing system in another embodiment of the present application;
[0054] Figure 3 is a flowchart of creating a script in another embodiment of the present application;
[0055] Figure 4 is a schematic diagram of another embodiment of the present application in which a script editing page is suspended on a target page;
[0056] Figure 5 is a schematic diagram of a test script in another embodiment of the present application;
[0057] Figure 6 is a schematic diagram of another embodiment of the present application in which real-time test information is suspended on a test page;
[0058] Figure 7 is a flowchart of a browser page testing method in another embodiment of the present application;
[0059] Figure 8 is a flowchart of a browser page testing method in another embodiment of the present application;
[0060] Fig. 9 It is a structural schematic diagram of a browser page testing device in an embodiment of the present application;
[0061] Fig.10 It is a schematic diagram of the structure of a computer device in an embodiment of the present application. DETAILED DESCRIPTION
[0062] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0063] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0064] In the description of the present application, the word "for example" is used to mean "used as an example, illustration or explanation". Any embodiment described as "for example" in the present application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is given to enable any technician in the field to implement and use the present invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.
[0065] Browser plug-in: Also known as browser extension, as the name implies, is a program that allows the browser to expand more functions, commonly known as plug-in. The main function of browser plug-in is to expand the functions of the browser, enrich the browsing experience, and meet different functional requirements. Many browsers have rich plug-ins with a wide range of application functions. In addition, programmers can also develop specific browser plug-ins.
[0066] Script plugin: A script used to extend or change the behavior of a web page in a web browser. It can add extra features for you, such as automatically filling in forms, automatically updating web page content, and enhancing the user experience of the website. Some can also help users manage and distribute their own scripts, or download and install scripts made by others. The most famous of these plugins is TamperMonkey.
[0067] Low-code technology: is a method of creating applications and software using technology based on a visual interface. Its advantage is that it allows technical and non-technical personnel to quickly develop and deploy applications without tedious programming steps. Its application scenarios include cloud application development, enterprise application development, data analysis and visualization, IoT application development, and more.
[0068] See also Figure 1 , the embodiment of the present application provides a browser page testing method, the method includes steps S101 to S103, which are as follows:
[0069] S101, calling a preset browser plug-in to obtain a test script to be executed by the browser, wherein the test script includes page information and a plurality of test cases.
[0070] Specifically, a preset browser plug-in is called to test the browser page, wherein the preset browser plug-in can be called by an operation on any browser page of the browser. The test script to be executed by the browser is obtained through the browser plug-in. The test script to be executed is the object to be tested selected by the user, and one or more test scripts can be selected for testing. If multiple test scripts to be executed are obtained, the test scripts are executed in sequence according to the selected order or other preset order for testing. In addition, if the user chooses to test the browser page currently displayed by the browser, the test script to be tested is obtained according to the page information of the currently displayed browser page.
[0071] A test script includes page information and several test cases. A test script is used to test a unique browser page. Page information is the page identification information of the test page used by the test script for testing. Page information includes but is not limited to information such as the URL and ID. However, a browser page may correspond to one or more test scripts. Test cases simulate the operations of users on the browser page that need to be tested, so a test script contains multiple test cases.
[0072] In one embodiment, this step also includes: S201, calling the browser plug-in to display a script editing interface with a second preset transparency in a second preset area of the target page; S202, receiving target information input by the user in the script editing interface, and generating a test case required for testing the target page according to the target information; S203, generating a test script for the target page according to the test case and the page information of the target page.
[0073] Specifically, in order to facilitate the tester to intuitively understand the events that need to be tested on the test page to be tested, the browser displays the target page of the test script to be created, and calls the browser plug-in to display the script editing interface of the second preset transparency in the second preset area of the target page, that is, the script editing interface is suspended on the target page, and the tester can edit the script according to the target page. The second preset area and the second preset transparency can be adjusted as needed, and the tester of the script editing interface that has been displayed on the target page can also move it directly, such as by dragging the mouse. The first preset area and the second preset area can be the same or different, and the first preset transparency and the second preset transparency can be the same or different. The script editing interface is designed as a translucent floating panel to minimize interference with the original interface. The user can freely adjust the transparency and position of the panel and adsorb it on the left or right side, so that the user's target input can be received, and the script editing interface is moved to the third preset area of the target page. The third preset area can be a predetermined fixed area or an area associated with the target input. For example, when the user selects an element, the script editing interface automatically moves to the area on the right side of the element so that the user can quickly determine where the edited test case is applicable.
[0074] The target information input by the user is received through the script editing interface, the test case required for testing the target page is generated according to the target information, and the test script of the target page is generated according to the test case and the page information of the target page. In addition, the browser includes several browser pages, and the number of test scripts edited for testing is large. In order to facilitate the storage and identification of the test script, the test script is provided with unique identification information, such as name, ID, etc.
[0075] In one embodiment, step S202, receiving target information input by a user in the script editing interface, and generating a test case required for testing the target page based on the target information, includes: S301, receiving target information input by a user in the script editing interface, the target information including a target element to be tested on the target page, a triggering event of the target element, and an expected result of executing the triggering event on the target element; S302, determining a test event based on the target element and the triggering event; S303, determining a test verification event for the test event based on the target element and the expected result; S304, obtaining the delay time between executing the test event and executing the test verification event through the script editing interface; S305, generating the test case based on the test event, the test verification event, and the delay time.
[0076] Specifically, the test case includes a test event and a test verification event. The test event is an operation that a user of the target page may perform, such as clicking on element A. The test verification event is to verify whether the structure of executing the test event is the same as the expected result, such as whether the page displayed by the browser after executing the test event and clicking on element A is the same as the expected page. The target element to be tested and the trigger event of the target element input by the tester are obtained through the script editing interface, and the test event is determined according to the target element and the trigger event. The target element is the operation object, and the trigger event is the operation performed on the operation object. For example, the target element is a scene selection box, and the trigger event is the content selected as "regional", then the test event is to select the content of the scene selection box as "regional". In addition, a test event may contain multiple target elements, and different target elements have different types. Each target element has a trigger event. For example, a target element is a scene selection box, and the corresponding trigger event is that the content of the scene selection box is "regional", and another target element is a customer type, and the corresponding trigger event is that the content of the customer type is "old customer", then the test event is to select the content of the scene selection box as "regional" and select the customer type as "old customer".
[0077] In addition, it is also necessary to input the expected execution result of the test event so that it can be used as a basis for judging whether the test has passed. Therefore, the target element of the target page entered by the tester and the expected result of the target element are obtained through the script editing interface, and the test verification event is determined based on the target element and the expected result. The test verification event is to verify whether the result obtained by executing the test event is the same as the expected result. For example, if the test event is to select the content of the scene selection box as "regional", the test verification event is to execute the test event to select the content of the scene selection box as "regional". Whether the page elements of the updated page are the same as the expected displayed page after the test event is executed. A test event may contain one or more test verification events.
[0078] Among them, there may be asynchronous requests after the test event is triggered, such as the need to request data from the server, so an appropriate delay needs to be added between executing the test event and verifying the result according to the test verification event. The delay time between the test event input by the tester and the execution of the test verification event is obtained through the script editing interface, and a test case is generated according to the test event, the test verification event and the delay time. It should be noted that the test case can be determined to have a unique name based on partial information of the test event and the test verification event.
[0079] In one embodiment, the step of receiving a target element to be tested on the target page input by a user in the script editing interface includes: S401, when the script editing interface is displayed on the target page, receiving a target input from the user for any element in the target page; S402, determining the element targeted by the target input as the target element.
[0080] Specifically, when the user selects a target element, in addition to directly inputting the element positioning code through the script editing interface to determine the target element, the user can also enable the element positioning function through the script editing interface to directly select the target element. The element positioning function can be enabled by clicking a preset icon on the script editing interface, or directly clicking the target element to be filled in on the script editing interface.
[0081] When the script editing interface is displayed on the target page, the user's target input for any element in the target page is received. The target input includes but is not limited to click, drag, box selection, etc. For example, first click the preset icon on the script editing interface, and then click the target element of the target page, or click the target element to be filled in on the script editing interface and drag it to the target element of the target page. According to the target input, the position of the click or drag focus (such as ID or class information, etc.) is determined, and then the target element is located. This embodiment also provides a low-code tool, which does not require testers to remember or find the location information of each element on the browser page, reducing the difficulty of editing scripts.
[0082] In one embodiment, when the test script includes multiple test cases, step S203, generates a test script for the target page according to the test cases and the page information of the target page, including: S501, obtaining the target element quantity and target element type of the test event of each of the test cases; S502, if at least two test cases have the same target element quantity, sorting the at least two test cases according to the target element type of the at least two test cases to obtain a test case group; S503, sorting the test case group and test cases outside the test case group in ascending order of the target element quantity; S504, generating a test script for the target page according to the sorted test cases and the page information of the target page.
[0083] Specifically, a test script contains multiple test cases, each test case imitates the user's operation on the browser page. The user cannot perform two different operations on the browser page at the same time. Therefore, when executing the test script, the test cases therein are executed one by one. The multiple test cases in the test script need to be sorted for subsequent calls and execution.
[0084] The number and type of target elements included in different test cases are not exactly the same. The test cases with fewer target elements have a lower possibility of incorrect test results. At the same time, when a test case fails the test, the test cases with fewer target elements are tested first, and the incorrect target elements can be located based on the previous test cases that passed the test.
[0085] Therefore, the number of target elements and target element types of the test events of each test case are obtained, and the test case group is obtained by sorting the test cases based on the number of target elements contained. For multiple test cases with the same number of target elements, the target element types are sorted according to the target element types contained. The sorting of the target element types follows the preset sorting strategy, which can be set by the tester as needed.
[0086] The sorted test case group is taken as a whole, and the test cases of the remaining non-test case groups are sorted in order of the number of target elements from small to large, and the test script of the target page is generated according to the sorted test cases and the page information of the target page.
[0087] In one embodiment, step S203, after generating the test script of the target page according to the test case and the page information of the target page, further includes: S601 storing the test script of the target page in a script library in a first preset format; S602, when a script calling instruction is obtained through the browser plug-in, determining the test script to be called by the script calling instruction from the script library according to the script calling instruction, and converting the test script to be called by the script calling instruction into the test script of the target page in a second preset format.
[0088] Specifically, in order to adapt to the different requirements of storage and execution, the scripts stored in the script library and the scripts during execution have different formats. After generating the test script of the target page, the test script of the target page is stored in the script library in a first preset format, for example, the script is saved in json format, and the scripts in the script library can be added, modified, copied or deleted through the management interface. When the tester needs to test the browser page, it is necessary to input the script call instruction through the browser plug-in to obtain the test script, determine the matching test script from the script library based on the script call instruction, and convert the test script matched by the script call instruction into a test script in a second preset format, for example, convert the test script matched by the script call instruction into a test script in a function format.
[0089] S102, displaying a target page according to the page information of the test script; wherein the target page is a test page used for testing by the test script.
[0090] Specifically, when editing a test script, the browser displays the target page tested by the test script, and the generated test script contains the page information of the target page. Therefore, the test page used by the test script for testing, i.e., the target page, is determined based on the page information of the test script. It should be noted that if the user chooses to test the browser page currently displayed by the browser when calling a browser plug-in to obtain a test script to be executed, i.e., the test script to be tested is obtained based on the page information of the currently displayed browser page, then the test page used by the test script for testing has been determined to be the browser page currently displayed by the browser, and there is no need to determine the test page according to this step.
[0091] After determining the test page, i.e., the target page, that the test script is used to test, the browser displays the target page. If the target page is the same as the browser page currently displayed by the browser, there is no need to jump and refresh.
[0092] S103, executing the test case, and displaying the test information of the test case in a first preset area of the target page through a window with a first preset transparency.
[0093] Specifically, several test cases in the test script are executed, and the test information of each test case is displayed in real time in the first preset area of the target page through a window of the first preset transparency, that is, the window displaying the test information of the test case is suspended on the test page. The first preset area and the first preset transparency can be adjusted as needed, and the script editing interface that has been displayed on the target page can also be directly moved by the tester, for example, by dragging the mouse.
[0094] The test information includes, but is not limited to, information such as the target element of the test event of each test case, the test event, and the test progress (such as passed, wait) of each test event. When all the test cases in the test script are executed and finished, a final test report of the test script will be generated. In addition to the detailed information in the real-time test report, there will also be a total test report consisting of the total number of use cases, the number of passed use cases, the total number of expected results, the number of passed expected results, and the test pass rate. In the present embodiment, during the test, the test progress is displayed in real time on the target page for the test, so that the user can intuitively and quickly understand the object of the test and the progress of each test.
[0095] In one embodiment, this step includes: S701, executing the test cases in sequence according to the order of the test cases in the test script; S702, when executing a certain test case, executing the test event of the certain test case, after the delay time, executing the test verification event of the certain test case, and generating a test result of executing the test verification event; S703, displaying the test information of the test case in a first preset area of the test page through a window with a first preset transparency, and the test information includes the test result.
[0096] Specifically, each test case is executed one by one in sequence according to the order of the test cases determined in the above embodiment. When executing each test case, the test event of the test case is executed first. After the test event is triggered, there may be an asynchronous request, such as the need to request data from the server. Therefore, after a delay time, the test verification event of the test case is executed based on the result of executing the test event. While executing each test case, the test information of each test case is displayed in a first preset area of the test page through a window with a first preset transparency. The test information includes the test result of executing the test verification event, that is, whether the result of outputting the execution of the test event is the same as expected. The specific displayed content can be set by the user as needed.
[0097] The way in which the browser plug-in runs the test script in this embodiment does not require the installation and configuration of the operating environment of other programming languages, and can automatically adapt to different browsers. Users do not need to write different test cases to test different browsers, and there is no need to configure or write intrusive code specifically for the test.
[0098] The embodiment of the present application provides a browser page testing system to solve the following common problems of current large-scale testing tools: Difficult to maintain, the test scripts of some testing tools are difficult to write and maintain, especially for non-developers, the learning curve is steep. Lack of scalability, some testing tools may lack scalability, cannot easily add custom functions or test libraries, and cannot meet the needs of complex testing scenarios. Lack of flexibility, some testing tools may be too focused on a specific type of test and cannot easily adapt to other types of tests, such as security testing, performance testing, etc. Dependence on a specific environment: Some testing tools rely on a specific environment and technology stack, which may prevent them from running in other environments, limiting their applicability. Insufficient reporting and visualization: Some testing tools may provide insufficient reporting and visualization, which may make it difficult to locate and fix problems. Lack of automation support: Some testing tools lack automation support and need to perform tests manually, which increases testing costs and time. Insufficient test coverage: Some testing tools may not cover all test scenarios and cannot find all defects and problems.
[0099] like Figure 2 As shown, the browser page test system includes a browser with a preset browser plug-in, a script editor, a script library, a script interpreter, and a log manager. Combined with the characteristics that the browser plug-in can be directly attached to the web page to run, after using the browser plug-in as the running environment, it is no longer necessary to rely on other specific running environments. The browser plug-in can be used in the testing field more directly than any UI testing tool developed in any other language. It can use native APIs to find and drive any DOM elements in the page, modify properties, trigger or listen to events, etc. It can be used as a supplement to other testing tools to complete some operations that other testing tools cannot do. In addition, the browser plug-in does not require the installation of additional software and running environment, and basically does not require any configuration to be quickly deployed. Its low-cost characteristics are also very suitable for small projects to quickly deploy test platforms, or some projects that do not have a good selection of test platforms in the early stage as overuse. Based on GUI editing scripts, it is separated from writing code, and test scripts become easy to maintain, which reduces the learning cost.
[0100] Script Editor
[0101] The user configures the script on the plugin interface, such as Figure 3 As shown, the configuration process is:
[0102] Select the target element to operate on
[0103] Select the event to be triggered or modify the properties of the element (i.e. trigger the event)
[0104] Set delay time
[0105] Select the target element to detect the result
[0106] Set the logical judgment formula for the judgment result
[0107] Expected outcome of the event
[0108] Finally, the script is output in json format and saved in the script library.
[0109] Script Interpreter
[0110] The test script written by the user is interpreted as a series of asynchronous programs called in serial. The script interpreter reads the test script configured by the user (saved in the script library in JSON format), and then converts it into subroutines such as interface element selection, event triggering, element value modification, timing, and expected result judgment, which are executed at set intervals.
[0111] Log Manager
[0112] The log program will display the test results of each step in real time on the interface during the script program execution, record these results, and finally generate a complete test report.
[0113] The browser page testing system includes the following functions:
[0114] (1) Create a script
[0115] Since the test script needs to be created on the page being tested, it is necessary to add a panel for related operations such as creating script files without destroying the test interface. Figure 4 As shown in the figure, in order to achieve this interaction mode, the script editing and other user interfaces are designed as semi-transparent floating panels (i.e., script editing interfaces) to minimize interference with the test interface. Users can freely adjust the transparency and position of the script editing interface and adsorb it on the left or right side of the test interface.
[0116] Test scripts have a similar operation mode, that is, simulating user operations and verifying whether the results of the operations meet expectations. Therefore, the creation of scripts can be divided into the following two steps: test event: select the target element + trigger the specified event on the target element, test verification event: select the target element + verify the expected result in the target element + record and output the test result. There may be asynchronous requests after triggering the specified event, so an appropriate delay time needs to be added between requesting the test event and verifying the test verification event result.
[0117] Low-code tools are used for operations when selecting target elements. In addition to manually writing element positioning code, users can also quickly locate the target element by dragging and dropping, thereby improving operational efficiency. This tool uses methods similar to XPath, CSS selectors, etc. to locate the target element. The HTML structure of the element can be viewed through the debugging tool to obtain positioning information. Then, by parsing the HTML structure of the element, the attribute information of the target element is extracted, such as tags, attribute values, text content, etc. Finally, based on the positioning and attribute information, the corresponding code (such as JavaScript code) is generated for operating and processing the target element.
[0118] (2) Management Scripts
[0119] In order to facilitate the storage and management of test scripts, test scripts are saved in json format. Multiple test scripts can be saved, and users can see these test scripts in the list of the script management interface, and can add, modify, copy or delete scripts in the management interface.
[0120] like Figure 5As shown, each test script has a name and an id, and can have multiple test cases. Each test case includes a selection element, a trigger event, a delay waiting time, and multiple expected results. Each expected result contains an element containing the expected result, a logical operation judgment, and an expected value.
[0121] (3) Execute the script
[0122] The test script will be executed one by one in the order of the test cases. The execution of each test case follows the process of selecting the specified element - triggering the specified event - waiting for the specified time - detecting the expected result. There can be no expected result or multiple expected results. The system will detect them one by one in order and give corresponding real-time reports.
[0123] (4) Real-time display of test information
[0124] During the execution of the test script, when each test case is executed to the detection result, the corresponding test result will be displayed in real time on the screen to see whether it meets the expectations. These results will also be recorded and presented as the final test report.
[0125] like Figure 6 As shown, the test case is executed on the test page. The left side is the test page being tested, and the test execution module of the user interface of the system covering the test page on the right is running the test script. Real-time test information is being output during the running process. The name of the test script is displayed at the top, and each item below corresponds to the test result of the use case. The execution result of the test case that passed the test in the report is displayed as a green PASS, and the test case being executed is displayed as a blue RUNNING, and the use case waiting to be executed is displayed as gray text, and the status is displayed as WAITING.
[0126] (5) Final test report
[0127] When all test cases in the test script are executed, a final test report will be generated. In addition to the detailed information in the real-time test report, there will also be an overall test report consisting of the total number of cases, the number of passed cases, the total number of expected results, the number of passed expected results, and the test pass rate.
[0128] In addition, if Figure 7 and Figure 8 As shown, the browser page testing system performs browser page testing including the following steps:
[0129] S1. The editing module of the browser plug-in selects the target element on the test page, and obtains the triggering event, expected result, attribute and other parameters of the target element to generate a test script;
[0130] S2. The script editor saves the test script generated by the editing module of the browser plug-in as a script file in JSON format, and the script manager saves the test script to the local script library and provides operations such as adding, modifying, and deleting scripts;
[0131] S3. When the tester calls the test script for the test page, the script interpreter converts the test script in JSON format into multiple functions for the browser plug-in to call;
[0132] S4. The running module of the browser plug-in calls the test script after the conversion format, and tests on the test page one by one according to the test cases in the test script; after executing the test event and selecting the target element to trigger the event, the test page executes the corresponding event element and updates the page, executes the test event delay and waits for the delay time to check the page element after the updated page, and uses the element value to execute the test verification event to obtain real-time test results, thereby completing the execution of a test case.
[0133] S5. The log module of the browser plug-in obtains real-time test information and logs from the running module, and displays the real-time test information through the test page;
[0134] S6. The log manager obtains the log from the log module of the browser plug-in, saves it, and provides a final test report.
[0135] In this embodiment, the user interaction interface for scripting is provided without destroying the original test page layout and display. The plug-in can record the operations performed by the user in the Web application and convert these operations into repeatable automated test scripts, allowing users to write scripts on the platform and manage them effectively. The test scripts are generated in a low-code manner. Users can create test scripts through the low-code tools provided by the platform to improve efficiency. After the script is fully executed, a complete test report is output according to the detection items set in each step.
[0136] There is no need to install and configure the runtime environment of other programming languages, just install the plug-in and the deployment is complete. The learning cost is extremely low, and only a small amount of JavaScript basics are required to master it. Native JavaScript can interact with any element of the page and drive events in real time without any obstacles. There is no need to configure or write intrusive code specifically for testing. It can quickly build a test platform for lightweight web applications, making it convenient to share test cases or collaborate with colleagues.
[0137] The browser plug-in runs user scripts in a way that the plug-in can record all the actions performed by users in the web application. This makes it very simple to create automated test scripts that can automatically adapt to different browsers. Users do not need to write different test cases to test different browsers. The final test report can help users better track and solve problems.
[0138] like Fig. 9 As shown, the embodiment of the present application provides a browser page testing device 900, including:
[0139] The information acquisition module 910 is used to call a preset browser plug-in to obtain a test script to be executed by the browser, wherein the test script includes script information and test cases;
[0140] A page display module 920, which is in communication with the information acquisition module 910 and is used to display a target page according to the script information of the test script, wherein the target page is a test page used for testing by the test script;
[0141] The page testing module 930 is communicatively connected with the page display module 920, and is used for executing the test case and displaying the test information of the test case in a first preset area of the target page through a window of a first preset transparency.
[0142] In some embodiments of the present application, the information acquisition module 910 is also used to call the browser plug-in to display a script editing interface with a second preset transparency in a second preset area of the target page; receive target information input by the user in the script editing interface, and generate a test case required to test the target page based on the target information; and generate a test script for the target page based on the test case and page information of the target page.
[0143] In some embodiments of the present application, the information acquisition module 910 is also used to receive target information input by a user in the script editing interface, the target information including the target element to be tested on the target page, the trigger event of the target element, and the expected result of executing the trigger event on the target element; determine a test event based on the target element and the trigger event; determine a test verification event for the test event based on the target element and the expected result; obtain the delay time between executing the test event and executing the test verification event through the script editing interface; and generate the test case based on the test event, the test verification event, and the delay time.
[0144] In some embodiments of the present application, the information acquisition module 910 is also used to receive a user's target input for any element in the target page when the script editing interface is displayed on the target page; and determine the element targeted by the target input as the target element.
[0145] In some embodiments of the present application, the information acquisition module 910 is also used to obtain the number of target elements and the target element type of the test event of each of the test cases; if at least two test cases have the same number of target elements, the at least two test cases are sorted according to the target element type of the at least two test cases to obtain a test case group; the test case group and test cases outside the test case group are sorted in order from small to large according to the number of target elements; and a test script for the target page is generated based on the sorted test cases and the page information of the target page.
[0146] In some embodiments of the present application, the page testing module 930 is also used to execute the test cases in sequence according to the order of the test cases in the test script; when executing a test case, execute the test event of the test case, and after the delay time, execute the test verification event of the test case, and generate a test result of executing the test verification event; display the test information of the test case in a first preset area of the test page through a window with a first preset transparency, and the test information includes the test result.
[0147] In some embodiments of the present application, the test information also includes the target element of each test event in the test case, the test event, and the test progress of each test event.
[0148] In some embodiments of the present application, the information acquisition module 910 is also used to store the test script of the target page in a script library in a first preset format; when a script calling instruction is obtained through the browser plug-in, the test script to be called by the script calling instruction is determined from the script library according to the script calling instruction, and the test script to be called by the script calling instruction is converted into the test script in a second preset format.
[0149] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0150] For example, Fig.10 The computer device shown can be Fig. 9The information acquisition module 910 in the browser page testing device 900 shown in the figure performs step S101. The computer device can perform steps S102 and S103 through the page display module 920. The computer device can perform step S104 through the page testing module 930. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external computer device through a network connection. When the computer program is executed by the processor, a browser page testing method is implemented.
[0151] Those skilled in the art will understand that Fig.10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0152] In some embodiments of the present application, a computer device is provided, comprising one or more processors; a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor in the steps of the above-mentioned browser page testing method. The steps of the browser page testing method here may be the steps of the browser page testing method in each of the above-mentioned embodiments.
[0153] In some embodiments of the present application, a computer-readable storage medium is provided, which stores a computer program, and the computer program is loaded by a processor, so that the processor executes the steps of the above-mentioned browser page testing method. The steps of the browser page testing method here can be the steps of the browser page testing method in each of the above-mentioned embodiments.
[0154] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0155] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0156] The above is a detailed introduction to a browser page testing method, device, computer equipment and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A browser page testing method, characterized in that: include: Calling a preset browser plug-in to obtain a test script to be executed by the browser, wherein the test script includes page information and test cases; Displaying a target page according to the page information of the test script; wherein the target page is a test page used by the test script for testing; The test case is executed, and test information of the test case is displayed in a first preset area of the target page through a window with a first preset transparency.
2. The browser page testing method according to claim 1, characterized in that: Before calling the preset browser plug-in to obtain the test script to be executed by the browser, it also includes: Calling the browser plug-in to display a script editing interface with a second preset transparency in a second preset area of the target page; Receiving target information input by a user in the script editing interface, and generating a test case required for testing the target page according to the target information; A test script for the target page is generated according to the test case and the page information of the target page.
3. The browser page testing method according to claim 2, characterized in that: The receiving target information input by the user in the script editing interface and generating a test case required for testing the target page according to the target information includes: Receive target information input by a user in the script editing interface, the target information including a target element to be tested on the target page, a triggering event of the target element, and an expected result of executing the triggering event on the target element; Determine a test event according to the target element and the trigger event; Determining a test verification event for the test event according to the target element and the expected result; Acquire the delay time between executing the test event and executing the test verification event through the script editing interface; The test case is generated according to the test event, the test verification event and the delay time.
4. The browser page testing method according to claim 3, characterized in that: Receiving a target element to be tested on the target page input by a user in the script editing interface, including: When the script editing interface is displayed on the target page, receiving a target input of a user to any element in the target page; An element targeted by the target input is determined as the target element.
5. The browser page testing method according to claim 3, characterized in that: In the case where the test script includes a plurality of test cases, generating the test script of the target page according to the test cases and the page information of the target page includes: Obtaining the number and type of target elements of the test event of each of the test cases; If the number of target elements of at least two test cases is the same, sorting the at least two test cases according to the target element types of the at least two test cases to obtain a test case group; Sort the test case group and the test cases outside the test case group in order of the number of target elements from small to large; A test script for the target page is generated according to the sorted test cases and the page information of the target page.
6. The browser page testing method according to claim 3, characterized in that: The executing the test case and displaying the test information of the test case in a first preset area of the target page through a window of a first preset transparency includes: Execute the test cases in sequence according to the order of the test cases in the test script; When executing a certain test case, executing the test event of the certain test case, executing the test verification event of the certain test case after the delay time, and generating a test result of executing the test verification event; The test information of the test case is displayed in a first preset area of the test page through a window of a first preset transparency, wherein the test information includes the test result.
7. The browser page testing method according to claim 6, characterized in that: The test information further includes at least one of the target element of each of the test events in the test case, the test event, and the test progress of each of the test events.
8. The browser page testing method according to claim 2, characterized in that: After generating the test script of the target page according to the test case and the page information of the target page, the method further includes: Storing the test script of the target page in a script library in a first preset format; When a script calling instruction is obtained through the browser plug-in, a test script to be called by the script calling instruction is determined from the script library according to the script calling instruction, and the test script to be called by the script calling instruction is converted into a test script of the target page in a second preset format.
9. A browser page testing device, characterized in that: include: An information acquisition module, used to call a preset browser plug-in to acquire a test script to be executed by the browser, wherein the test script includes script information and test cases; A page display module, which is in communication with the information acquisition module and is used to display a target page according to the script information of the test script, wherein the target page is a test page used for testing by the test script; The page testing module is communicatively connected with the page display module, and is used for executing the test case and displaying the test information of the test case in a first preset area of the target page through a window of a first preset transparency.
10. A computer device, characterized in that: The computer device comprises: one or more processors; A memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the browser page testing method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to execute the steps in the browser page testing method according to any one of claims 1 to 8.