Web page testing method, testing device, electronic equipment and storage medium

By extracting script information in web page tests and generating configuration files, and automatically generating test cases, the problem of low testing efficiency in the existing technology is solved and more efficient web page testing is achieved.

CN113360366BActive Publication Date: 2025-01-10BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010146734.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-03-05
Publication Date
2025-01-10
Estimated Expiration
2040-03-05

AI Technical Summary

Technical Problem

Existing Web page testing methods require manual storage of test cases, resulting in inconvenient batch execution and low testing efficiency.

Method used

By obtaining the script after the simulation operation, extracting page element information and simulation operation related information, generating configuration files, and using the configuration files to generate test cases, automating the web page testing process.

Benefits of technology

It improves the efficiency of web page testing, reduces the need for manual viewing and manual generation of test cases, and is suitable for application scenarios of large-scale test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113360366B_ABST
    Figure CN113360366B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a Web page testing method, a testing device, an electronic device and a storage medium, wherein the method comprises: obtaining a script generated after simulating an operation on a Web page to be tested; extracting the page element information and the information related to the simulated operation from the script, and generating a configuration file; generating a test case using the configuration file; and testing the Web page using the test case. The embodiment of the present invention can improve the testing efficiency of Web pages and is more suitable for application scenarios that require a large number of test cases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of web page testing, and in particular to a web page testing method, a testing device, an electronic device and a storage medium. Background Art

[0002] During the development of a Web (World Wide Web) page, it is necessary to test the Web page, for example, to test the UI (User Interface) of the Web page.

[0003] The existing testing methods for Web pages are mainly carried out through testing tools, such as selenium and webdriver, where selenium is also called selenium RC, which can be used to test whether the various functions of the Web page are normal. In the prior art, when testing a Web page, the Selenium-IDE plug-in in selenium RC can be used to record the simulated operation of the test script to obtain a script, and then the page element information carried in the script is manually checked, and a test case is manually generated based on the page element information to test the Web page, where the simulated operation refers to the simulation of the user operation, and the script refers to the script generated when the user operation is simulated.

[0004] However, since the above test cases need to be manually saved after being generated, there is a problem of inconvenience in batch execution, resulting in low testing efficiency. Summary of the invention

[0005] The purpose of the embodiments of the present invention is to provide a web page testing method, a testing device, an electronic device and a storage medium to improve the efficiency of web page testing. The specific technical solution is as follows:

[0006] In a first aspect, an embodiment of the present invention provides a web page testing method, comprising:

[0007] Acquire a script generated after the simulated operation of the Web page to be tested, wherein the script carries: page element information of the Web page to be tested and information related to the simulated operation;

[0008] Extracting the page element information and the information related to the simulation operation from the script, and generating a configuration file;

[0009] Generate test cases using the configuration file;

[0010] The Web page is tested using the test case.

[0011] Optionally, the step of extracting the page element information and the information related to the simulation operation from the script and generating a configuration file includes:

[0012] A configuration file is generated using preset test case functional requirements, the extracted page element information, and the information related to the simulation operation, wherein the test case functional requirements include: instance backup requirements, instance creation requirements, instance restart requirements, instance configuration information change requirements, and instance process node addition requirements; the page element information includes: the name of the page element, the positioning method of the page element, and the location information of the page element in the Web page to be tested; and the information related to the simulation operation includes: the operation process information of the simulation operation and the input value of the simulation operation.

[0013] Optionally, the step of extracting the page element information and the information related to the simulation operation from the script and generating a configuration file includes:

[0014] Using the preset test requirements of each functional module in the Web page to be tested, the extracted page element information, and the information related to the simulation operation, multiple configuration files are generated, and the functional modules include: an instance backup module, an instance creation module, an instance restart module, an instance configuration information change module, and an instance process node addition module;

[0015] Then the step of generating the test case by using the configuration file includes:

[0016] A plurality of test cases are generated using the plurality of configuration files, wherein different test cases are used to test each functional module in the Web page to be tested.

[0017] Optionally, the step of testing the Web page using the test case includes:

[0018] Using each of the multiple test cases, the functional modules corresponding to the test case are tested respectively.

[0019] Optionally, before testing the Web page using the test case, the method further includes:

[0020] Creating a test task for the test case, wherein the test task is used to test a current functional module, and the current functional module is any module of the Web page;

[0021] Then the step of testing the Web page using the test case includes:

[0022] Comparing the running data of the test task with the configuration data in the test case to obtain a comparison result;

[0023] Based on the comparison result, it is determined whether the current functional module passes the test.

[0024] Optionally, the step of judging whether the current functional module passes the test based on the comparison result includes:

[0025] If the comparison result is consistent, it is determined that the current functional module passes the test;

[0026] If the comparison result is inconsistent, it is determined that the current functional module has failed the test.

[0027] Optionally, the step of obtaining a script generated after simulating an operation on the Web page to be tested includes:

[0028] Performing simulation operations on the Web page to be tested;

[0029] The simulation operation is recorded to obtain a script of the simulation operation.

[0030] In a second aspect, an embodiment of the present invention provides a web page testing device, including:

[0031] An acquisition module, used to acquire a script generated after a simulated operation on the Web page to be tested, wherein the script carries: page element information of the Web page to be tested and information related to the simulated operation;

[0032] A first generating module, used for extracting the page element information and the information related to the simulation operation from the script, and generating a configuration file;

[0033] A second generating module, used to generate a test case using the configuration file;

[0034] The testing module is used to test the Web page using the test case.

[0035] Optionally, the first generating module is specifically used for:

[0036] A configuration file is generated using preset test case functional requirements, the extracted page element information, and the information related to the simulation operation, wherein the test case functional requirements include: instance backup requirements, instance creation requirements, instance restart requirements, instance configuration information change requirements, and instance process node addition requirements; the page element information includes: the name of the page element, the positioning method of the page element, and the location information of the page element in the Web page to be tested; and the information related to the simulation operation includes: the operation process information of the simulation operation and the input value of the simulation operation.

[0037] Optionally, the first generating module is specifically used for:

[0038] Using the preset test requirements of each functional module in the Web page to be tested, the extracted page element information, and the information related to the simulation operation, multiple configuration files are generated, and the functional modules include: an instance backup module, an instance creation module, an instance restart module, an instance configuration information change module, and an instance process node addition module;

[0039] Then the second generating module is specifically used for:

[0040] A plurality of test cases are generated using the plurality of configuration files, wherein different test cases are used to test each functional module in the Web page to be tested.

[0041] Optionally, the test module is specifically used for:

[0042] Using each of the multiple test cases, the functional modules corresponding to the test case are tested respectively.

[0043] Optionally, the device further comprises:

[0044] A creation module, used for creating a test task of the test case, wherein the test task is used for testing a current functional module, and the current functional module is any module of the Web page;

[0045] The test module is specifically used for:

[0046] Comparing the running data of the test task with the configuration data in the test case to obtain a comparison result;

[0047] Based on the comparison result, it is determined whether the current functional module passes the test.

[0048] Optionally, the test module is specifically used for:

[0049] If the comparison result is consistent, it is determined that the current functional module passes the test;

[0050] If the comparison result is inconsistent, it is determined that the current functional module has failed the test.

[0051] Optionally, the acquisition module includes:

[0052] A simulation submodule, used for performing simulation operations on the Web page to be tested;

[0053] The recording submodule is used to record the simulation operation to obtain a script of the simulation operation.

[0054] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the method steps of the Web page testing method provided in the first aspect above.

[0055] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of the Web page testing method provided in the first aspect are implemented.

[0056] In a fifth aspect, an embodiment of the present invention further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method steps of the Web page testing method provided in the first aspect above.

[0057] In a sixth aspect, an embodiment of the present invention further provides a computer program, which, when executed on a computer, enables the computer to execute the method steps of the Web page testing method provided in the first aspect above.

[0058] The embodiment of the present invention provides a Web page testing method, a testing device, an electronic device and a storage medium. After obtaining the script generated after the simulated operation of the Web page to be tested, the script page element information and the information related to the simulated operation of the script are extracted from the script, and a configuration file is generated. Then, the configuration file is used to generate a test case, so that the script Web page is tested using the test case. It can be seen that, by applying the embodiment of the present invention, since the configuration file used to generate the test case contains the script page element information and the information related to the simulated operation, there is no need to manually check the page element information carried in the script, so there is no need to manually generate the test case based on the page element information, which improves the testing efficiency of the Web page and is more suitable for application scenarios that require a large number of test cases. Of course, any product or method implementing the present invention does not necessarily need to achieve all the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0060] Figure 1 A schematic diagram of a flow chart of a Web page testing method provided by an embodiment of the present invention;

[0061] Figure 2 Another flowchart of a Web page testing method provided by an embodiment of the present invention;

[0062] Figure 3 A schematic diagram of the structure of a Web page testing device provided by an embodiment of the present invention;

[0063] Figure 4 Another structural schematic diagram of a Web page testing device provided by an embodiment of the present invention;

[0064] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0065] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in 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. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0066] The existing testing method for Web pages can also adopt the Page Objects design pattern method, that is, after locating the page elements in the Web page, the page elements are placed in different Page functions for automated use. However, this method is complicated in the process of placing the page elements in different Page functions, which is not friendly to inexperienced operators. In addition, when the page elements are frequently changed, the page elements need to be relocated each time, and the locating process of the page elements is cumbersome, so it is easy to obtain the wrong elements.

[0067] In view of this, Figure 1 As shown, an embodiment of the present invention provides a Web page testing method, which may include the following steps:

[0068] S101, obtaining a script generated after simulating an operation on a Web page to be tested.

[0069] In an embodiment of the present invention, an electronic device can simulate operations on a Web page to be tested, for example, simulating a user clicking a link on a Web page to be tested, simulating content input by a user in an input box of a Web page to be tested, simulating a user selecting a value from a drop-down list of a Web page to be tested, and the like, and generate a script after the simulation operation, which can carry: page element information of the Web page to be tested, and information related to the simulation operation. The above-mentioned page element information refers to information related to page elements in the Web page to be tested, and the content contained therein will be shown in the following embodiments, and the above-mentioned information related to the simulation operation refers to information generated during the simulation operation, and the content contained therein will also be shown in the following embodiments. The above-mentioned electronic device can refer to a server, an electronic computer, a mobile terminal, and the like.

[0070] The above script may also include: commands generated after each simulated operation, for example, for the operation of simulating a user clicking a link in the Web page to be tested, a click command may be generated, for the operation of simulating a user entering content in an input box of the Web page to be tested, an input command may be generated, and for the operation of simulating a user selecting a value from a drop-down list of the Web page to be tested, a selection command may be generated.

[0071] S102, extracting page element information and information related to the simulation operation from the script, and generating a configuration file.

[0072] After obtaining the script, since the script carries the page element information of the web page to be tested and the information related to the simulation operation, the page element information and the information related to the simulation operation can be extracted from the script to generate a configuration file. It can be understood that the configuration file also contains the page element information and the information related to the simulation operation. The suffix of the configuration file is usually conf, which is the abbreviation of configuration config.

[0073] S103, generating test cases using the configuration files.

[0074] In the embodiment of the present invention, after obtaining the configuration file, the configuration file can be used to generate a test case, and the test case can include input parameters, execution conditions and expected results of the test, so as to test the function of the Web page to be tested.

[0075] S104, testing the Web page using the test case.

[0076] After the test case is generated, the embodiment of the present invention can use the test case to test the Web page, for example, to test various functions in the Web page.

[0077] As an optional implementation of the embodiment of the present invention, a configuration file can be generated using preset test case functional requirements, extracted page element information, and information related to simulated operations, thereby generating a configuration file according to the needs of testers to improve user experience.

[0078] The above test case functional requirements may refer to the tester's requirements for the functions that the test case can achieve, such as: instance backup requirements, instance creation requirements, instance restart requirements, instance configuration information change requirements, and instance process node addition requirements, etc. The instance here may refer to the abbreviation of the test case. Of course, the above test case functional requirements can be pre-set according to the tester's needs.

[0079] The above-mentioned page element information may include: the name of the page element, the positioning method of the page element, the position information of the page element in the Web page to be tested, and the path of the page element. Among them, the page element may refer to the content elements constituting a Web page, for example, it may include: text, pictures, audio, animation, video and other content elements; the positioning method of the page element may refer to the use of a certain positioning method to locate the current page element in the Web page, for example, by positioning the page element's identification number (ID), or by positioning the page element's name (name), etc.; the position information of the page element in the Web page to be tested may refer to the position coordinates of the page element in the Web page to be tested. In the process of setting the Web page, different page elements may be named, or different identifiers may be added, or the position coordinates of each page element in the Web page may be indicated to distinguish each page element, which is reasonable; the path of the page element may refer to the storage path of the page element, which is usually the path of the CSS (Cascading Style Sheets) file storing the page element.

[0080] The above-mentioned information related to the simulation operation may include: operation process information of the simulation operation, such as the target operation object of the simulation operation, the operation command of the simulation operation, etc., and may also include input values ​​of the simulation operation, such as input parameters.

[0081] As an optional implementation of the embodiment of the present invention, the embodiment of the present invention can generate multiple configuration files by using the preset test requirements of each functional module in the Web page to be tested, the extracted page element information, and the information related to the simulation operation.

[0082] Exemplarily, the above functional modules may include: an instance backup module, an instance creation module, an instance restart module, an instance configuration information change module, and an instance process node addition module. Among them, the instance backup module is used to back up the instance data involved in the Web page; the instance creation module is used to create different instances; the instance restart module is used to restart the instance, such as restarting a test case service; the instance configuration information change module is used to change the configuration information in the instance; the instance process node addition module is used to add process nodes in the instance.

[0083] It can be understood that a web page to be tested usually contains multiple functional modules, and testers usually need to test each functional module. Therefore, the multiple configuration files generated by the embodiment of the present invention, different configuration files can be used to generate different test cases to test different functional modules in the web page to be tested. For a web page to be tested containing multiple functional modules, each functional module can be tested in batches, which improves the test flexibility on the one hand and further improves the test efficiency on the other.

[0084] As an optional implementation of the embodiment of the present invention, a test case can correspond to a functional module in the Web page to be tested, and each test case in the multiple test cases can be used to test the functional module corresponding to the test case respectively. In this way, the test is more purposeful and it is convenient for the tester to test the specific functional modules in the Web page more specifically.

[0085] As an optional implementation of the embodiment of the present invention, in the process of obtaining the script generated after the simulated operation on the Web page to be tested, the Web page to be tested can be simulated, the simulated operation can be recorded, and the recorded content can be obtained, thereby obtaining the script of the simulated operation. The recording method can refer to the script recording process of Selenium-IDE. The above-mentioned recorded content can be saved in the form of a Python file, wherein Python is a computer programming language, and the data saved in the Python file is based on the Python language description.

[0086] A Web page testing method provided by an embodiment of the present invention obtains a script generated after a simulated operation on a Web page to be tested, extracts script page element information and information related to the script and the simulated operation from the script, generates a configuration file, and then generates a test case using the configuration file, thereby using the test case to test the script Web page. It can be seen that, by applying the embodiment of the present invention, since the configuration file used to generate the test case contains the script page element information and the information related to the simulated operation, there is no need to manually check the page element information carried in the script, and therefore there is no need to manually generate test cases based on the page element information, thereby improving the testing efficiency of the Web page and being more suitable for application scenarios that require a large number of test cases.

[0087] The embodiment of the present invention also provides a Web page testing method, such as Figure 2 As shown, the method process may include:

[0088] S201, obtaining a script generated after simulating an operation on the Web page to be tested.

[0089] S202, extracting page element information and information related to the simulation operation from the script, and generating a configuration file.

[0090] S203, generate test cases using the configuration files.

[0091] The above steps S201 to S203 are Figure 1 S101 to S103 of the illustrated embodiment are the same and are not described here in detail.

[0092] S204, creating a test task for the test case.

[0093] After generating a test case, the embodiment of the present invention may also create a test task for the test case, wherein the test task is used to test the current functional module, the current functional module may refer to any module of a Web page, and the test case may be referred to as an instance.

[0094] Exemplarily, for the above-mentioned instance backup module, the test tasks that can be created include: computer room selection task, instance selection task, data backup task, backup file consistency detection task, and these tasks can all involve backup functions. Among them, for the above-mentioned computer room selection task, different businesses can be involved in a Web page, and these different businesses can be processed in different computer rooms. Therefore, when backing up the data of test cases corresponding to different businesses, different computer rooms can be selected, and this task is the computer room selection task. For the instance selection task, it is easy to understand that a Web page can involve different instances, so different instances can be selected, and this task is the instance selection task. For the data backup task, data will be generated when operating the Web page, so the data can be backed up, and this task is the data backup task. For the backup file consistency detection task, after the data is backed up, the status of the backup file, the number of backup files and other information can be recorded in the backup list, so it can be detected whether the recorded information is consistent with that before the backup, and this task is the backup file consistency detection task.

[0095] For the above instance creation module, the test tasks that can be created include: computer room selection task, instance creation task, instance configuration comparison task, and these tasks can all involve instance creation functions. Among them, for the above computer room selection task, different businesses can be involved in a web page, and these different businesses can be processed in different computer rooms. Therefore, when creating test cases for different businesses, different computer rooms can be selected. This task is the computer room selection task. For the above instance creation task, different instances can be created for the web page. This task is the instance creation task. For the above instance configuration comparison task, after the instance is created, the configuration information obtained after the instance is created can be compared for consistency with the configuration information of the instance described in natural language before creation.

[0096] For the above instance restart module, the test tasks that can be created include: computer room selection task, instance selection task, instance restart task, instance configuration comparison task, all of which can involve the instance restart function. Among them, the principles of computer room selection task and instance selection task are the same as the above content, but they are used in the instance restart function. For the above instance restart task, you can restart an instance, and this task is the instance restart task. For the above instance configuration comparison task, after restarting the instance, you can compare whether the configuration and status of the instance before and after the restart are consistent.

[0097] For the above-mentioned instance configuration information change module, the test tasks that can be created include: computer room selection task, instance selection task, instance configuration modification task, instance configuration comparison task, and instance status detection task. These tasks can all involve the instance change function. Among them, the principles of the computer room selection task and the instance selection task are the same as the aforementioned content, except that they are used in the instance configuration information change function. For the above-mentioned instance configuration modification task, the configuration information of a certain instance can be modified, and this task is the instance configuration modification task. For the above-mentioned instance configuration comparison task, after modifying the configuration information of the instance, the data before and after the instance configuration information is changed can be compared. The specific comparison process is: obtain the configuration information of the changed instance, and then compare it with the configuration information defined by the configuration parameters in the configuration command before the change. For the above-mentioned instance status detection task, the change in the status of the instance after the configuration information of the instance is modified can be detected.

[0098] For the above-mentioned instance process node addition module, the test tasks that can be created include: computer room selection task, instance selection task, database slave node addition task, instance configuration comparison task, instance status detection task, all of which can involve the instance process node addition function. Among them, the principles of the computer room selection task and the instance selection task are the same as the above content, except that they are used in the instance process node addition function. For the database slave node addition task, when the process node of the instance is added, the data of the node will be added to the database accordingly. For the above-mentioned instance configuration comparison task, due to the addition of process nodes, the instance configuration information will change, so it is necessary to compare the configuration information before and after the process node is added. For the above-mentioned instance status detection task, similarly, due to the addition of process nodes, the state of the instance will change, so it is possible to detect the change in the state of the instance after the instance adds the process node.

[0099] S205, comparing the running data of the test task with the configuration data in the test case to obtain a comparison result.

[0100] It can be understood that operation data can be generated when executing a test task. Therefore, the operation data can be compared with the configuration data in the test case to determine the consistency between the operation data and the configuration data in the test case, thereby achieving a comparison result.

[0101] S206: Determine whether the current functional module passes the test based on the comparison result.

[0102] After obtaining the comparison result, the embodiment of the present invention can determine whether the current functional module passes the test based on the comparison result.

[0103] Specifically, if the comparison result is consistent, it is determined that the current functional module has passed the test;

[0104] If the comparison result is inconsistent, it is determined that the current functional module has failed the test.

[0105] A Web page testing method provided by an embodiment of the present invention creates a test task for a test case, and compares the running data of the test task with the configuration data in the test case to obtain a comparison result, thereby judging whether the current functional module passes the test based on the comparison result, and can test each functional module in a more targeted manner.

[0106] Corresponding to the above method embodiments, the embodiments of the present invention also provide corresponding device embodiments.

[0107] like Figure 3 As shown, an embodiment of the present invention provides a web page testing device, including:

[0108] The acquisition module 301 is used to acquire a script generated after the simulated operation on the Web page to be tested, and the script carries: page element information of the Web page to be tested and information related to the simulated operation.

[0109] The first generating module 302 is used to extract page element information and information related to the simulation operation from the script and generate a configuration file.

[0110] The second generating module 303 is used to generate test cases using the configuration files.

[0111] The testing module 304 is used to test the Web page using the test case.

[0112] The first generating module 302 is specifically used for:

[0113] A configuration file is generated using preset test case functional requirements, extracted page element information, and information related to simulation operations, wherein the test case functional requirements include: instance backup requirements, instance creation requirements, instance restart requirements, instance configuration information change requirements, and instance process node addition requirements; the page element information includes: the name of the page element, the positioning method of the page element, and the location information of the page element on the Web page to be tested; and the information related to simulation operations includes: the operation process information of the simulation operation and the input value of the simulation operation.

[0114] The first generating module 302 is specifically used for:

[0115] Multiple configuration files are generated using the preset test requirements of each functional module in the Web page to be tested, the extracted page element information, and the information related to the simulation operation. The functional modules include: instance backup module, instance creation module, instance restart module, instance configuration information change module, and instance process node addition module.

[0116] Then the second generation module 303 is specifically used for:

[0117] Multiple test cases are generated using multiple configuration files, wherein different test cases are used to test each functional module in the Web page to be tested.

[0118] The test module 304 is specifically used for:

[0119] Using each of the multiple test cases, the functional modules corresponding to the test case are tested respectively.

[0120] Among them, Figure 3 Based on the device shown, Figure 4 As shown, the Web page testing device of the embodiment of the present invention may also include:

[0121] A creation module 401 is used to create a test task of a test case, where the test task is used to test a current function module, which is any module of a Web page;

[0122] The testing module 304 is specifically used for:

[0123] Compare the running data of the test task with the configuration data in the test case to obtain the comparison result, and determine whether the current functional module passes the test based on the comparison result.

[0124] The test module 304 is specifically used for:

[0125] If the comparison results are consistent, it is determined that the current functional module has passed the test;

[0126] If the comparison result is inconsistent, it is determined that the current functional module has failed the test.

[0127] A Web page testing device provided by an embodiment of the present invention obtains a script generated after a simulated operation on a Web page to be tested, extracts script page element information and information related to the script and the simulated operation from the script, generates a configuration file, and then generates a test case using the configuration file, thereby using the test case to test the script Web page. It can be seen that, by applying the embodiment of the present invention, since the configuration file used to generate the test case contains the script page element information and the information related to the simulated operation, there is no need to manually check the page element information carried in the script, and therefore there is no need to manually generate test cases based on the page element information, thereby improving the testing efficiency of the Web page and being more suitable for application scenarios that require a large number of test cases.

[0128] The embodiment of the present invention further provides an electronic device, which may be a server. Figure 5As shown, the device 500 includes a processor 501 and a machine-readable storage medium 502, the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the following steps:

[0129] Obtaining a script generated after simulating the operation on the Web page to be tested, the script carrying: page element information of the Web page to be tested and information related to the simulation operation;

[0130] Extract page element information and information related to simulation operations from the script and generate a configuration file;

[0131] Generate test cases using configuration files;

[0132] Use test cases to test web pages.

[0133] The machine-readable storage medium may include a random access memory (RAM) or a non-volatile memory, such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0134] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0135] The electronic device provided by the embodiment of the present invention, after obtaining the script generated after the simulated operation on the Web page to be tested, extracts the script page element information and the information related to the script and the simulated operation from the script, and generates a configuration file, and then generates a test case using the configuration file, so as to test the script Web page using the test case. It can be seen that, by applying the embodiment of the present invention, since the configuration file used to generate the test case contains the script page element information and the information related to the simulated operation, there is no need to manually check the page element information carried in the script, and therefore there is no need to manually generate the test case based on the page element information, which improves the testing efficiency of the Web page and is more suitable for application scenarios that require a large number of test cases.

[0136] The embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the computer program is used to perform the following steps:

[0137] Obtaining a script generated after simulating the operation on the Web page to be tested, the script carrying: page element information of the Web page to be tested and information related to the simulation operation;

[0138] Extract page element information and information related to simulation operations from the script and generate a configuration file;

[0139] Generate test cases using configuration files;

[0140] Use test cases to test web pages.

[0141] The computer-readable storage medium provided by the embodiment of the present invention, after obtaining the script generated after the simulated operation on the Web page to be tested, extracts the script page element information and the information related to the script and the simulated operation from the script, and generates a configuration file, and then uses the configuration file to generate a test case, so as to use the test case to test the script Web page. It can be seen that, by applying the embodiment of the present invention, since the configuration file used to generate the test case contains the script page element information and the information related to the simulated operation, there is no need to manually check the page element information carried in the script, and therefore there is no need to manually generate the test case based on the page element information, which improves the testing efficiency of the Web page and is more suitable for application scenarios that require a large number of test cases.

[0142] The embodiment of the present invention also provides a computer program product comprising instructions, which, when executed on a computer, causes the computer to perform the following steps:

[0143] Obtaining a script generated after simulating the operation on the Web page to be tested, the script carrying: page element information of the Web page to be tested and information related to the simulation operation;

[0144] Extract page element information and information related to simulation operations from the script and generate a configuration file;

[0145] Generate test cases using configuration files;

[0146] Use test cases to test web pages.

[0147] The computer program product containing instructions provided by the embodiment of the present invention, after obtaining the script generated after the simulated operation on the Web page to be tested, extracts the script page element information and the information related to the script and the simulated operation from the script, and generates a configuration file, and then generates a test case using the configuration file, so as to test the script Web page using the test case. It can be seen that, by applying the embodiment of the present invention, since the configuration file used to generate the test case contains the script page element information and the information related to the simulated operation, there is no need to manually check the page element information carried in the script, and thus there is no need to manually generate the test case based on the page element information, which improves the testing efficiency of the Web page and is more suitable for application scenarios that require a large number of test cases.

[0148] The embodiment of the present invention further provides a computer program, which, when executed on a computer, causes the computer to execute the following steps:

[0149] Obtaining a script generated after simulating the operation on the Web page to be tested, the script carrying: page element information of the Web page to be tested and information related to the simulation operation;

[0150] Extract page element information and information related to simulation operations from the script and generate a configuration file;

[0151] Generate test cases using configuration files;

[0152] Use test cases to test web pages.

[0153] The computer program including instructions provided by the embodiment of the present invention, after obtaining the script generated after the simulated operation on the Web page to be tested, extracts the script page element information and the information related to the script and the simulated operation from the script, and generates a configuration file, and then generates a test case using the configuration file, so as to test the script Web page using the test case. It can be seen that, by applying the embodiment of the present invention, since the configuration file used to generate the test case contains the script page element information and the information related to the simulated operation, there is no need to manually check the page element information carried in the script, and therefore there is no need to manually generate the test case based on the page element information, which improves the testing efficiency of the Web page and is more suitable for application scenarios requiring a large number of test cases.

[0154] As for the device / electronic device / storage medium embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0155] It should be noted that, in this article, 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 any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0156] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0157] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A Web page testing method, characterized in that: The method comprises: Acquire a script generated after the simulated operation of the Web page to be tested, wherein the script carries: page element information of the Web page to be tested and information related to the simulated operation; Extracting the page element information and the information related to the simulation operation from the script, and generating a configuration file; Generate test cases using the configuration file; Testing the Web page using the test case; The step of extracting the page element information and the information related to the simulation operation from the script and generating a configuration file includes: Generate a configuration file using preset test case functional requirements, the extracted page element information, and the information related to the simulation operation, wherein the test case functional requirements include: instance backup requirements, instance creation requirements, instance restart requirements, instance configuration information change requirements, and instance process node addition requirements; the page element information includes: the name of the page element, the positioning method of the page element, and the location information of the page element on the Web page to be tested; and the information related to the simulation operation includes: the operation process information of the simulation operation and the input value of the simulation operation; or Using the preset test requirements of each functional module in the Web page to be tested, the extracted page element information, and the information related to the simulation operation, multiple configuration files are generated, and the functional modules include: an instance backup module, an instance creation module, an instance restart module, an instance configuration information change module, and an instance process node addition module.

2. The method according to claim 1, characterized in that The step of generating the test case using the configuration file comprises: A plurality of test cases are generated using the plurality of configuration files, wherein different test cases are used to test each functional module in the Web page to be tested.

3. The method according to claim 2, characterized in that The step of testing the Web page using the test case comprises: Each test case in the plurality of test cases is used to test the functional modules corresponding to each test case, and one test case corresponds to one functional module in the Web page to be tested.

4. The method according to claim 2, characterized in that: Before testing the Web page using the test case, the method further includes: Creating a test task for the test case, wherein the test task is used to test a current functional module, and the current functional module is any module of the Web page; Then the step of testing the Web page using the test case includes: Comparing the running data of the test task with the configuration data in the test case to obtain a comparison result; Based on the comparison result, it is determined whether the current functional module passes the test.

5. The method according to claim 4, characterized in that The step of judging whether the current functional module passes the test based on the comparison result includes: If the comparison result is consistent, it is determined that the current functional module passes the test; If the comparison result is inconsistent, it is determined that the current functional module has failed the test.

6. The method according to claim 1, characterized in that The step of obtaining the script generated after the simulated operation on the Web page to be tested includes: Performing simulation operations on the Web page to be tested; The simulation operation is recorded to obtain a script of the simulation operation.

7. A web page testing device, characterized in that: The device comprises: An acquisition module, used to acquire a script generated after a simulated operation on the Web page to be tested, wherein the script carries: page element information of the Web page to be tested and information related to the simulated operation; A first generating module, used for extracting the page element information and the information related to the simulation operation from the script, and generating a configuration file; A second generating module, used to generate a test case using the configuration file; A testing module, used to test the Web page using the test case; The first generating module is specifically used for: Generate a configuration file using preset test case functional requirements, the extracted page element information, and the information related to the simulation operation, wherein the test case functional requirements include: instance backup requirements, instance creation requirements, instance restart requirements, instance configuration information change requirements, and instance process node addition requirements; the page element information includes: the name of the page element, the positioning method of the page element, and the location information of the page element in the Web page to be tested; and the information related to the simulation operation includes: the operation process information of the simulation operation and the input value of the simulation operation; or Using the preset test requirements of each functional module in the Web page to be tested, the extracted page element information, and the information related to the simulation operation, multiple configuration files are generated, and the functional modules include: an instance backup module, an instance creation module, an instance restart module, an instance configuration information change module, and an instance process node addition module.

8. The device according to claim 7, characterized in that The second generating module is specifically used for: A plurality of test cases are generated using the plurality of configuration files, wherein different test cases are used to test each functional module in the Web page to be tested.

9. The device according to claim 8, characterized in that The test module is specifically used for: Each test case in the plurality of test cases is used to test the functional modules corresponding to each test case, and one test case corresponds to one functional module in the Web page to be tested.

10. The device according to claim 8, characterized in that The device also includes: A creation module, used for creating a test task of the test case, wherein the test task is used for testing a current functional module, and the current functional module is any module of the Web page; The test module is specifically used for: Comparing the running data of the test task with the configuration data in the test case to obtain a comparison result; Based on the comparison result, it is determined whether the current functional module passes the test.

11. The device according to claim 10, characterized in that The test module is specifically used for: If the comparison result is consistent, it is determined that the current functional module passes the test; If the comparison result is inconsistent, it is determined that the current functional module has failed the test.

12. The device according to claim 7, characterized in that The acquisition module comprises: A simulation submodule, used for performing simulation operations on the Web page to be tested; The recording submodule is used to record the simulation operation to obtain a script of the simulation operation.

13. An electronic device, characterized in that: The method comprises a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the method steps of the Web page testing method according to any one of claims 1 to 6.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of the Web page testing method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Test method and test system for WEB pages

    CN104679658A

  • Webpage test method and terminal

    CN105279076A