A web page program testing method, device and equipment and a storage medium

By using multiple webpage driver objects to simultaneously open browser pages and independently manage test results in webpage application testing, the problems of low efficiency and poor robustness of multi-role testing are solved, achieving efficient and independent multi-role testing.

CN114817059BActive Publication Date: 2025-10-21WINNING HEALTH TECHNOLOGY GROUP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210523320.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-13
Publication Date
2025-10-21
Estimated Expiration
2042-05-13

AI Technical Summary

Technical Problem

In web application testing, multi-role testing results in waste of resources, high cost, low testing efficiency, poor robustness of test scripts, and difficulty in reusing test scripts for multi-role scenarios.

Method used

By obtaining test scripts corresponding to multiple roles, using multiple pre-built web page driver objects, opening multiple browser pages simultaneously, and executing the test scripts in each browser page, we can ensure that role operations and testing do not affect each other. We also use different debugging ports and storage addresses to manage test results independently.

Benefits of technology

It improves the efficiency of multi-role testing, enhances the robustness of test scripts, improves the reusability of test scripts, reduces frequent role switching operations, and ensures that each role operates independently without affecting other roles.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114817059B_ABST
    Figure CN114817059B_ABST
Patent Text Reader

Abstract

The application provides a webpage program testing method and device, equipment and storage medium, and designs an automatic testing field. A plurality of roles corresponding test scripts are acquired, wherein the plurality of roles corresponding test scripts are test scripts corresponding to business operations of a plurality of roles in a preset webpage program, a plurality of webpage driving objects are simultaneously started by a plurality of browser pages, and the plurality of roles corresponding test scripts are respectively executed in the plurality of browser pages to obtain a plurality of roles corresponding test results. The method does not need to frequently switch between different roles and systems in the test of a plurality of role business scenarios, can effectively improve the test efficiency, will not affect other roles if a certain role process execution is wrong, can improve the robustness of the test script, and can reuse the test script corresponding to a certain role if the business operation of the certain role is in a plurality of business scenarios, thereby improving the reusability of the test script.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automated testing technology, and in particular to a web page program testing method, apparatus, device, and storage medium. Background Art

[0002] During web application testing, you can use the test script to open the browser and simulate operations such as clicking and dragging web elements to implement browser-based web application testing.

[0003] In web-based multi-role testing, when multi-role testing is completed on multiple servers, resources are wasted significantly and costs are high. When multi-role testing is completed on a single server, it is necessary to frequently switch between different roles. Each time a switch is made, the current role must be exited before entering the next role for testing. When testing a multi-role scenario, there is at least one role that needs to be tested at multiple different times, resulting in multiple switching between roles, and each time a large number of repetitive and redundant test operations need to be performed, resulting in low test efficiency. At the same time, if an error occurs in one of the steps of the test script during the test, the test of the multi-role scenario needs to be restarted, resulting in poor robustness of the test script and difficulty in reusing the test script for the multi-role scenario. Summary of the Invention

[0004] The purpose of the present invention is to provide a web program testing method, device, equipment and storage medium to address the deficiencies of the above-mentioned prior art, so as to solve the technical problems of low testing efficiency and poor robustness of test scripts in the prior art of web program testing for multiple roles.

[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of the present application are as follows:

[0006] In a first aspect, an embodiment of the present application provides a webpage program testing method, the method comprising:

[0007] Acquire test scripts corresponding to multiple roles, wherein the test scripts corresponding to the multiple roles are test scripts corresponding to business operations of the multiple roles in a preset webpage program;

[0008] Multiple browser pages are opened simultaneously by multiple pre-built web page driving objects, and test scripts corresponding to the multiple roles are respectively executed in the multiple browser pages to obtain test results corresponding to the multiple roles.

[0009] Optionally, the plurality of pre-built web page driving objects are used to simultaneously open a plurality of browser pages, including:

[0010] The multiple web page drive objects respectively use multiple debugging ports to open the multiple browser pages at the same time.

[0011] Optionally, the plurality of web page driven objects respectively using a plurality of debugging ports and simultaneously opening the plurality of browser pages include:

[0012] The multiple web page drive objects respectively use the multiple debugging ports to simultaneously open multiple pages of the same preset browser as the multiple browser pages; the multiple debugging ports are multiple debugging ports of the same preset browser.

[0013] Optionally, the plurality of web page driven objects respectively using a plurality of debugging ports and simultaneously opening the plurality of browser pages include:

[0014] The multiple web page drive objects respectively use the multiple debugging ports to simultaneously open multiple browser pages as the multiple browser pages; the multiple browsers are multiple different browsers with the same kernel, and the multiple debugging ports are the debugging ports of the multiple browsers.

[0015] Optionally, before the multiple webpage-driven objects respectively use multiple debugging ports and simultaneously open the multiple browser pages, the method further includes:

[0016] The plurality of web page driven objects are constructed according to the inputted plurality of object creation scripts, wherein each object creation script includes: a debugging port.

[0017] Optionally, the method further includes: storing the user data and cache data in the test result corresponding to each role in a first preset address and a second preset address specified by the web page driver object corresponding to each role, respectively.

[0018] Optionally, before simultaneously opening multiple browser pages using the pre-built multiple webpage-driven objects, the method further includes:

[0019] The plurality of web page driven objects are constructed according to the inputted plurality of object creation scripts, wherein each object creation script includes: a first preset address and a second preset address.

[0020] In a second aspect, an embodiment of the present application provides a webpage program testing device, comprising:

[0021] An acquisition module, configured to acquire test scripts corresponding to a plurality of roles, wherein the test scripts corresponding to the plurality of roles are test scripts corresponding to business operations of the plurality of roles in a preset webpage program;

[0022] The execution module is used to drive objects by multiple pre-built web pages, open multiple browser pages at the same time, and execute test scripts corresponding to the multiple roles in the multiple browser pages respectively to obtain test results corresponding to the multiple roles.

[0023] In a third aspect, an embodiment of the present application provides a computer device comprising: a storage medium and a processor, wherein the storage medium stores a computer program executable by the processor, and when the processor executes the computer program, a web page program testing method according to the first aspect is implemented.

[0024] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is read and executed, a web page program testing method according to the first aspect is implemented.

[0025] Compared with the prior art, this application has the following beneficial effects:

[0026] The embodiments of the present application provide a web program testing method, apparatus, device and storage medium. By obtaining test scripts corresponding to multiple roles, the test scripts corresponding to the multiple roles are test scripts corresponding to the business operations of the multiple roles in the preset web program. Multiple pre-built web page driver objects are used to open multiple browser pages at the same time, and the test scripts corresponding to the multiple roles are respectively executed in the multiple browser pages to obtain test results corresponding to the multiple roles, so that the operations and tests between the multiple roles do not affect each other. There is no need to frequently switch between different roles and systems in the testing of multiple role business scenarios, which can effectively improve the testing efficiency. At the same time, each role operates and tests independently in the corresponding browser. If there is an error in the execution of a role process, it will not affect other roles, so that the robustness of the test script is improved. Moreover, if the business operation of a role is in multiple business scenarios, the test script corresponding to the role can be reused when testing the role in multiple business scenarios, thereby improving the reusability of the test script. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.

[0028] Figure 1 A flowchart of a web page program testing method provided in an embodiment of the present application;

[0029] Figure 2A flowchart of a method for opening multiple browser pages provided in an embodiment of the present application;

[0030] Figure 3 A flowchart of another web application testing method provided in an embodiment of the present application;

[0031] Figure 4 A flowchart of another web application testing method provided in an embodiment of the present application;

[0032] Figure 5 A schematic diagram of a web page program testing device provided in an embodiment of the present application;

[0033] Figure 6 A schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.

[0035] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for protection, but merely represents selected embodiments of the present application. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0036] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.

[0037] In the multi-role business scenario of medical informationization, each role requires a corresponding information system and permissions, and each role has a unique account and password in the corresponding information system. Because multiple roles in this business scenario need to perform operations, and each role may need to perform multiple operations, when testing multi-role business scenarios of medical informationization, it is necessary to frequently switch between different roles. Each switch requires logging out of the current role's account and logging into the new system with the account of the other role, which is a cumbersome process.

[0038] For example, the multiple-role business scenario of medical informationization can be: the patient registers for hospitalization, the nurse arranges hospitalization for the patient, the doctor prescribes medicine for the patient, and the patient takes the medicine. In this business scenario, there are six steps. The first step is that the hospital staff of the inpatient department registers the patient in the Hospital Information System (HIS). The hospital staff of the inpatient department can be the first role; the second step is that the nurse of the inpatient department arranges a bed for the patient in the corresponding system of the nurse station, that is, arranges hospitalization for the patient. The nurse of the inpatient department can be the second role; the third step is that the doctor of the inpatient department prescribes a medication order for the patient in the corresponding system of the doctor station. The doctor of the inpatient department can be the third role; the fourth step is that the nurse of the inpatient department signs for the medication order of the inpatient doctor in the corresponding system of the nurse station and applies to the pharmacy for medication; the fifth step is that the pharmacist of the pharmacy department dispenses the medication in the corresponding system of the pharmacy. The pharmacist of the pharmacy department can be the fourth role; the sixth step is that the nurse of the inpatient department arranges for the patient to receive medication services in the corresponding system of the nurse station.

[0039] When testing the above-mentioned multiple role business scenarios of medical informationization, it is first necessary to open the hospital information management system, log in to the account of the hospital staff of the inpatient department, and test the operation of the role; secondly, log out of the account and system of the hospital staff of the inpatient department, open the corresponding system of the nurse station where the nurse of the inpatient department is located, log in to the account of the nurse of the inpatient department, and test the operation of the role; then, log out of the account and system of the nurse of the inpatient department, open the corresponding system of the doctor station where the doctor of the inpatient department is located, log in to the account of the doctor of the inpatient department, and test the operation of the role; again, log out of the account and system of the hospital of the inpatient department, continue to open the corresponding system of the nurse station where the nurse of the inpatient department is located, log in to the account of the nurse of the inpatient department, and test the operation of the role; then, log out of the account and system of the nurse of the inpatient department, open the corresponding system of the pharmacy where the pharmacist of the pharmacy department is located, log in to the account of the pharmacist of the pharmacy department, and test the operation of the role; finally, log out of the account and system of the pharmacist of the pharmacy department, continue to open the corresponding system of the nurse station where the nurse of the inpatient department is located, log in to the account of the nurse of the inpatient department, and test the operation of the role.

[0040] In the above business scenario, all four roles need to perform operations. When testing, they need to switch between the four roles and log out and log in, which makes the test less efficient. The nurse in the inpatient department performed three discontinuous operations. When testing, all three times, they need to first open the corresponding system of the nurse station where the nurse in the inpatient department is located, log in to the nurse's account in the inpatient department, and then test the operation. This test operation involves a large number of repeated actions, and the redundancy of the test operation is high, which reduces the efficiency of the test. In the multiple steps of the above business scenario, if a step goes wrong, the entire process needs to be restarted. Therefore, the test results corresponding to some steps that have been tested cannot be reused, and the test script of the above business scenario is less robust. The above business scenario with multiple roles in medical informationization is only an example. The process of the actual business scenario is more complicated than the above process. There may be more roles and more steps designed, which makes the test efficiency relatively low.

[0041] In the solution of the present application, multiple roles can be logged in to multiple browser pages respectively, and the operations and tests of multiple roles are performed on their respective corresponding browser pages. That is, the operations and tests between multiple roles do not affect each other, and there is no need to perform role switching in the test script. The problem of frequent switching between different roles and systems can be solved. At the same time, since multiple roles are managed independently in multiple independent browser pages, if an error occurs in the process execution of a role, it will not affect other roles, which can improve the robustness of the test script.

[0042] In order to improve the testing efficiency of each role in multiple role business scenarios and the robustness of test scripts, the solution of this application provides a web program testing method, so that multiple roles log in to multiple browser pages respectively, and the operations and tests of multiple roles are performed on their respective corresponding browser pages.

[0043] The following is an explanation of a web page program testing method provided in an embodiment of the present application through a specific example. Figure 1 This is a flow chart of a web page program testing method provided in an embodiment of the present application. Figure 1 As shown, the method includes:

[0044] S101, obtaining test scripts corresponding to multiple roles.

[0045] The test script can be executed by an automated testing tool. In this embodiment of the present application, the automated testing tool can be Selenium, which can be used for web application testing, i.e., web page testing. Selenium tests run directly in the browser. The test script opens the browser and simulates operations such as clicking and dragging web elements, just like a real user performing business operations, thereby achieving automated testing of the web application.

[0046] In the embodiment of the present application, the automated testing tool may also be an automated WEB application testing tool such as QTP (Quick Test Professional) and RFT (IBM Rational Test Professional), which is not specifically limited in the embodiment of the present application.

[0047] The test scripts corresponding to multiple roles are the test scripts corresponding to the business operations of multiple roles in the preset web page program. For example, in the above business scenario, the business operation of the first role (hospital staff in the inpatient department) is to handle admission registration for patients in the hospital information management system, so the test script corresponding to this role is the test script corresponding to this business operation; the second role (nurse in the inpatient department) can correspond to multiple test scripts due to the existence of multiple business operations, where each test script corresponds to one business operation. The test scripts corresponding to other roles are similar to the descriptions of the test scripts corresponding to the above roles, and will not be elaborated on here.

[0048] In the embodiment of the present application, the test script can be in Java language, and of course it can also be in other languages, which is not specifically limited in the embodiment of the present application. The following takes the test script in Java language as an example to explain the technical solution of the present application.

[0049] S102, using a plurality of pre-built web page driving objects, simultaneously opening a plurality of browser pages, and executing test scripts corresponding to a plurality of roles in the plurality of browser pages respectively, to obtain test results corresponding to the plurality of roles.

[0050] In the automated testing tool Selenium, you can rely on the web page driver object to open the browser page, and then execute the test script in the opened browser page to obtain the test results.

[0051] When Selenium operates a browser, it needs the assistance of a web driver object. For example, the web driver object can be an object constructed by the WebDriver class. The object can be run by Selenium and automatically open the browser page and return the content of the page during testing.

[0052] In this embodiment of the present application, multiple webpage driver objects are pre-built, allowing multiple browser pages to be opened simultaneously. Each browser page can execute a test script for the role corresponding to that browser page to obtain test results corresponding to the business operations of that role. Multiple browser pages can execute test scripts corresponding to multiple roles independently of each other.

[0053] For example, as in the above business scenario, there are four roles. Four web page driver objects can be pre-built for the four roles to obtain four independent browser pages. At this time, the first role can execute the test script corresponding to the first role in the browser page corresponding to the first web page driver object, that is, the browser page is only responsible for simulating the business operations of the hospital staff in the inpatient department; the second role can execute the test script corresponding to the second role in the browser page corresponding to the second web page driver object, that is, the browser page is only responsible for simulating the business operations of the nurses in the inpatient department; the descriptions of the web page driver objects, corresponding browser pages, corresponding executed test scripts, and corresponding simulated business operations corresponding to other roles are similar to the descriptions of the corresponding content of the above roles, and will not be elaborated here.

[0054] In the embodiment of the present application, the business operations of multiple roles in multiple browser pages can be tested for content, interface, functionality, performance, compatibility, and security, etc., by executing the test script, which is not specifically limited in the embodiment of the present application. The test results can be used to discover as many errors as possible in the browser-side and server-side programs corresponding to the business operations of multiple roles and correct them in a timely manner to ensure the quality of the programs corresponding to the business operations of multiple roles.

[0055] A web program testing method provided by an embodiment of the present application obtains test scripts corresponding to multiple roles, where the test scripts corresponding to the multiple roles are test scripts corresponding to the business operations of the multiple roles in a preset web program. Multiple pre-built web page driver objects are used to open multiple browser pages at the same time, and the test scripts corresponding to the multiple roles are executed in the multiple browser pages respectively to obtain test results corresponding to the multiple roles, so that the operations and tests between the multiple roles do not affect each other, and there is no need to frequently switch between different roles and systems in the testing of multiple role business scenarios, which can effectively improve the testing efficiency. At the same time, each role operates and tests independently in the corresponding browser. If there is an error in the execution of a role process, it will not affect other roles, so that the robustness of the test script is improved. Moreover, if the business operation of a role is in multiple business scenarios, the test script corresponding to the role can be reused when testing the role in multiple business scenarios, thereby improving the reusability of the test script.

[0056] In the above Figure 1Based on the web application testing method described above, this embodiment of the present application also provides a method for opening multiple browser pages. Optionally, the method S102 described above, wherein multiple pre-built web page driver objects are used to simultaneously open multiple browser pages, includes: using multiple web page driver objects to simultaneously open multiple browser pages using multiple debugging ports.

[0057] In a multi-role business scenario, if no browser settings are made, then on a single server, after building multiple web driver objects, each browser page opened will automatically close the previously launched browser page and restart the browser, resulting in only the most recently opened browser page. In addition, the browser pages corresponding to multiple roles are closed in sequence. Therefore, it is impossible to open multiple browser pages simultaneously. This is because multiple web driver objects built using the WebDriver class will each open the browser with the same default debug port, making it impossible to open multiple browser pages simultaneously. Therefore, multiple web driver objects need to use multiple debug ports to open multiple browser pages simultaneously, and then execute test scripts corresponding to multiple roles in multiple browser pages.

[0058] Multiple browser pages can correspond to multiple debug ports, and the debug port of each browser page can be different from the other debug ports. For example, in the above-mentioned multiple-role business scenario, there are four roles, that is, four independent browser pages are opened simultaneously. If the first role corresponds to the first browser page, the second role corresponds to the second browser page, the third role corresponds to the third browser page, and the fourth role corresponds to the fourth browser page, the debug port corresponding to the first browser page can be 9000, the debug port corresponding to the second browser page can be 9001, the debug port corresponding to the third browser page can be 9002, and the debug port corresponding to the fourth browser page can be 9003. It can be understood that the description of the debug port is only an example and is not specifically limited in the embodiments of this application.

[0059] An embodiment of the present application provides a method for opening multiple browser pages. Multiple web page driver objects each use multiple debugging ports to open multiple browser pages at the same time, so that the multiple debugging ports of the multiple browser pages corresponding to multiple roles are different. When each browser page is opened, it will not affect other browser pages, ensuring that multiple browsers can exist at the same time, so that the multiple browsers can be independent of each other.

[0060] Based on the above embodiment, the present application also provides another method for opening multiple browser pages. Optionally, the above method, wherein multiple web page driver objects each use multiple debug ports to simultaneously open multiple browser pages, includes: multiple web page driver objects each use multiple debug ports to simultaneously open multiple pages of the same preset browser as the multiple browser pages. The multiple debug ports are multiple debug ports of the same preset browser.

[0061] In the embodiment of the present application, the preset browser can be any browser. When Selenium operates the preset browser, it needs the assistance of the preset browser driver, wherein the preset browser driver can be a separate service that implements the WebDriver wired protocol, and the preset browser driver can be represented by BrowserDriver. Constructing a web page driver object webdriver1 through the preset browser driver can be: WebDriver webdriver1 = new BrowserDriver(), or: BrowseDriver webdriver1 = new BrowserDriver(), which is not specifically limited in the embodiment of the present application. Constructing another web page driver object webdriver2 through BrowserDriver can be: WebDriverwebdriver2 = new BrowserDriver(), or: BrowseDriver webdriver2 = newBrowserDriver(). The construction of other web page driver objects is similar to the construction method of the above-mentioned web page driver objects, and will not be elaborated on here.

[0062] In the embodiment of the present application, the preset browser can be any browser, and the preset browser object can be any browser driving object, and the preset browser and the preset browser object correspond to each other.

[0063] An embodiment of the present application provides a method for opening multiple browser pages, which uses multiple web page drive objects, each of which uses multiple debugging ports to simultaneously open multiple pages of the same preset browser as multiple browser pages, wherein the multiple debugging ports are multiple debugging ports of the same preset browser, so that the multiple browser pages opened can be pages of multiple different debugging ports corresponding to the same preset browser.

[0064] Based on the above embodiment, the present application also provides another method for opening multiple browser pages. Optionally, the above method, wherein multiple web page driver objects each use multiple debug ports to simultaneously open multiple browser pages, includes: multiple web page driver objects each use multiple debug ports to simultaneously open multiple browser pages as multiple browser pages. The multiple browsers are multiple different browsers with the same kernel, and the multiple debug ports are debug ports of the multiple browsers.

[0065] If multiple browser pages correspond to different browser types but the same kernel, without using multiple debugging ports, each browser page will automatically close the previously launched browser page when it is opened. Therefore, multiple debugging ports are required to open multiple browser pages at the same time as multiple browser pages.

[0066] For example, the first browser and the second browser are two browsers with the same core. In a multi-role business scenario, there are pages of two roles and two different browsers. The pages of the two different browsers can be the page of the first browser and the page of the second browser. One of the web page drive objects can be constructed according to the first browser driver corresponding to the first browser, and the other web page drive object can be constructed according to the second browser driver corresponding to the second browser; if there are multiple roles and multiple pages of different browsers in the multi-role business scenario, some of the pages of the multiple different browsers can be pages of the first browser, and the other pages can be pages of the second browser, that is, each web page drive object can be constructed by the first browser driver or the second browser driver. The construction method is as described in the above embodiment and will not be elaborated here.

[0067] If there are multiple browsers with the same core, and there are multiple roles and pages of multiple different browsers in multiple role business scenarios, each web page driver object can be constructed through the browser driver corresponding to any browser in the multiple browsers with the same core. The construction method is as described in the above embodiment and will not be elaborated here.

[0068] An embodiment of the present application provides a method for opening multiple browser pages, which is driven by multiple web page objects, each using multiple debugging ports, and simultaneously opening multiple browser pages as multiple browser pages. The multiple browsers are multiple different browsers with the same kernel, and the multiple debugging ports are debugging ports of multiple browsers, so that the multiple browser pages opened can be pages of multiple different debugging ports corresponding to multiple different browsers.

[0069] Based on the above embodiment, the present application also provides another method for implementing web application testing. Optionally, before the above method S102, multiple web page driver objects each use multiple debug ports, and before simultaneously opening multiple browser pages, the method further includes: constructing multiple web page driver objects based on the input multiple object creation scripts. Each object creation script includes a debug port.

[0070] Figure 2 A flowchart of a method for opening multiple browser pages provided in an embodiment of the present application. Figure 2 As shown, the method includes:

[0071] S201, constructing multiple web page driver objects according to multiple object creation scripts inputted, wherein each object creation script includes: a debugging port.

[0072] When building a web page driver object, since different debugging ports need to be specified, it is necessary not only to build it through the browser driver corresponding to the browser, but also to specify the debugging port in the object creation script.

[0073] For example, when Selenium operates a browser, it can construct a web driver object webdriver1 through the browser driver BrowseDriver as follows: WebDriver webdriver1 = new BrowserDriver(). On this basis, after specifying a debugging port, it can construct a web driver object webdriver1 as follows:

[0074] BrowserOptions options=new BrowserOptions();

[0075] options.setExperimentalOption("debuggerAddress","localhost:9000");

[0076] WebDriver webdriver1=new BrowserDriver(options);

[0077] Among them, BrowserOptions can be represented as a class that configures browser startup properties. Through this class, relevant parameters can be configured for the browser. In this embodiment of the application, a corresponding object options can be created through the BrowserOptions class, and the browser's debug port (debuggerAddress) can be set in the options object using the setExperimentalOption method. In this embodiment of the application, the BrowseDriver object options of the BrowseOptions class is used to initialize the BrowserDriver, and the debug port 9000 can be set for the web driver object webdriver1.

[0078] Using the above method, you can build a web driver object. Since the browser's debug port is specified through debuggerAddress, you can use the specified debug port 9000 to open the browser page. Using the same method, you can build multiple web driver objects with different debug ports based on multiple roles. Multiple web driver objects correspond to multiple browser pages with different debug ports.

[0079] S202, multiple web page drive objects are used, multiple debugging ports are used respectively, and multiple browser pages are opened simultaneously.

[0080] In the above-mentioned multiple-role business scenario, there are four roles. Then, in the above-mentioned S201, four web page driver objects can be constructed based on the four input object creation scripts. Each object creation script includes: a debug port. For example, the debug port in the first object creation script corresponding to the first role can be 9000, the debug port in the second object creation script corresponding to the second role can be 9001, the debug port in the third object creation script corresponding to the third role can be 9002, and the debug port in the fourth object creation script corresponding to the fourth role can be 9003. Based on the four different debug ports in the four object creation scripts corresponding to the four roles, four web page driver objects with four different debug ports can be constructed. Then, the four debug ports can be respectively used to simultaneously open four browser pages with four different debug ports.

[0081] Among them, the number of roles, the number of object creation scripts, the number of web page driver objects, the number of debug ports, and the expression of each debug port are only examples and are not specifically limited in the embodiments of this application.

[0082] Optionally, in the present application, multiple browser pages with multiple different debugging ports can also be pre-opened through the command line. When executing multiple test scripts corresponding to multiple roles, the browser page corresponding to the debugging port can be found in the multiple browser pages through the debugging port of the browser set in the object options corresponding to each test script, and tested. Among them, multiple browser pages of the same preset browser with multiple different debugging ports can be created through multiple command lines, or browser pages of multiple different browsers with different debugging ports. If a browsing page of a browser with a debugging port of 9000 is created through a command line, the debugging port can be specified through remote-debugging-port. For example, the debugging port of the browsing page of the browser can be specified as 9000 through Browser.exe—remote-debugging-port-9000.

[0083] An embodiment of the present application provides a method for opening multiple browser pages, which creates scripts based on multiple input objects and constructs multiple web page driven objects. Each object creation script includes: a debugging port, so that multiple web page driven objects with different debugging ports can be constructed according to multiple roles. By using multiple different debugging ports, browser pages with multiple different debugging ports can be opened at the same time, so that the operations and tests between multiple roles do not affect each other, which can effectively improve the test efficiency. At the same time, the robustness of the test script can be improved, and the reusability of the test script is also improved.

[0084] In the above Figure 1 Based on the web application testing method shown above, another embodiment of the present application provides another method for implementing web application testing. Optionally, the method further includes: transferring the user data and cached data in the test results corresponding to each role to a first preset address and a second preset address specified by the web page driver object corresponding to each role.

[0085] In the above embodiment, the operation processes of multiple browser pages can be managed independently, but the user data and cached data in the test results of the multiple browser pages are not separated. Therefore, before executing the test scripts corresponding to the multiple roles in the multiple browser pages, it is necessary to distinguish the storage locations of the test results data generated by the multiple roles in the multiple browser pages. This makes the data generated by the tests in the multiple browser pages independent of each other, ensuring the data independence of the multiple browser pages. The data in the test results of each browser page can include user data and cached data.

[0086] The user data and cached data in the test results corresponding to each role need to be stored in two different files. The two different files correspond to two directories, and the two directories correspond to two addresses, which can be a first preset address and a second preset address. That is, the user data and cached data in the test results corresponding to each role can be stored in the first preset address and the second preset address specified by the web page driver object corresponding to each role, respectively. It is understandable that in a multi-role business scenario, multiple web page driver objects corresponding to multiple roles can specify multiple first preset addresses and multiple second preset addresses, and the multiple preset addresses and the multiple preset second addresses are different from each other.

[0087] Another method for testing a web page program provided by an embodiment of the present application stores the user data and cache data in the test results corresponding to each role in the first preset address and the second preset address specified by the web page driver object corresponding to each role, respectively, so that the multiple user data and multiple cache data generated by the test in multiple browser pages are independent of each other, thereby ensuring the data independence of multiple browser pages.

[0088] Based on the above embodiment, the present application also provides another method for implementing web application testing. Optionally, before the above method S102, before opening multiple browser pages simultaneously using multiple pre-built web page driver objects, the method further includes: constructing multiple web page driver objects based on multiple input object creation scripts, each object creation script including: a first preset address and a second preset address.

[0089] Figure 3 A flowchart of another web program testing method provided in an embodiment of the present application.

[0090] like Figure 3 As shown, the method includes:

[0091] S301, constructing multiple web page driver objects according to multiple object creation scripts inputted, wherein each object creation script includes: a first preset address and a second preset address.

[0092] Based on the embodiment of S201 in which each object creation script includes a debug port, each object creation script further includes: a first preset address and a second preset address. For example, when Selenium operates a browser, based on a specified debug port and a specified first preset address and a specified second preset address, a web driver object webdriver1 may be constructed as follows:

[0093] BrowserOptions options=new BrowserOptions();

[0094] options.addArguments("user-data-dir="+"first default address");

[0095] options.addArguments("disk-cache-dir="+"second preset address");

[0096] options.setExperimentalOption("debuggerAddress","localhost:9000");

[0097] WebDriver webdriver1=new BrowserDriver(options);

[0098] The addArguments method can be used to set the data storage address of the browser in the options object. The user-data-dir can be the storage address of the user data, that is, the first preset address, and the disk-cache-dir can be the storage address of the cache data, that is, the second preset address.

[0099] In an embodiment of the present application, the object options of the BrowserOptions class is used to initialize BrowserDriver, that is, the debug port 9000, the first preset address, and the second preset address are set for the web page driver object webdriver1. According to the above method, a web page driver object can be constructed. Since the debug port of the browser is specified by debuggerAddress, the storage address of the user data is specified by user-data-dir, and the storage address of the cached data is set by disk-cache-dir, the specified debug port 9000 can be used to open the browser page, and the data in the test results can be stored by the specified storage address. Using the same method, multiple web page driver objects with different debug ports can be constructed according to multiple roles. Multiple web page driver objects correspond to multiple browser pages with different debug ports and multiple first preset addresses and multiple second preset addresses. On the basis of ensuring that the operations and tests of multiple browser pages are independent of each other, the independence of the data in the multiple test results corresponding to the multiple browser pages is guaranteed.

[0100] S302, multiple pre-built web page drive objects are used to open multiple browser pages at the same time.

[0101] In an embodiment of the present application, multiple web page driver objects are constructed based on the specified multiple debugging ports and the specified multiple first preset addresses and multiple second preset addresses. When multiple browser pages are opened, the storage addresses of user data and cached data in the test results corresponding to each browser page are set, thereby achieving the independence of the data storage space of multiple user data and multiple cached data generated by the tests in multiple browser pages.

[0102] Another method for testing a web page program provided in an embodiment of the present application is to create scripts based on multiple input objects to construct multiple web page driver objects. Each object creation script includes: a first preset address and a second preset address. The multiple pre-constructed web page driver objects open multiple browser pages at the same time, so that on the basis of the multiple browser pages being independent of each other, the multiple user data and multiple cached data generated by the tests in the multiple browser pages are also independent of each other, thereby achieving complete independence of the test of each role in the web page program test.

[0103] In the above embodiments of the present application Figure 1 、 Figure 2 、 Figure 3 Based on the provided web page program testing method, the web page program testing method is specifically explained below through a complete embodiment in combination with the accompanying drawings. Figure 4 This is a flow chart of another web page program testing method provided in an embodiment of the present application. Figure 4 As shown, the method includes:

[0104] S401, obtaining test scripts corresponding to multiple roles.

[0105] The specific implementation and effect description of S401 can be found in the above Figure 1 S101 in the description will not be repeated here.

[0106] S402 , constructing multiple webpage driver objects according to the input multiple object creation scripts, each object creation script including: a debugging port, a first preset address, and a second preset address.

[0107] The specific implementation and effect description of S402 are described in the above Figure 2 S201 and Figure 3 S301 in the description will not be repeated here.

[0108] S403, using multiple pre-built web page driver objects, respectively using multiple debugging ports, opening multiple browser pages at the same time, and executing test scripts corresponding to multiple roles in the multiple browser pages respectively, to obtain test results corresponding to the multiple roles.

[0109] The specific implementation and effect description of S403 can be found in the above Figure 2 S202 and Figure 1 S102 in the description will not be repeated here.

[0110] S404: storing the user data and cached data in the test result corresponding to each role in the first preset address and the second preset address specified by the webpage driver object corresponding to each role respectively.

[0111] The specific implementation and effect description of S403 can be found in the above embodiment and will not be repeated here.

[0112] The following describes a web page program testing device, equipment, and storage medium provided by the present application for execution. The specific implementation process and technical effects are described above and will not be repeated below.

[0113] Figure 5 A schematic diagram of a web page program testing device provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the web program testing device includes:

[0114] The acquisition module 501 is used to acquire test scripts corresponding to multiple roles, wherein the test scripts corresponding to the multiple roles are test scripts corresponding to the business operations of the multiple roles in the preset webpage program.

[0115] The execution module 502 is used to drive objects using multiple pre-built web pages, open multiple browser pages at the same time, and execute test scripts corresponding to multiple roles in the multiple browser pages respectively to obtain test results corresponding to the multiple roles.

[0116] Optionally, the execution module 502 is further configured to drive the object via multiple web pages, respectively using multiple debugging ports, and simultaneously opening multiple browser pages.

[0117] Optionally, the execution module 502 is further configured to drive objects by multiple web pages, respectively using multiple debugging ports, and simultaneously opening multiple pages of the same preset browser as multiple browser pages; the multiple debugging ports are multiple debugging ports of the same preset browser.

[0118] Optionally, the execution module 502 is also used to drive objects by multiple web pages, respectively using multiple debugging ports, and simultaneously opening pages of multiple browsers as multiple browser pages; the multiple browsers are multiple different browsers with the same kernel, and the multiple debugging ports are debugging ports of multiple browsers.

[0119] Optionally, the execution module 502 is further configured to construct a plurality of web page driven objects according to a plurality of input object creation scripts, wherein each object creation script includes: a debugging port.

[0120] The storage module 503 is configured to store the user data and cached data in the test result corresponding to each role in the first preset address and the second preset address specified by the webpage driver object corresponding to each role, respectively.

[0121] Optionally, the execution module 502 is further configured to construct a plurality of web page driven objects according to a plurality of input object creation scripts, wherein each object creation script includes: a first preset address and a second preset address.

[0122] The above modules can be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more digital singular processors (DSPs), or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code through a processing element, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0123] Figure 6 A schematic diagram of a computer device provided in an embodiment of the present application, which may be a computing device or server with computing processing capabilities.

[0124] The computer device includes: a processor 601 , a storage medium 602 , and a bus 603 . The processor 601 and the storage medium 602 are connected via the bus 603 .

[0125] The storage medium 602 is used to store programs, and the processor 601 calls the programs stored in the storage medium 602 to execute the above method embodiment. The specific implementation methods and technical effects are similar and will not be repeated here.

[0126] Optionally, the present invention further provides a program product, such as a computer-readable storage medium, comprising a program, which is used to perform the above method embodiment when executed by a processor.

[0127] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0128] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0129] In addition, the functional units in various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or hardware plus software functional units.

[0130] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (English: Read-Only Memory, abbreviated: ROM), a random access memory (English: Random Access Memory, abbreviated: RAM), a magnetic disk or an optical disk, and other media that can store program code.

[0131] The above are only specific embodiments of the present application, but the scope of protection of this application is not limited to them. Any changes or substitutions that can be easily conceived by any person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A web page program testing method, characterized in that: include: Obtaining test scripts corresponding to multiple roles in multiple role business scenarios, wherein the test scripts corresponding to the multiple roles are test scripts corresponding to the business operations of the multiple roles in a preset webpage program; Multiple web page driver objects pre-built for the multiple roles respectively use multiple debugging ports and simultaneously open multiple browser pages, so that the multiple browser pages correspond to the multiple roles respectively, and the multiple web page driver objects are pre-assigned with different multiple debugging ports; Executing test scripts corresponding to the multiple roles in the multiple browser pages respectively to obtain test results corresponding to the multiple roles, wherein the multiple roles are respectively logged in to the multiple browser pages, and the business operations and tests of the multiple roles are respectively performed on the corresponding browser pages; The multiple browser pages are multiple pages of the same preset browser, and the multiple debug ports are multiple debug ports of the same preset browser; or, the multiple browser pages are pages of multiple browsers with the same kernel as the multiple browser pages, and the multiple debug ports are debug ports of the multiple browser pages.

2. The webpage program testing method according to claim 1, wherein: Before simultaneously opening the multiple browser pages by using multiple debugging ports for the multiple web page driver objects for the multiple roles, the method further includes: The plurality of web page driven objects are constructed according to the inputted plurality of object creation scripts, wherein each object creation script includes: a debugging port.

3. The webpage program testing method according to claim 1, wherein: The method further comprises: The user data and cache data in the test result corresponding to each role are respectively stored in the first preset address and the second preset address specified by the web page driver object corresponding to each role.

4. The webpage program testing method according to claim 3, wherein: Before simultaneously opening multiple browser pages by using multiple web page driver objects pre-built for the multiple roles and using multiple debugging ports respectively, the method further includes: The plurality of web page driven objects are constructed according to the inputted plurality of object creation scripts, wherein each object creation script includes: a first preset address and a second preset address.

5. A web page program testing device, characterized in that: include: An acquisition module, configured to acquire test scripts corresponding to multiple roles in multiple role business scenarios, wherein the test scripts corresponding to the multiple roles are test scripts corresponding to the business operations of the multiple roles in a preset webpage program; An execution module is configured to use a plurality of web page driver objects pre-built for the plurality of roles, respectively adopt a plurality of debugging ports, and simultaneously open a plurality of browser pages, so that the plurality of browser pages correspond to the plurality of roles, and the plurality of web page driver objects are pre-assigned with different plurality of debugging ports; execute test scripts corresponding to the plurality of roles in the plurality of browser pages, respectively, to obtain test results corresponding to the plurality of roles, wherein the plurality of roles are respectively logged in to the plurality of browser pages, and business operations and tests of the plurality of roles are respectively performed on the corresponding browser pages; The multiple browser pages are multiple pages of the same preset browser, and the multiple debug ports are multiple debug ports of the same preset browser; or, the multiple browser pages are pages of multiple browsers with the same kernel as the multiple browser pages, and the multiple debug ports are debug ports of the multiple browser pages.

6. A computer device, characterized in that: include: A storage medium and a processor, wherein the storage medium stores a computer program executable by the processor, and when the processor executes the computer program, the web page program testing method described in any one of claims 1 to 4 is implemented.

7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is read and executed, the web page program testing method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Application program testing method and device, storage medium and server

    CN110704304A