Browser page function test method and device
By obtaining automated test data in the visual code writer, the problem of low stability of browser page function test recording results in the prior art is solved, and the testing efficiency and controllability are improved.
Patent Information
- Application Number
- CN202311755411.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-19
- Publication Date
- 2025-06-20
AI Technical Summary
In the prior art, the recording results of browser page function tests are not stable, resulting in the subsequent testing process being uncontrollable, and the recording technology is implemented in the form of a browser plug-in, affecting the testing efficiency.
By introducing a visual code writer, we obtain pre-determined automated test data, including general code generated based on use cases, atomic functions or user operations recorded, and use this data to test the test browser page functions.
It improves the efficiency of browser page function testing, ensures controllability and stability of the test process, and avoids the problem of element selector failure in recording technology.
Smart Images

Figure CN120179541A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the technical field of computers and network communications, and in particular, to a method and device for testing browser page functions. Background Art
[0002] Automated testing is an important technical means to ensure the quality of the front end. However, for users such as developers, it takes a lot of effort to learn the test framework and maintain test cases, resulting in a certain amount of labor costs.
[0003] In the prior art, the above problems can be solved based on the recording technology. Specifically, the user confirms "start recording", opens the browser and the target web page, the user confirms the page function to be tested, and operates on the page. After the user's operation is completed, the recording is ended. The recording technology will generate a piece of data associated with the just operation path, and subsequently, the page function of the browser to be tested can be tested based on this data.
[0004] However, the above recording technologies are all implemented in the form of browser plug-ins, which affect the efficiency of browser page function testing during actual testing. Summary of the Invention
[0005] The present disclosure provides a method and device for testing browser page functions to solve the problem that the stability of the recording result in the prior art is not high, resulting in an uncontrollable subsequent testing process.
[0006] In a first aspect, embodiments of the present disclosure provide a method for testing browser page functions, including:
[0007] Obtaining pre-determined automated test data in a visual code editor, where the automated test data is generated based on the general code corresponding to the preset use cases in the visual code editor, or generated based on the atomic functions corresponding to the preset test cases selected in the visual code editor, or generated by recording the user's operation behavior on the browser page;
[0008] Using the automated test data to test the browser page function to be tested to obtain a test result.
[0009] In a second aspect, embodiments of the present disclosure provide a device for testing browser page functions, the device includes:
[0010] An acquisition unit for acquiring predetermined automated test data in a visual code writer, where the automated test data is generated based on general code corresponding to a preset use case in the visual code writer, or generated based on atomic functions corresponding to preset test cases selected in the visual code writer, or generated by recording a user's operation behavior on a browser page;
[0011] A test unit for testing the function of a browser page to be tested by using the automated test data to obtain a test result.
[0012] In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0013] The memory stores computer-executable instructions;
[0014] The processor executes the computer-executable instructions stored in the memory to implement the test method for the browser page function as described in the first aspect above.
[0015] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the test method for the browser page function as described in the first aspect above.
[0016] In a fifth aspect, an embodiment of the present disclosure provides a computer program product including a computer program, and when the computer program is executed by a processor, it implements the test method for the browser page function as described in the first aspect above.
[0017] The test method and device for the browser page function provided by the embodiments of the present disclosure obtain predetermined automated test data in a visual code writer. The automated test data is generated based on general code corresponding to a preset use case in the visual code writer, or generated based on atomic functions corresponding to preset test cases selected in the visual code writer, or generated by recording a user's operation behavior on a browser page. Then, the function of the browser page to be tested is tested by using the automated test data to obtain a test result. In this technical solution, relevant test code can be quickly generated based on some processing operations of the user on the visual code writer, improving the efficiency of browser page function testing. Description of the Drawings
[0018] To more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are some embodiments of the present disclosure. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0019] Figure 1 Schematic diagram of the execution architecture of the test method for browser page functions provided by the embodiments of the present disclosure;
[0020] Figure 2 Schematic flow chart of the test method for browser page functions provided by the embodiments of the present disclosure Figure 1 ;
[0021] Figure 3 Schematic flow chart of the test method for browser page functions provided by the embodiments of the present disclosure Figure 2 ;
[0022] Figure 4 Schematic diagram of the creation page of the visualization code editor provided by the embodiments of the present disclosure;
[0023] Figure 5 Schematic diagram of the recording page provided by the embodiments of the present disclosure;
[0024] Figure 6 Schematic diagram of the management of automated test data provided by the embodiments of the present disclosure;
[0025] Figure 7 Schematic flow chart of the test method for browser page functions provided by the embodiments of the present disclosure Figure 3 ;
[0026] Figure 8 Schematic flow chart of the test method for browser page functions provided by the embodiments of the present disclosure Figure 4 ;
[0027] Figure 9 Schematic diagram of the structure of the test device for browser page functions provided by the embodiments of the present disclosure;
[0028] Figure 10 Schematic diagram of the structure of the electronic device provided by the embodiments of the present disclosure. Detailed implementation manners
[0029] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present disclosure with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are some, but not all, of the embodiments of the present disclosure. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present disclosure without creative efforts shall fall within the scope of protection of the present disclosure.
[0030] Automated testing is an important technical means to ensure the quality of the front end. However, for users such as developers and testers, learning test frameworks and maintaining test cases require a lot of effort and bring certain labor costs.
[0031] Recording is a technology born to solve the above problems. It can capture the operation paths of users on the page and generate automated test cases, significantly reducing the labor costs of learning frameworks and maintaining cases.
[0032] Among them, the process of the recording technology can be implemented as follows:
[0033] 1. The user confirms "start recording", opens the browser and the target web page;
[0034] At this time, a recording script will be loaded in the web page, and the role of the script is to capture the operation paths of users on the page.
[0035] 2. The user confirms the page function to be tested and operates on the page;
[0036] At this time, the recording technology will automatically record the operation paths of the user, such as clicks, inputs, etc.
[0037] 3. After the user finishes the operation, end the recording, and the recording technology will generate a piece of data associated with the just operation path;
[0038] At this time, the user can directly use this data to export test cases and apply them to automated testing.
[0039] However, the above recording technology is generally implemented in the form of browser plugins. For example, recording tools such as Selenium IDE and Chrome Devtools Recorder all have the following technical problems:
[0040] 1. It cannot be seamlessly connected to code editing after recording. That is, recording is more like a low-code (ProCode) tool and cannot achieve completely no-code (No Code). Usually, secondary editing is required after exporting the code;
[0041] 2. It fails to meet business requirements and subsequent plans, such as integrating with existing test case functions in the business (code management, debugging, etc.);
[0042] 3. The stability of the recording results is not high, mainly reflected in the fact that the generated element selectors are prone to failure during playback or test execution;
[0043] 4. During actual testing, in some implementations, users need to completely write the corresponding code, and a solution for quickly generating test code cannot be achieved, which affects the test efficiency.
[0044] In view of the technical problems existing in the prior art, the technical concept of the inventor is as follows: A visual code editor (Visual Studio Code, VSCode) can be introduced to implement recording. Since the visual code editor, as a front-end development editor, provides code development capabilities and can be responsible for data communication, page driving, file operations, etc. During recording, the data recorded on the recording browser can be converted into steps, that is, storing recording operations, providing code editing of the recording results, etc. During subsequent playback (i.e., testing), based on the recording results, the page of the browser to be tested can be controlled for testing.
[0045] Figure 1 The execution architecture diagram of the test method for browser page functions provided by the embodiments of the present disclosure is as Figure 1 shown. The execution architecture includes: a visual code editor plugin, a recording home page, and a recording browser.
[0046] In a possible implementation, at the bottom layer of the visual code editor plugin, it is responsible for data communication, browser page driving, file operations, etc.; the recording home page is responsible for automated test data management after recording; the recording browser is responsible for providing a recording & playback environment (that is, recording the operation behaviors of users and testing the browser page to be tested based on the automated test data generated by the visual code editor plugin).
[0047] Among them, the recording browser is a browser in the Puppeteer environment, including: Puppeteer Chromium, and the recording home page is Webview.
[0048] It should be understood that: Figure 1 The execution architecture is only one possible implementation of this method and is not limited.
[0049] The execution subject of the test method for browser page functions involved in the embodiments of the present disclosure is an electronic device, which can be a mobile phone, a computer, a computer, a tablet, a server, etc.
[0050] The following is the specific implementation process of the test method for browser page functions, the test device for browser page functions, and electronic devices involved in the embodiments of the present disclosure. Some examples are for illustration only and are not limited.
[0051] Figure 2 Schematic flow of the test method for browser page functions provided by the embodiments of the present disclosure Figure 1 。
[0052] As Figure 2 shown, the test method for browser page functions includes:
[0053] Step 21: Obtain the pre-determined automated test data in the visualization code editor;
[0054] Among them, the automated test data is generated based on the general code corresponding to the preset use cases in the visualization code editor, or based on the atomic functions corresponding to the selected preset test cases in the visualization code editor, or based on the recording of the user's operation behavior on the browser page;
[0055] In this step, obtaining the pre-determined automated test data from the visualization code editor can be test cases such as automated test scripts.
[0056] Optionally, the automated test data is implemented based on the visualization code editor plugin. As a front-end development editor, the visualization code editor provides a good code development experience. In the implementation, operations such as writing test cases such as automated test scripts can be performed on the visualization code editor.
[0057] Optionally, the above-mentioned automated test data can also be pre-placed in some online platforms related to testing, and downloaded or retrieved from the online platform during actual testing.
[0058] Optionally, the generation of automated test data can have the following possible implementations:
[0059] The first: In response to creating a recording use case in the visualization code editor and recording the user's operation behavior on the corresponding browser page, generating automated test data (this implementation is detailed in the following embodiments);
[0060] The second: In response to the operation of writing operation behavior code into the general code corresponding to the use case in the visualization code editor, generating automated test data;
[0061] The third: In response to selecting the atomic function corresponding to the test case in the visualization code editor, generating automated test data based on the atomic function corresponding to the test case.
[0062] Under the second and third implementations, operation interfaces are reserved in the visual code writer tool to support the user's ability to customize the generation of automated test data related to their business.
[0063] For example, in the second implementation, the user writes variable code for behavioral operations in the visual code writer. These can be atomic-like variables that are matched with the general code of pre-set relevant test cases to create test cases, and then form the code for executing relevant user operations, that is, generate automated test data.
[0064] Specifically, the user can configure in the form of code-written data and export a function in the code file that is the same as the key value. Write the specific operation behavior to be executed in this function, thereby implementing the atomic function of the code, and then generate automated test data.
[0065] For example, in the third implementation, on the visual code writer page, there is a pre-set custom configuration option, such as "custom". Under this option, various atomic functions configured can be viewed. Then select an atomic function and start recording operations to generate subsequent automated test data.
[0066] Optionally, in response to the user's writing operation, the automated test code corresponding to the automated test data can be edited in the visual code writer to generate new automated test data.
[0067] Under this implementation, after the test data recording is implemented, the automated test data can be opened in the visual code writer. Then, based on business requirements, personal needs, user experience, etc., the user can perform editing operations such as modifying, supplementing, and partially deleting the automated test data to obtain the desired automated test data.
[0068] And under this implementation, the drawback that the test data obtained by conventional browser plug-in recording cannot be directly edited can be avoided, improving the test data generation ability and the efficiency of subsequent tests.
[0069] Step 22: Use the automated test data to test the functions of the browser page to be tested and obtain the test results.
[0070] In this step, after obtaining the automated test data above, based on this automated test data, the browser to be tested is tested, that is, the page functions of the browser are tested, such as query function, jump function, display function, etc. After the test, the corresponding test results are obtained.
[0071] Optionally, the automated test data includes sub-data corresponding to multiple operation behaviors. The implementation of this step can be as follows: for each sub-data, use the sub-data to perform page operations on the browser to be tested, and record the results corresponding to the page operations. Among them, the test results include: the results corresponding to the page operations of all sub-data.
[0072] In this implementation, the automated test data obtained above can include: sub-data corresponding to multiple operation behaviors. For example, for the operation behavior: click on the element "X", the browser page will then jump to the relevant page of "X" and display the relevant content of "X". Then, the sub-data corresponding to "click on the element 'X'" is the test case for implementing this test scenario. In subsequent page operations on the browser to be tested, the test case of this test scenario can be used to implement the click operation on the element "X" on the browser to be tested, so as to obtain the corresponding display result and record the result corresponding to this page operation.
[0073] Furthermore, in the implementation of testing the browser to be tested, for some special services, it can be based on the atomic function method, that is, it supports users to connect the customized capabilities and the capabilities customized for the corresponding services in the form of code and access them into the recording tool for use. For example, users write some general code functions in the visual code editor project. These code functions provide a mechanism for users to configure according to this mechanism, or provide a rule. After configuring according to this rule, the capabilities of these general code functions can be used in the recording tool to meet business requirements, etc.
[0074] The test method for the browser page function provided by the embodiments of the present disclosure obtains the pre-determined automated test data in the visual code editor. The automated test data is generated based on the general code corresponding to the preset test cases in the visual code editor, or generated based on the atomic functions corresponding to the selected preset test cases in the visual code editor, or generated by recording the operation behaviors of users on the browser page. Then, use the automated test data to test the function of the browser page to be tested to obtain the test results. In this technical solution, relevant test code can be quickly generated on the visual code editor based on some processing operations of users, improving the efficiency of testing the browser page function.
[0075] Based on the above embodiments, Figure 3 This is a schematic flowchart of the test method for the browser page function provided by the embodiments of the present disclosure Figure 2 . As Figure 3 shown, the test method for the browser page function further includes:
[0076] Among them, in this embodiment, a process is implemented in which, in response to creating a recording use case in a visualization code editor and recording the operation behavior of a user on a corresponding browser page, automated test data is generated.
[0077] Step 31: In response to a creation operation, create a recording use case on the visualization code editor and obtain the identifier of the web page corresponding to the recording use case.
[0078] In this step, after installing the visualization code editor, open the plugin view of the visualization code editor. In response to the user clicking on the corresponding recording home page icon, enter the recording home page to create a recording use case.
[0079] In this implementation, Figure 4 FIG. is a schematic diagram of the creation page of the visualization code editor provided by the embodiment of the present disclosure. As Figure 4 shown, in the creation operation, when creating a recording use case, the name of the use case can be set. For example, demo. This implementation can be achieved in the visualization code editor.
[0080] After that, the recording web page uniform resource locator (URL) can be input, which can be the identifier of the web page. For example, the website address is www.1235XXXX.com. This implementation can be input in the recording home page Webview.
[0081] Step 32: In response to a recording operation, record the operation behavior of the user on the browser page corresponding to the identifier of the web page to obtain the test case corresponding to the recording use case.
[0082] In this step, after inputting the identifier of the recorded web page, in response to the recording operation of the user clicking to start recording, the browser is opened, and the user operates the function to be tested on the browser page, that is, the operation behavior of the user. After the operation ends, the test case corresponding to the recording use case is generated.
[0083] In this implementation, Figure 5 FIG. is a schematic diagram of the recording page provided by the embodiment of the present disclosure. As Figure 5 shown, when the user clicks the recording operation to start recording, the content of the website address, such as AAA, BBB, CCC, and the operation process of the user, are displayed on the browser page.
[0084] In addition, additional functions can also be provided, such as assertions, screenshots, and so on.
[0085] Optionally, when starting to record the browser using Puppeteer, a JavaScript script will be injected into the page, and this script listens through the Application Programming Interface (API).
[0086] Step 33: Generate automated test data corresponding to the test case.
[0087] In this step, after the recording ends, that is, after closing the browser page, corresponding automated test data can be generated based on the above recording process.
[0088] Optionally, the generation method can be: there are multiple step data in the test case, that is, each operation behavior recorded on the browser page, thus constituting the automated test data.
[0089] In addition, a function for editing the step data can also be provided, that is, editing operations that can be performed on the steps, such as copy, paste, add, delete, etc.
[0090] In a possible implementation, after the recording is completed, the correctness of the recorded data can be verified through the playback function: click the "Start Playback" icon (in addition, a function for setting the playback rate is also provided).
[0091] The browser is opened, and the case steps are automatically executed. If all pass, it is regarded as a successful playback; if there is one failure, it is regarded as a failed playback. After the case step data is confirmed to be correct, click the "Export Code" button, and a case file is successfully created, that is, the automated test data.
[0092] During specific playback, after starting the browser using Puppeteer, first find the target element, and then call the Puppeteer API according to the step type to drive the browser page. The implementation can be referred to the Figure 7 illustrated embodiment.
[0093] In this implementation Figure 6 is a schematic diagram of the management of the automated test data provided by the embodiments of the present disclosure, as Figure 6 shown, showing the implementation of opening a web page (target: www.1235XXXX.com), clicking operation 1 (target: 111), clicking operation 2 (target: 112), etc.
[0094] Among them, 111 is "css=#div>ul...", and 112 is "css=#_next>#main...".
[0095] In addition, a value is also shown.
[0096] The test method for browser page functions provided by the embodiments of the present disclosure creates a recording use case on a visual code editor in response to a creation operation, obtains the identifier of the web page corresponding to the recording use case, and records the operation behavior of the user on the browser page corresponding to the identifier of the web page in response to a recording operation to obtain a test case corresponding to the recording use case, and then generates automated test data corresponding to the test case. In this technical solution, the recording of the user's operation behavior is realized through the visual code editor plug-in, so as to generate the automated test data for subsequent testing.
[0097] Based on the above embodiments, Figure 7 is a schematic flowchart of the test method for browser page functions provided by the embodiments of the present disclosure Figure 3 As Figure 7 shown, in the test method for browser page functions, page operations are performed on the browser to be tested using sub-data, and the results corresponding to the page operations are recorded, which may include:
[0098] Step 71: Based on at least one element selector, select a target element or the parent element of the target element in the page of the browser to be tested according to the sub-data;
[0099] Among them, the behavior triggered by the target element is the same as the behavior triggered by the parent element corresponding to the target element.
[0100] In this solution, in the recording function, the element selector is very important, and its quality plays a decisive role in the stability of the recording use case. If the quality of the element selector in a step is poor, it will easily lead to the failure of finding the target element, resulting in the failure of the execution of the entire use case.
[0101] Optionally, to further improve the stability of the element selector, if the selector result of the target element is unstable, try to find a parent element with higher stability to replace the target element by bubbling. That is, based on at least one element selector, the target element or the parent element of the target element can be selected in the page of the browser to be tested according to the sub-data for the subsequent execution process.
[0102] Among them, it is judged whether the parent element can replace the target element to perform subsequent page operations, such as whether the behavior occurring when clicking on the parent element is exactly the same as that of the target element; termination condition: if the occurring behavior is inconsistent, then terminate the bubbling; generate the selector result of the parent element and check the stability of the result.
[0103] Optionally, in this solution, multiple element selectors can be provided during playback or testing, for example, query selector, css selector, text selector, xpath selector.
[0104] Among them, the elements are buttons, input boxes, drop-down menus, etc. on the page. Using element selectors can enable test scripts to accurately find and operate on various elements on the page, thereby implementing various operations in automated test cases.
[0105] Optionally, the implementation of this step can be: determining a target element or the parent element corresponding to the target element in the page of the browser to be tested based on at least one element selector and a preset regular expression.
[0106] To improve the stability of recorded test cases, a loose-mode execution mechanism can be introduced, which can be: the element selector lookup API no longer uses the "equals" operator to match the target element, but instead uses operators with a wider matching range such as "fuzzy" and "contains" (which can be implemented based on special rules, for example, in the way of regular expressions); return a list of target elements that match successfully and give a matching description, such as found through the XX operator, the element context structure, etc.; continue to execute the remaining process using the target element with the highest matching degree, and display the matching situation after the execution ends; the user can choose whether to use the matching element, and if confirmed, update the selector information.
[0107] Optionally, the preset selector sequence includes at least one element selector arranged in order of priority. Then the implementation of this step can be: sequentially performing selection processing in the page of the browser to be tested based on the element selectors in the selector sequence according to the sub-data until the target element or the parent element corresponding to the target element is selected.
[0108] Under this implementation, an execution priority can be set for the element selector, that is, a selector sequence is set. The process is as follows: traverse the selector sequence and call the element lookup API in the sequence order (the sequence order is the execution priority order). If the selector with a higher priority fails to find and the selector with a lower priority finds successfully, continue to execute, and the remaining process continues to use the alternative selector.
[0109] In addition, a mechanism for automatically adjusting the priority of the selector sequence can be added: after the above execution ends, adjust the selector sequence order (re-sort the selector sequence from high to low according to the success rate of finding). In addition, during the execution process, the number of successful lookups of element selectors will be collected and analyzed statistically for each page dimension, such as a total of Y element lookups are performed on the XX page, where the success rate of the css selector is A% and the success rate of the text selector is B%, etc. Then, when generating a new element selector sequence, a default sorting is performed on the sequence based on the latest statistical data.
[0110] Step 72: Perform page operations on the target element or the parent element corresponding to the target element, and obtain and record the results corresponding to the page operations performed on the target element or the parent element corresponding to the target element.
[0111] In this step, after determining the target element or the parent element corresponding to the target element, perform corresponding page operations on the target element or the parent element corresponding to the target element to obtain an execution result.
[0112] The test method for browser page functions provided by the embodiments of the present disclosure selects a target element or the parent element corresponding to the target element in the page of the browser to be tested according to sub-data based on at least one element selector, performs page operations on the target element or the parent element corresponding to the target element, and obtains and records the results corresponding to the page operations performed on the target element or the parent element corresponding to the target element. In this technical solution, the efficiency and accuracy of determining the target element or the parent element corresponding to the target element for performing page operations through at least one element selector are improved, thereby improving the quality and stability of the entire use case execution.
[0113] Based on the above embodiments, Figure 8 is a schematic flowchart of the test method for browser page functions provided by the embodiments of the present disclosure Figure 4 . As Figure 8 shown, the test method for browser page functions may include:
[0114] It should be understood that the steps involved in the playback process can be used during actual testing, and their implementation principles are similar.
[0115] Step 1: Start playback;
[0116] Step 2: Traverse the use case step list;
[0117] Among them, the use case step list records the sub-data corresponding to the multiple operation behaviors included in the above-mentioned automated test data, that is, each step represents each sub-data.
[0118] Step 3: Determine whether the playback step is less than the total step length? If so, execute Step 4; if not, execute Step 5;
[0119] Step 4: Determine whether the user confirms to proceed to the next step? If so, execute Step 6; if not, execute Step 11;
[0120] Step 5: Playback is successful, execute Step 11;
[0121] Step 6: Locate the target element in the current step;
[0122] Step 7: Determine whether the location is successful? If so, execute Step 8; if not, execute Step 10;
[0123] Step 8: Invoke the API to drive the page;
[0124] Step 9: Determine whether the operation is successful? If so, execute Step 3; if not, execute Step 10;
[0125] Step 10, playback fails;
[0126] Step 11, end playback.
[0127] The test method for browser page functions provided by the embodiments of the present disclosure has a similar implementation principle and technical solution to the above embodiments, which will not be elaborated here.
[0128] Based on the above method embodiments, Figure 9 FIG. is a schematic structural diagram of a test device for browser page functions provided by an embodiment of the present disclosure, as Figure 9 shown, the test device for browser page functions includes:
[0129] An acquisition unit 91, configured to acquire pre-determined automated test data in a visualization code editor, where the automated test data is generated based on general code corresponding to a use case preset in the visualization code editor, or generated based on atomic functions corresponding to test cases selected in the visualization code editor, or generated by recording the operation behavior of a user on a browser page;
[0130] A test unit 92, configured to use the automated test data to test the browser page function to be tested, and obtain a test result.
[0131] According to one or more embodiments of the present disclosure, the acquisition unit 91 is further configured to:
[0132] In response to an operation of writing operation behavior code in the general code corresponding to a use case in the visualization code editor, generate automated test data;
[0133] Or, in response to selecting an atomic function corresponding to a test case in the visualization code editor, generate automated test data based on the atomic function corresponding to the test case;
[0134] Or, in response to creating a recording use case in the visualization code editor and recording the operation behavior of a user on a corresponding browser page, generate automated test data.
[0135] According to one or more embodiments of the present disclosure, the acquisition unit 91 is further configured to: in response to a writing operation of a user, perform an editing operation on the automated test code corresponding to the automated test data in the visualization code editor, and generate new automated test data.
[0136] According to one or more embodiments of the present disclosure, the automated test data includes sub-data corresponding to multiple operation behaviors;
[0137] Correspondingly, the test unit 92 is specifically configured to:
[0138] For each sub-data, use the sub-data to perform page operations on the browser to be tested, and record the results corresponding to the page operations.
[0139] Among them, the test results include: the results corresponding to the page operations corresponding to all sub-data.
[0140] According to one or more embodiments of the present disclosure, the test unit 92 uses the sub-data to perform page operations on the browser to be tested and records the results corresponding to the page operations, specifically for:
[0141] Based on at least one element selector, select a target element or the parent element corresponding to the target element in the page of the browser to be tested according to the sub-data.
[0142] Perform a page operation on the target element or the parent element corresponding to the target element, and obtain and record the result corresponding to the page operation performed on the target element or the parent element corresponding to the target element.
[0143] According to one or more embodiments of the present disclosure, the test unit 92 selects a target element or the parent element corresponding to the target element in the page of the browser to be tested based on at least one element selector, specifically for:
[0144] Based on at least one element selector and a preset regular expression, select a target element or the parent element corresponding to the target element in the page of the browser to be tested.
[0145] According to one or more embodiments of the present disclosure, the preset selector sequence includes: at least one element selector arranged in order of priority;
[0146] The test unit 92 selects a target element or the parent element corresponding to the target element in the page of the browser to be tested based on at least one element selector, specifically for:
[0147] Successively based on the element selectors in the selector sequence, perform selection processing in the page of the browser to be tested according to the corresponding elements in the sub-data until the target element or the parent element corresponding to the target element is selected.
[0148] The test device for the browser page function provided by the embodiments of the present disclosure has technical solutions and technical effects similar to those in the above embodiments, and will not be elaborated here.
[0149] In order to implement the above embodiments, the embodiments of the present disclosure also provide an electronic device. Figure 10 For the structural schematic diagram of the electronic device provided by the embodiments of the present disclosure, refer to Figure 10 , this electronic device can be a terminal device.
[0150] Among them, the terminal device may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (PADs), portable media players (PMPs), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 10 The electronic device shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present disclosure.
[0151] As Figure 10 shown, the electronic device may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 101, which may perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 102 or the program loaded from the storage device 108 into the random access memory (RAM) 103. In the RAM 103, various programs and data required for the operation of the electronic device are also stored. The processing device 101, the ROM 102, and the RAM 103 are connected to each other through a bus 104. The input / output (I / O) interface 105 is also connected to the bus 104.
[0152] Generally, the following devices may be connected to the I / O interface 105: an input device 106 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 107 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 108 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 109. The communication device 109 may allow the electronic device to communicate with other devices wirelessly or wirelessly to exchange data. Although Figure 10 the electronic device with various devices is shown, it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices may be implemented or had.
[0153] In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, an embodiment of the present disclosure includes a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes program code for performing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 109, or installed from the storage device 108, or installed from the ROM 102. When the computer program is executed by the processing device 101, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0154] It should be noted that the above-mentioned computer-readable medium in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable signal medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0155] The above-mentioned computer-readable medium can be included in the above-mentioned electronic device; or it can exist separately and not be assembled into the electronic device.
[0156] The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by the electronic device, the electronic device is caused to execute the method shown in the above embodiment.
[0157] Computer program code for performing the operations of this disclosure may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also conventional procedural programming languages such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or it may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0158] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that, in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system that performs the specified functions or operations, or by a combination of dedicated hardware and computer instructions.
[0159] The units described in the embodiments of this disclosure may be implemented in software or in hardware. Among them, the name of the unit does not constitute a limitation to the unit itself in some cases. For example, the first acquisition unit may also be described as "the unit for acquiring at least two Internet protocol addresses".
[0160] The functions described above in this document may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), system on a chip (SOC), complex programmable logic devices (CPLD), and so on.
[0161] In the context of the present disclosure, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0162] In a first aspect, according to one or more embodiments of the present disclosure, there is provided a method for testing browser page functions, including:
[0163] Obtaining predetermined automated test data in a visualization code writer, where the automated test data is generated based on general code corresponding to a preset use case in the visualization code writer, or generated based on atomic functions corresponding to selected preset test cases in the visualization code writer, or generated by recording the operation behavior of a user on a browser page;
[0164] Using the automated test data to test the browser page function to be tested to obtain a test result.
[0165] According to one or more embodiments of the present disclosure, the method further includes:
[0166] In response to an operation of writing operation behavior code into the general code corresponding to the use case in the visualization code writer, generating the automated test data;
[0167] Or, in response to selecting the atomic function corresponding to the test case in the visualization code writer, generating the automated test data based on the atomic function corresponding to the test case;
[0168] Or, in response to creating a recording use case in the visualization code writer and recording the operation behavior of a user on a corresponding browser page, generating the automated test data.
[0169] According to one or more embodiments of the present disclosure, the method further includes:
[0170] In response to a user's writing operation, an editing operation is performed on the automated test code corresponding to the automated test data in the visualization code editor to generate new automated test data.
[0171] According to one or more embodiments of the present disclosure, the automated test data includes sub-data corresponding to multiple operation behaviors;
[0172] Correspondingly, using the automated test data to test the function of the browser page to be tested to obtain a test result includes:
[0173] For each sub-data, use the sub-data to perform a page operation on the browser to be tested, and record the result corresponding to the page operation;
[0174] Wherein, the test result includes: the results corresponding to the page operations corresponding to all sub-data.
[0175] According to one or more embodiments of the present disclosure, using the sub-data to perform a page operation on the browser to be tested and record the result corresponding to the page operation includes:
[0176] Based on at least one element selector, select a target element or a parent element corresponding to the target element in the page of the browser to be tested according to the sub-data;
[0177] Perform the page operation on the target element or the parent element corresponding to the target element, and obtain and record the result corresponding to performing the page operation on the target element or the parent element corresponding to the target element.
[0178] According to one or more embodiments of the present disclosure, based on at least one element selector, selecting a target element or a parent element corresponding to the target element in the page of the browser to be tested according to the sub-data includes:
[0179] Based on at least one element selector and a preset regular expression, select a target element or a parent element corresponding to the target element in the page of the browser to be tested.
[0180] According to one or more embodiments of the present disclosure, the preset selector sequence includes: at least one element selector arranged in a priority order;
[0181] Based on at least one element selector, selecting a target element or a parent element corresponding to the target element in the page of the browser to be tested according to the sub-data includes:
[0182] Select and process elements in the page of the browser to be tested based on the element selectors in the selector sequence in turn, according to the corresponding elements in the sub-data, until the target element or the parent element corresponding to the target element is selected.
[0183] In a second aspect, according to one or more embodiments of the present disclosure, there is provided a test device for browser page functions, including:
[0184] An acquisition unit, configured to acquire pre-determined automated test data in a visual code writer, where the automated test data is generated based on general code corresponding to a preset use case in the visual code writer, or generated based on atomic functions corresponding to selected preset test cases in the visual code writer, or generated by recording the operation behavior of a user on a browser page;
[0185] A test unit, configured to test the functions of the browser page to be tested by using the automated test data, and obtain a test result.
[0186] According to one or more embodiments of the present disclosure, the acquisition unit is further configured to:
[0187] In response to an operation of writing operation behavior code in the general code corresponding to the use case in the visual code writer, generate the automated test data;
[0188] Or, in response to selecting the atomic function corresponding to the test case in the visual code writer, generate the automated test data based on the atomic function corresponding to the test case;
[0189] Or, in response to creating a recording use case in the visual code writer and recording the operation behavior of a user on a corresponding browser page, generate the automated test data.
[0190] According to one or more embodiments of the present disclosure, the acquisition unit is further configured to: in response to a writing operation of a user, perform an editing operation on the automated test code corresponding to the automated test data in the visual code writer to generate new automated test data.
[0191] According to one or more embodiments of the present disclosure, the automated test data includes sub-data corresponding to multiple operation behaviors;
[0192] Correspondingly, the test unit is specifically configured to:
[0193] For each sub-data, perform page operations on the browser to be tested by using the sub-data, and record the results corresponding to the page operations;
[0194] Among them, the test results include: the results corresponding to the page operations corresponding to all sub-data.
[0195] According to one or more embodiments of the present disclosure, the test unit uses the sub-data to perform page operations on the browser to be tested and records the results corresponding to the page operations, specifically for:
[0196] Based on at least one element selector, select a target element or a parent element corresponding to the target element in the page of the browser to be tested according to the sub-data;
[0197] Perform the page operation on the target element or the parent element corresponding to the target element, and obtain and record the results corresponding to performing the page operation on the target element or the parent element corresponding to the target element.
[0198] According to one or more embodiments of the present disclosure, the test unit selects a target element or a parent element corresponding to the target element in the page of the browser to be tested based on at least one element selector according to the sub-data, specifically for:
[0199] Based on at least one element selector and a preset regular expression, select a target element or a parent element corresponding to the target element in the page of the browser to be tested.
[0200] According to one or more embodiments of the present disclosure, the preset selector sequence includes: at least one element selector arranged in order of priority;
[0201] The test unit selects a target element or a parent element corresponding to the target element in the page of the browser to be tested based on at least one element selector according to the sub-data, specifically for:
[0202] Successively based on the element selectors in the selector sequence, perform selection processing in the page of the browser to be tested according to the corresponding elements in the sub-data until the target element or the parent element corresponding to the target element is selected.
[0203] In a third aspect, according to one or more embodiments of the present disclosure, an electronic device is provided, including: at least one processor and a memory;
[0204] The memory stores computer execution instructions;
[0205] The at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the test method for the browser page function as described in the first aspect and various possible designs of the first aspect above.
[0206] Fourthly, according to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the test method for browser page functions as described in the first aspect above and various possible designs of the first aspect.
[0207] Fifthly, according to one or more embodiments of the present disclosure, there is provided a computer program product including a computer program, which, when executed by a processor, implements the test method for browser page functions as described in the first aspect above and various possible designs of the first aspect.
[0208] The above description is only a preferred embodiment of the present disclosure and an illustration of the applied technical principles. Those skilled in the art should understand that the scope of the disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) having similar functions disclosed in the present disclosure.
[0209] In addition, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although a number of specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments may also be implemented combinatorially in a single embodiment. Conversely, the various features described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0210] Although the subject matter has been described in language specific to structural features and / or methodological act logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A test method for browser page functions, characterized in that, Including: Obtaining predetermined automated test data in a visual code editor, where the automated test data is generated based on general code corresponding to a preset use case in the visual code editor, or generated based on atomic functions corresponding to preset test cases selected in the visual code editor, or generated by recording the operation behavior of a user on a browser page; Testing the function of the browser page to be tested with the automated test data to obtain a test result.
2. The method according to claim 1, characterized in that, The method further includes: In response to an operation of writing operation behavior code into the general code corresponding to the use case in the visual code editor, generating the automated test data; Or, in response to selecting the atomic function corresponding to the test case in the visual code editor, generating the automated test data based on the atomic function corresponding to the test case; Or, in response to creating a recording use case in the visual code editor and recording the operation behavior of a user on the corresponding browser page, generating the automated test data.
3. The method according to claim 1 or 2, characterized in that, The method further includes: In response to a writing operation of a user, performing an editing operation on the automated test code corresponding to the automated test data in the visual code editor to generate new automated test data.
4. The method according to claim 1 or 2, characterized in that, The automated test data includes sub-data corresponding to multiple operation behaviors respectively; Correspondingly, the testing the function of the browser page to be tested with the automated test data to obtain a test result includes: For each sub-data, performing a page operation on the browser to be tested with the sub-data and recording the result corresponding to the page operation; Wherein, the test result includes: the results corresponding to the page operations corresponding to all sub-data.
5. The method according to claim 4, characterized in that, The performing a page operation on the browser to be tested with the sub-data and recording the result corresponding to the page operation includes: Based on at least one element selector, selecting a target element or a parent element corresponding to the target element in the page of the browser to be tested according to the sub-data, where the behavior triggered by the target element is the same as the behavior triggered by the parent element corresponding to the target element; Performing the page operation on the target element or the parent element corresponding to the target element, and obtaining and recording the result corresponding to performing the page operation on the target element or the parent element corresponding to the target element.
6. The method according to claim 5, characterized in that, The selecting a target element or a parent element corresponding to the target element in the page of the browser to be tested according to the sub-data based on at least one element selector includes: Selecting a target element or a parent element corresponding to the target element in the page of the browser to be tested based on the at least one element selector and a preset regular expression.
7. The method according to claim 5 or 6, characterized in that, The preset selector sequence includes: at least one element selector arranged in order of priority; The selecting a target element or a parent element corresponding to the target element in the page of the browser to be tested according to the sub-data based on at least one element selector includes: Based on the element selectors in the selector sequence in turn, select and process in the page of the browser to be tested according to the corresponding elements in the sub-data until the target element or the parent element corresponding to the target element is selected.
8. A test device for browser page functions, characterized in that, The device includes: An acquisition unit, configured to acquire the automated test data predetermined in the visualization code writer, where the automated test data is generated based on the general code corresponding to the use cases preset in the visualization code writer, or is generated based on the atomic functions corresponding to the preset test cases selected in the visualization code writer, or is generated by recording the operation behaviors of the user on the browser page; A test unit, configured to test the functions of the browser page to be tested by using the automated test data to obtain a test result.
9. An electronic device, characterized in that, It includes: A processor and a memory communicatively connected to the processor; The memory stores computer execution instructions; The processor executes the computer execution instructions stored in the memory to implement the method according to any one of claims 1 to 7 above.
10. A computer-readable storage medium, characterized in that, Computer execution instructions are stored in the computer-readable storage medium, and when the computer execution instructions are executed by a processor, they are used to implement the method according to any one of claims 1 to 7 above.
11. A computer program product, including a computer program, characterized in that, When the computer program is executed by a processor, it implements the method according to any one of claims 1 to 7 above.