Web application automated testing method and computer device
By dynamically embedding preset embedded frameworks and automatic loading of preset test cases, the problems of incomplete test range, long cycle, and poor stability in the existing technology are solved, and efficient and simple automated web application testing is achieved, reducing the need for testing. personnel requirements.
Patent Information
- Application Number
- CN202410814022.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-06-24
AI Technical Summary
Existing web application automated testing technology has problems such as incomplete test coverage, long test cycle, difficult testing, poor test stability, high requirements on testers, and high maintenance costs.
Use the dynamically embedded preset embedded framework to obtain the preset browser through the ImGui application, add operation nodes, call preset test cases, obtain information to be tested, determine and load test cases, expand test coverage, and improve automation and efficiency.
It achieves comprehensive automated testing of front-end and back-end, reduces test complexity and maintenance costs, improves test accuracy and efficiency, and reduces requirements for testers.
Smart Images

Figure CN118377726B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of automated testing, and in particular to a web application automated testing method and a computer device. Background Art
[0002] At present, there are three main solutions in the field of web application automated testing. The first one is that developers write unit test codes for the codes of each module, and then run these unit tests before the project is tested. This method is not friendly to old projects. If there is no unit test before, it takes a lot of time to write a large number of unit tests. In addition, since the backend interfaces of some web applications need to be called by the frontend to be connected in series, it is more difficult to write unit test codes for the backend interfaces.
[0003] The second way is to use API tools such as Postman to perform functional testing on the backend. This test only targets the backend part and cannot cover the front-end page.
[0004] The third is Selenium, which uses WebDirver for automated testing. WebDriver needs to be used in conjunction with specific browsers and drivers. Different versions of browsers may require different versions of drivers, which increases the complexity and maintenance cost of testing, and may also cause test instability. In addition, Selenium has a steep learning curve, and you need to master a certain programming foundation and understanding of Web technology to effectively write and execute automated test scripts. Summary of the invention
[0005] In view of this, the embodiments of the present disclosure provide a web application automated testing method and a computer device, which can solve the problems existing in the prior art such as incomplete testing coverage, long testing cycle, testing difficulty, poor testing stability, high requirements for testers, and high maintenance costs.
[0006] In a first aspect, the present disclosure provides a method for automated testing of web applications, which adopts the following technical solutions:
[0007] Embed the preset embedded framework into the ImGui application to obtain the preset browser;
[0008] Adding an operation node matching the preset browser in a node editor to obtain a preset editor;
[0009] Call the preset test case according to the web page to be tested;
[0010] Acquiring information to be tested based on the web page to be tested;
[0011] Based on the information to be tested, obtaining test node information;
[0012] Determine whether the preset test case contains the test node information, and if so, load the preset test case in the preset browser and the preset editor to obtain the test information of the web page to be tested;
[0013] If not, obtain additional node information, add the additional node information to the preset editor, obtain the updated preset editor, load the preset test case in the preset browser and the updated preset editor, and obtain the test information of the web page to be tested.
[0014] Optionally, the preset embedded framework is a Chromium embedded framework;
[0015] The method for obtaining the preset browser includes: embedding the Chromium embedded framework into the ImGui application through off-screen rendering.
[0016] Optionally, the method for obtaining the preset test case includes:
[0017] Based on the recording unit of the preset browser, obtaining an operation event of the user on the preset browser;
[0018] Based on the operation event, obtain page element information;
[0019] Acquire initial node information based on the page element information;
[0020] Configuring the initial node information in the preset editor;
[0021] Based on the operation event, determine whether an auxiliary node needs to be configured, and if not, connect the input connection point and the output connection point of the initial node information to obtain a number of initial connections;
[0022] If so, obtain the type of the auxiliary node, add the auxiliary node in the preset editor based on the type, obtain update node information, connect the input connection point and the output connection point of the update node information, and obtain a number of update connections;
[0023] The preset test case is obtained based on the initial node information and a number of the initial connections, or the preset test case is obtained based on the updated node information and a number of the updated connections.
[0024] Optionally, the operation event includes any one of a mouse click event, a keyboard event, and a window zoom event;
[0025] The page element information includes display information, page text information, page style information, page button information and input box information.
[0026] Optionally, the obtaining the information to be tested based on the web page to be tested includes:
[0027] Open the web page to be tested in the preset browser to obtain the recorded content to be tested;
[0028] Based on the recorded content to be tested, the information to be tested is obtained.
[0029] Optionally, the method for loading the preset test case includes:
[0030] Use topological sorting to obtain the running order of the target nodes;
[0031] Based on the running order, the working function of each target node is executed in turn.
[0032] Optionally, the method further includes: the Chromium embedded framework shares the test information with the ImGui application in the form of a texture;
[0033] The ImGui application uses the texture to obtain a rendered image.
[0034] In a second aspect, the present disclosure also provides a web application automated testing system, which adopts the following technical solution:
[0035] An embedding module configured to embed a preset embedded framework into the ImGui application to obtain a preset browser;
[0036] An adding module is configured to add an operation node matching the preset browser in a node editor to obtain a preset editor;
[0037] A calling module is configured to call a preset test case according to the web page to be tested;
[0038] A first acquisition module is configured to acquire information to be tested based on the web page to be tested;
[0039] A second acquisition module is configured to acquire test node information based on the information to be tested;
[0040] A judgment module is configured to judge whether the preset test case contains the test node information, and if so, load the preset test case in the preset browser and the preset editor to obtain the test information of the web page to be tested;
[0041] If not, obtain additional node information, add the additional node information to the preset editor, obtain the updated preset editor, load the preset test case in the preset browser and the updated preset editor, and obtain the test information of the web page to be tested.
[0042] In a third aspect, the embodiments of the present disclosure further provide a computer device, which adopts the following technical solution:
[0043] The computer device comprises:
[0044] at least one processor; and,
[0045] a memory communicatively connected to the at least one processor; wherein,
[0046] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the above-mentioned web application automated testing methods.
[0047] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute any of the above-mentioned web application automated testing methods.
[0048] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, including a computer program / instruction, which implements the steps of any of the above methods when executed by a processor.
[0049] The web application automation testing method disclosed in the present application can cover the front-end and back-end, has a high degree of automation, is simple and efficient; specifically, by dynamically embedding a preset embedded framework, a standard test environment can be provided to ensure a consistent execution environment in different test scenarios, and to ensure that the test is accurate and controllable; by adding browser operation nodes, the execution environment of the test case can be clearly specified to ensure that the test case can be executed smoothly, and the obtained preset editor is more intuitive and flexible, and testers can more easily design complex test processes in the preset editor; automatically calling preset test cases can save testers the time of manually selecting test cases, and can improve the degree of automation and execution efficiency of the test; obtaining the information to be tested can help testers understand the status and characteristics of the application to be tested, and provide necessary context information for subsequent test operations ; By obtaining the test node information, the tester can accurately locate the key elements of the page to be tested, which is helpful for the subsequent test case design and execution; by judging whether the test case contains the test node information, it can effectively screen out whether the existing test cases are applicable to the current test scenario, saving unnecessary test case execution time; when the called preset test case contains the test node information, the test case can be directly loaded and the test information of the web page to be tested can be obtained, the existing test case can be directly executed, and the test results can be quickly obtained, which can improve the efficiency of the test; when the called preset test case does not contain all the test node information, the additional node information is obtained and added to the preset editor, which can flexibly expand the test coverage and increase the test depth of the application to be tested while keeping the test case structure clear.
[0050] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following preferred embodiments are specifically cited and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0052] Figure 1 A flowchart of a web application automation testing method provided by an embodiment of the present disclosure.
[0053] Figure 2 A flowchart of a method for obtaining preset test cases provided in an embodiment of the present disclosure.
[0054] Figure 3 A flowchart of a method for acquiring information to be tested provided in an embodiment of the present disclosure.
[0055] Figure 4 A flowchart of a method for loading preset test cases provided in an embodiment of the present disclosure.
[0056] Figure 5 This is a functional block diagram of a web application automated testing system provided by an embodiment of the present disclosure.
[0057] Figure 6 A schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0058] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0059] It should be clear that the following embodiments of the present disclosure are described by specific specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other in the absence of conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.
[0060] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.
[0061] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The drawings only show components related to the present disclosure rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0062] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.
[0063] Reference Figure 1 In the first aspect, the present application discloses a method for automated testing of web applications, which specifically includes the following schemes:
[0064] S100, embed the preset embedded framework into the ImGui application to obtain the preset browser.
[0065] In this embodiment, the preset embedded framework is the Chromium Embedded Framework (ie, CEF).
[0066] Optionally, the method for obtaining the preset browser includes: embedding the Chromium embedded framework into the ImGui application through off-screen rendering.
[0067] This step allows the dynamic embedding of ImGui applications, which enables GUI applications to fully control all stages of web page loading and running through CEF, making it easy to add callback functions for various stages of page rendering.
[0068] S200, adding an operation node matching the preset browser to a node editor to obtain a preset editor.
[0069] In this step, by adding matching operation nodes in the node editor, you can ensure that it matches the actual browser environment, thereby improving the accuracy and reliability of the test; by adding operation nodes, testers do not need to write nodes from scratch, saving time and energy in editing test cases.
[0070] S300: Call a preset test case according to the web page to be tested.
[0071] Specifically, there are multiple preset test cases, which can be stored in a database; when a test task comes, the preset test case matching the web page to be tested can be called from the database.
[0072] In this step, by calling the preset test cases, a series of designed test steps can be automatically executed to cover various preset test scenarios and functional points, which can ensure wide test coverage and improve the comprehensive verification of the functions of the page to be tested; the preset test cases have been designed and verified, so they can be called directly for execution, saving the time and effort of manually writing test scripts. The automation of test execution can greatly speed up the test and improve the efficiency and timeliness of the test.
[0073] Manually written test scripts are prone to omissions or errors, but calling preset test cases can reduce this risk because the preset test cases have been verified and optimized, reducing the impact of human factors on test results. The automated execution of preset test cases is conducive to the implementation of continuous integration and continuous delivery processes. After each code submission or deployment, the automatic execution of preset test cases can promptly identify potential problems and ensure the quality and stability of software delivery. At the same time, the automated execution of preset test cases ensures the repeatability and consistency of the testing process, and will not cause inconsistent test results due to human factors, thereby improving the credibility and effectiveness of the test.
[0074] S400: Acquire information to be tested based on the web page to be tested.
[0075] In this step, by obtaining the information of the web page to be tested, we can fully understand the various components, functions and interaction methods of the page, so as to design test cases and test strategies in a targeted manner and improve the comprehensiveness and accuracy of the test; by obtaining the information to be tested, testers can select the test focus in a targeted manner and avoid unnecessary tests, thereby improving the test efficiency. At the same time, the test case design can be optimized according to the characteristics of the page, saving test resources and time costs.
[0076] S500: Acquire test node information based on the information to be tested.
[0077] Acquiring the test node information based on the information to be tested can avoid unnecessary testing and waste of resources, accurately locate the test nodes, avoid testing irrelevant nodes, and save test resources and time costs.
[0078] S600, determining whether the preset test case contains test node information, and if so, loading the preset test case in a preset browser or preset editor to obtain test information of the web page to be tested;
[0079] If not, obtain additional node information, add the additional node information to the preset editor, obtain an updated preset editor, load the preset test case in the preset browser and the updated preset editor, and obtain test information of the web page to be tested.
[0080] If the preset test case already contains the node information for testing, then loading the corresponding test case into the preset editor can directly obtain the test information of the web page to be tested without additional steps, which can ensure the accuracy and comprehensiveness of the test because the test case already contains targeted node information; directly loading the preset test case containing the node information for testing can save the tester's time and energy, and there is no need to obtain and add node information additionally, and the test execution can be more efficient and faster; using the node information in the preset test case can reduce the risk of manually adding node information. The preset test case has been verified and optimized, and the node information contained in it is more reliable, which can reduce errors and inconsistencies in the testing process.
[0081] It should be noted that what is judged in this step is whether the called preset test case contains all the test node information.
[0082] The web application automated testing method disclosed in the present application can provide a standard testing environment by dynamically embedding a preset embedded framework, ensuring a consistent execution environment in different test scenarios, and ensuring that the test is accurate and controllable; by adding browser operation nodes, the execution environment of the test case can be clearly specified to ensure that the test case can be executed smoothly, and the obtained preset editor is more intuitive and flexible, and the tester can more easily design complex test processes in the preset editor; automatically calling preset test cases can save the tester's time in manually selecting test cases, and can improve the automation level and execution efficiency of the test; obtaining the information to be tested can help the tester understand the status and characteristics of the application to be tested, and provide necessary context information for subsequent test operations; by obtaining the test node information, Testers can accurately locate the key elements of the page to be tested, which is helpful for the subsequent test case design and execution; by judging whether the test case contains test node information, they can effectively screen out whether the existing test cases are applicable to the current test scenario, saving unnecessary test case execution time; when the called preset test case contains test node information, the test case can be directly loaded and the test information of the web page to be tested can be obtained, and the existing test case can be directly executed to quickly obtain test results, which can improve the efficiency of the test; when the called preset test case does not contain all the test node information, additional node information can be obtained and added to the preset editor, which can flexibly expand the test coverage and increase the test depth of the application to be tested while keeping the test case structure clear.
[0083] The web application automated testing method disclosed in the present application can realize automated testing of web applications, effectively reduce manual operation time and the possibility of errors, and at the same time can more comprehensively cover various functions and scenarios of the application to be tested, thereby improving the comprehensiveness and depth of the test; through the design of preset browsers and preset editors and the automated loading of preset test cases, it can cover the front end and the back end, greatly reducing the requirements of automated testing on testers.
[0084] Reference Figure 2 , the method for obtaining the preset test cases specifically includes the following schemes:
[0085] A100, based on the recording unit of the preset browser, obtains the operation events of the user on the preset browser.
[0086] Specifically, the operation event includes any one of a mouse click event, a keyboard event, and a window zoom event.
[0087] In this step, by recording the user's operation events on the preset browser, the user's interaction behavior with the application to be tested can be quickly and accurately captured as the basis of the test case, reducing the workload of manually writing test cases.
[0088] A200, based on operation events, obtains page element information.
[0089] Specifically, the page element information includes display information, page text information, page style information, page button information and input box information.
[0090] Obtaining page element information helps to accurately locate the various functional modules and interactive elements of the application under test, providing the necessary materials and context for subsequent test case design.
[0091] A300, obtaining initial node information based on page element information.
[0092] The initial node information is the basis of the test case. It describes the initial state and basic operation flow of the application to be tested, and provides a basis for the subsequent test case design and execution.
[0093] A400, configure the initial node information in the preset editor.
[0094] Configuring initial node information in the preset editor helps to uniformly manage and organize test cases, making the writing and maintenance of test cases more convenient and efficient.
[0095] A500, based on the operation event, determines whether an auxiliary node needs to be configured, and if not, connects the input connection point and the output connection point of the initial node information to obtain a number of initial connections;
[0096] If so, obtain the type of the auxiliary node, add the auxiliary node in the preset editor based on the type, obtain the update node information, connect the input connection point and the output connection point of the update node information, and obtain a number of update lines.
[0097] According to the characteristics and needs of the operation events, it is flexibly determined whether auxiliary nodes need to be configured, which can make the test cases more suitable for the actual test scenarios and improve the effectiveness and coverage of the test cases.
[0098] A600, obtaining a preset test case based on initial node information and a number of initial connections, or obtaining a preset test case based on updated node information and a number of updated connections.
[0099] In this embodiment, through automatic recording of user operation events and intelligent judgment based on page element information, most test cases can be automatically generated, reducing the time and workload of manually writing test cases; through flexible configuration of initial node information and auxiliary node information, test cases are more in line with actual test scenarios, covering more test paths and interaction scenarios, and improving the comprehensiveness and effectiveness of test cases; by managing and organizing test cases in a preset editor, the maintenance and expansion of test cases are more convenient and efficient, reducing the maintenance cost of test cases.
[0100] Furthermore, in obtaining the preset test cases, node assertion testing can be used to detect whether the communication between nodes is carried out as expected and to ensure that the nodes can correctly process and respond after receiving the message.
[0101] Reference Figure 3 , the method for obtaining the information to be tested specifically includes the following schemes:
[0102] S410, opening the web page to be tested in a preset browser, and obtaining the recorded content to be tested.
[0103] By opening the web page to be tested in the preset browser, the consistency and stability of the test environment can be ensured, avoiding differences in test results caused by different browsers or environments. At the same time, obtaining the recorded content to be tested can record the user's various operations on the page to be tested, providing an important data basis for the subsequent test case design and execution.
[0104] S420: Acquire information to be tested based on the recorded content to be tested.
[0105] By analyzing the recorded content to be tested, the user's various operations and interactive behaviors on the page to be tested can be accurately captured, and then the key information to be tested, such as page element status, user input, etc., can be extracted, providing the necessary context and data support for the subsequent call of test cases, which makes it easy to quickly call the preset test cases that match the web page to be tested.
[0106] In this embodiment, by opening the web page to be tested in a preset browser and recording the content, the layout, function and interaction information of the page to be tested can be accurately captured, which helps the tester to fully understand the characteristics of the page to be tested and provide an accurate reference for subsequent testing work; obtaining the information to be tested based on the recorded content can be completed more quickly, the recording process can be completed in a shorter time, and various interactive actions and changes on the page can be captured without manually recording them one by one, saving the tester's time and energy costs; recording the content to be tested can ensure the integrity of the information. During the recording process, various page states and interaction scenarios can be covered as much as possible, ensuring that the acquired test information is comprehensive enough, which is helpful for subsequent test analysis and design.
[0107] In addition, the recorded content can be used as a test benchmark to facilitate tracking of test changes. When the page structure or function changes, the content to be tested can be re-recorded and compared with the previous recording to quickly identify the change points and update the test strategy and use cases in a targeted manner.
[0108] Furthermore, for obtaining the information to be tested, the URL of the web page to be tested may be directly obtained, and then the corresponding preset test case may be called according to the URL.
[0109] Reference Figure 4 , the loading methods of preset test cases include:
[0110] B100, uses topological sorting to obtain the running order of the target nodes.
[0111] The target nodes include all nodes related to the web page to be tested.
[0112] Using topological sorting can ensure that the execution order of each node in the test case is correct, avoiding execution errors or exceptions caused by the dependencies between nodes. Topological sorting can sort the nodes according to their dependencies, thereby ensuring the accuracy and rationality of the execution order of the test case.
[0113] B200, based on the running order, executes the work function of each target node in turn.
[0114] Executing the work function of each node in the order in which the nodes are run can ensure that the execution of the test case is orderly and standardized. The work function of each node is designed for a specific test operation or scenario, and executing these operations in a predetermined order can ensure the integrity and accuracy of the test case.
[0115] In this embodiment, topological sorting is used to ensure that the nodes in the test case are correctly executed according to their dependencies, and errors caused by confusion in the execution order due to the dependencies between nodes can be avoided, thereby ensuring the accuracy and reliability of the test; topological sorting can effectively reduce the number of node executions and improve execution efficiency. By determining the execution order of the nodes in advance, it can avoid repeated execution of the same node or execution of unnecessary nodes, thereby saving execution time and resources.
[0116] Topological sorting can reduce the occurrence of human errors. Since the execution order of nodes is determined according to their dependencies rather than arbitrary human arrangements, the error rate caused by improper execution order can be reduced. Using topological sorting to determine the execution order of nodes can enhance the maintainability of test cases. When a test case needs to be modified or updated, only the dependencies between nodes need to be updated without readjusting the execution order, which simplifies the maintenance of test cases. Topological sorting can discover the possibility of parallel execution, thereby improving the concurrent execution capability of test cases. After determining the dependencies of nodes, independent nodes can be combined into parallel execution tasks, further improving the efficiency of testing.
[0117] Therefore, using topological sorting to obtain the running order of nodes and executing the working function of each node in sequence based on the running order can ensure the correct execution order, improve execution efficiency, reduce error rate, enhance maintainability, and support parallel execution, thereby improving the efficiency and quality of test case loading.
[0118] Furthermore, the web application automated testing method disclosed in the present application also includes: the Chromium embedded framework shares the test information with the ImGui application in the form of a texture;
[0119] The ImGui application uses textures to obtain rendered images.
[0120] By sharing the test information in the form of textures to the ImGui application through the Chromium embedded framework, real-time visualization of the test process and results can be achieved. The ImGui application can instantly obtain and display rendered images, allowing testers to observe the page rendering effect in a timely manner, making it easier to find problems and adjust test strategies in a timely manner.
[0121] Sharing test information in the form of textures can simplify the process of acquiring test information. The ImGui application can directly obtain rendered images from textures without the need for complex data transmission or processing, which improves the efficiency and convenience of acquiring test information.
[0122] By sharing the test information in the form of textures, resource consumption can be reduced. Compared with other transmission methods, such as transmitting over the network or saving on disk, using texture sharing can reduce the overhead of data transmission and storage, saving system resources.
[0123] The combination of Chromium embedded framework and ImGui application improves the scalability of the test. The ImGui application can be easily expanded and customized according to specific needs to achieve more diverse test information display and analysis functions to meet the test needs in different scenarios.
[0124] By sharing the test information in the form of textures, certain security measures can be taken during the transmission and processing process, which enhances the security of the test data. Data transmission can be encrypted to ensure that the test information is not obtained by unauthorized visitors, protecting the integrity and confidentiality of the test data.
[0125] The web application automation testing method disclosed in this application is relatively close to the usage of Selenium, but the implementation method is different from Selenium. The difference is that CEF is introduced in the form of a dynamic library. CEF is an open source Web browser control based on the Google Chromium project, which is equivalent to directly integrating a Chromium browser into a GUI application. This allows the GUI application to completely control the various stages of web page loading and operation through CEF, and facilitates the addition of callback functions for various periods of page rendering. Because CEF only cuts off the GUI part of Chromium, the rendering result of the CSS of the page and the execution result of javascript are consistent with Chromium. In addition, the window event system is also completely sent to CEF by the GUI application, which is itself a complete control of the forwarding of window events. Selenium uses WebDriver, which is a branch of ChromeDriver. It needs to install a driver to achieve the purpose of communicating with the browser. In terms of controlling the browser and controlling events, it is completely determined by ChromeDriver. It can only communicate with it by calling its API. Although it is open source, secondary development is difficult.
[0126] Furthermore, from the user's perspective, a set of recording and playback operation instances of logging in and out are explained by taking clicking a button on a page as an example.
[0127] When a user opens a web page, the page is given to the user in the form of a picture. The user clicks a "button" on the picture (the button on the page), and then sends the mouse click event (including coordinate position, number of clicks, etc.) to CEF. After receiving the event, CEF operates the web page. Off-screen rendering is used here, the texture corresponding to the web page is updated, and the picture seen by the user is updated.
[0128] In this process, we can find that the collection of mouse and keyboard events and the process of forwarding them to CEF is equivalent to adding an intermediate layer between user operations and the "browser" (CEF). Using this intermediate layer, it is easy to record and playback user operations on web pages.
[0129] Of course, having the recording and playback functions is not enough for automated testing. Automated testing is mainly to verify the correctness of data. Recording and playback are just a set of operations, and they do not provide timely feedback when errors occur. Therefore, necessary verification operations need to be added here. You can set the "protected days" to verify by judging whether the value is correct.
[0130] In this solution, the verification operation is provided to users in the form of NodeEditor nodes (which are easy to use for users without programming knowledge). At the same time, in order to facilitate users to write test cases, mouse, keyboard events, browser operations, etc. are also integrated into NodeEditor.
[0131] This allows users to add nodes to perform test steps. This is another core function of the application.
[0132] At this time, users can use these nodes to easily complete some simple test cases.
[0133] The following is a login process: Convert the recorded events into a set of nodes, such as GLFW's mouse click event (MouseButton), into a mouse click node. Convert a set of GLFW keyboard char input events (such as pressing admin on the keyboard, GLFW will receive the pressing and releasing of the a key, the pressing and releasing of the d key, etc.) into an Input node.
[0134] This is different from Selenium. The operations recorded by Selenium can be exported to Java, Python, Ruby, and C# code, and then WebDriver can be controlled through code. The test process cannot be controlled in a node manner.
[0135] Users can also quickly add verification nodes during recording by hovering over the element to be tested and clicking the shortcut key to pop up the verifier and quickly add verification steps. The verification steps will be output as nodes of NodeEditor together with mouse click events during the conversion phase of the recording operation.
[0136] At this time, the specific use of the application is: when the user needs to write a test case for a page, first turn on the page recording, then click and input the regular test process, and if it is found that the data on some pages needs to be verified, press the "Add Verification Node" shortcut key to add verification rules for the page elements. After the test process is completed, turn off the recording.
[0137] Then convert the recorded events and added checks into NodeEditor nodes. After adjusting the generated nodes, a test case is completed. After saving the test case, you can repeat the test, and through the binding of Dom (the node uses the clicked coordinates to parse the XPATH of the element, and in fact the node is bound to the XPATH of dom, not the coordinates), the test case is not limited by the size of the browser window. At this time, for the test of different installation packages, you only need to click Start, the node will run automatically, and the check type node will find problems during the test and will promptly feedback to notify the tester.
[0138] Furthermore, NodeEditor node expansion includes: 1) Node monitoring and control of browsers: You can use the callback function when CEF renders the page to add dedicated nodes, such as controlling the browser's native alert. In addition, the mutual call between CEF and javascript can monitor the non-native alert of the page without modifying the front-end code (using MutationObserver to monitor the DOM changes corresponding to the alert).
[0139] 2) Monitoring and control of components by nodes: The verification value of the page data in the test case can be obtained directly by querying the database.
[0140] This solution can be applied to projects that mainly use manual click testing. After transferring the test cases to the node, a lot of time and manpower can be saved in the subsequent testing process. For example, if a project adds a lot of new features, testers are required to conduct full testing and adapt to 4 databases. At this time, if it takes m testers n hours to manually test all the functions of the page, the test time is 4*m*n. If this solution is used, after adjusting the NodeEditor nodes according to the changes in the project, the remaining test time can be infinitely reduced because the solution can perform parallel testing by deploying multiple instances.
[0141] In addition, compared with Selenium, this solution has lower requirements for testers. Testers only need to create different types of nodes and then complete a test case through simple connections. There is no need to install a large number of dependencies like Selenium to work.
[0142] Reference Figure 5 The second aspect of the present application provides a web application automated testing system, which adopts the following technical solutions:
[0143] An embedding module configured to embed a preset embedded framework into the ImGui application to obtain a preset browser;
[0144] Add a module, configure the node editor to add an operation node that matches the preset browser, and get the preset editor;
[0145] A calling module is configured to call a preset test case according to the web page to be tested;
[0146] A first acquisition module is configured to acquire information to be tested based on a web page to be tested;
[0147] A second acquisition module is configured to acquire test node information based on the information to be tested;
[0148] A judgment module is configured to judge whether the preset test case contains the test node information, and if so, load the preset test case in the preset browser and the preset editor to obtain the test information of the web page to be tested;
[0149] If not, obtain additional node information, add the additional node information to the preset editor, obtain an updated preset editor, load the preset test case in the preset browser and the updated preset editor, and obtain test information of the web page to be tested.
[0150] The computer device according to the embodiment of the present disclosure includes a memory and a processor. The memory is used to store non-temporary computer-readable instructions. Specifically, the memory may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may include, for example, a read-only memory (ROM), a hard disk, a flash memory, etc.
[0151] The processor may be a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities, and may control other components in the computer device to perform desired functions. In one embodiment of the present disclosure, the processor is used to run the computer-readable instructions stored in the memory, so that the computer device performs all or part of the steps of the web application automated testing method of each embodiment of the present disclosure.
[0152] Those skilled in the art should be able to understand that in order to solve the technical problem of how to obtain a good user experience, the present embodiment may also include well-known structures such as a communication bus and an interface, and these well-known structures should also be included in the protection scope of the present disclosure.
[0153] like Figure 6 A schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure is shown, which is a schematic diagram of the structure of a computer device suitable for implementing the embodiment of the present disclosure. Figure 6 The computer device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0154] like Figure 6 As shown, the computer device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) or a program loaded from a storage device into a random access memory (RAM). In the RAM, various programs and data required for the operation of the computer device are also stored. The processor, ROM, and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.
[0155] Typically, the following devices can be connected to the I / O interface: input devices such as sensors or visual information acquisition devices; output devices such as display screens; storage devices such as tapes, hard disks, etc.; and communication devices. The communication device can allow the computer device to communicate with other devices (such as edge computing devices) wirelessly or by wire to exchange data. Figure 6 A computer device having various devices is shown, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0156] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processor, all or part of the steps of the web application automation testing method of the embodiment of the present disclosure are executed.
[0157] For detailed description of this embodiment, reference may be made to the corresponding descriptions in the aforementioned embodiments, which will not be repeated here.
[0158] According to the computer-readable storage medium of the embodiment of the present disclosure, non-transitory computer-readable instructions are stored thereon. When the non-transitory computer-readable instructions are executed by a processor, all or part of the steps of the web application automated testing method of each embodiment of the present disclosure are executed.
[0159] The above-mentioned computer-readable storage media include, but are not limited to: optical storage media (e.g., CD-ROM and DVD), magneto-optical storage media (e.g., MO), magnetic storage media (e.g., magnetic tape or mobile hard disk), media with built-in rewritable non-volatile memory (e.g., memory card) and media with built-in ROM (e.g., ROM box).
[0160] For detailed description of this embodiment, reference may be made to the corresponding descriptions in the aforementioned embodiments, which will not be repeated here.
[0161] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.
[0162] In the present disclosure, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. The block diagrams of the devices, devices, equipment, and systems involved in the present disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagram. As will be appreciated by those skilled in the art, these devices, devices, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The words "such as" used here refer to the phrase "such as but not limited to", and can be used interchangeably with them.
[0163] Additionally, as used herein, "or" used in a list of items beginning with "at least one" indicates a separate list, so that, for example, a list of "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not mean that the example described is preferred or better than other examples.
[0164] It should also be noted that in the system and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.
[0165] Various changes, substitutions, and modifications of the technology herein may be made without departing from the technology of the teachings defined by the appended claims. Furthermore, the scope of the claims of the present disclosure is not limited to the specific aspects of the above processes, machines, manufactures, compositions of events, means, methods, and actions. Currently existing or later to be developed processes, machines, manufactures, compositions of events, means, methods, or actions that perform substantially the same functions or achieve substantially the same results as the corresponding aspects herein may be utilized. Thus, the appended claims include such processes, machines, manufactures, compositions of events, means, methods, or actions within their scope.
[0166] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0167] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A web application automated testing method, characterized in that: include: Embed the preset embedded framework into the ImGui application to obtain the preset browser; Adding an operation node matching the preset browser in a node editor to obtain a preset editor; Call the preset test case according to the web page to be tested; Acquiring information to be tested based on the web page to be tested; Based on the information to be tested, obtaining test node information; Determine whether the preset test case contains the test node information, and if so, load the preset test case in the preset browser and the preset editor to obtain the test information of the web page to be tested; If not, obtain additional node information, add the additional node information to the preset editor, obtain the updated preset editor, load the preset test case in the preset browser and the updated preset editor, and obtain test information of the web page to be tested; The preset embedded framework is the Chromium embedded framework; The method for obtaining the preset browser includes: embedding the Chromium embedded framework into the ImGui application by off-screen rendering; The method for loading the preset test case includes: obtaining the running order of the target nodes by topological sorting; and executing the working function of each target node in sequence based on the running order.
2. The web application automated testing method according to claim 1, characterized in that: The method for obtaining the preset test case includes: Obtaining an operation event of a user on the preset browser; Based on the operation event, obtain page element information; Acquire initial node information based on the page element information; Configuring the initial node information in the preset editor; Based on the operation event, determine whether an auxiliary node needs to be configured, and if not, connect the input connection point and the output connection point of the initial node information to obtain a number of initial connections; If so, obtain the type of the auxiliary node, add the auxiliary node in the preset editor based on the type, obtain update node information, connect the input connection point and the output connection point of the update node information, and obtain a number of update connections; The preset test case is obtained based on the initial node information and a plurality of the initial connections, or the preset test case is obtained based on the updated node information and a plurality of the updated connections.
3. The web application automated testing method according to claim 2, characterized in that: The operation event includes any one of a mouse click event, a keyboard event, and a window zoom event; The page element information includes display information, page text information, page style information, page button information and input box information.
4. The web application automated testing method according to claim 3, characterized in that: The obtaining the information to be tested based on the web page to be tested includes: Open the web page to be tested in the preset browser to obtain the recorded content to be tested; Based on the recorded content to be tested, the information to be tested is obtained.
5. The web application automated testing method according to any one of claims 1 to 4, characterized in that: The method further includes: the Chromium embedded framework shares the test information with the ImGui application in the form of a texture; The ImGui application uses the texture to obtain a rendered image.
6. A computer device, characterized in that: The computer device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the web application automated testing method according to claim 5.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the web application automated testing method according to claim 5.
8. A computer program product comprising computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method according to claim 5 are implemented.
