Web page testing method, device, electronic device and storage medium
By generating test addresses and using a headless browser to conduct web page testing, and automatically comparing page images, the high cost and false detection problems caused by manual inspection in the existing technology are solved, and efficient and accurate website testing is achieved.
Patent Information
- Application Number
- CN202111450103.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2041-11-30
AI Technical Summary
In the prior art, website testing requires a lot of manual inspection, resulting in huge workload, high time cost and prone to false inspection problems.
By generating the test address and using a headless browser for simulated access, the web page image is obtained and the preset image is compared, and it will automatically determine whether the web page has passed the test and avoid manual inspection.
Save a lot of labor and time costs, reduce the possibility of manual mis-checking, and improve the efficiency and accuracy of testing.
Smart Images

Figure CN114153729B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of software testing, and in particular to a web page testing method, device, electronic device and storage medium. Background Art
[0002] In the related art, website testing is usually implemented by manual inspection. The inspectors simulate the user's operation behavior and compare the response results with the expected results to obtain the test results. Since website testing requires a lot of regression testing, when inspectors manually inspect the website, the workload of the inspectors is huge and the time cost is high. Summary of the invention
[0003] The present disclosure provides a web page testing method, device, electronic device and storage medium to at least solve the problem of huge workload and high time cost when manually testing website performance in the related art. The technical solution of the present disclosure is as follows:
[0004] According to a first aspect of an embodiment of the present disclosure, a web page testing method is provided, comprising: concatenating at least one query parameter group with the address of a web page to be tested, respectively, to obtain at least one test address; the query parameter group comprises at least one query parameter and at least one query parameter value corresponding to the query parameter; performing a simulated access operation on the web page to be tested based on the at least one test address, and obtaining a page image of the test page opened during the simulated access operation; comparing the page image of the test page with a preset image to obtain a comparison result; and the comparison result is used to determine whether the web page to be tested passes the test.
[0005] Optionally, the method further includes: generating a query parameter value corresponding to at least one query parameter according to a generation rule corresponding to at least one query parameter; and determining at least one query parameter group according to at least one query parameter and the query parameter value corresponding to at least one query parameter.
[0006] Optionally, the comparing the page image of the test page with the preset image to obtain the comparison result includes: obtaining the similarity between the page image of the test page and the preset image, and determining the similarity as the comparison result.
[0007] Optionally, the method further includes: when the similarity is greater than or equal to a preset threshold, determining that the page to be tested passes the test.
[0008] Optionally, the above method further includes: generating an alarm message when the similarity is less than a preset threshold; the alarm message includes the address of the web page to be tested.
[0009] Optionally, the above method also includes: in the case that there is no blank area in the element placeholder area in the preset image, determining whether there is a blank area in the element placeholder area in the page image of the test page; the element placeholder area is the area corresponding to the web page element in the web page; comparing the page image of the test page with the preset image to obtain a comparison result, including: in the case that there is no blank area in the element placeholder area in the page image of the test page, comparing the page image of the test page with the preset image to obtain a comparison result.
[0010] Optionally, the method further includes: randomly determining at least one query parameter from parameters included in the web page to be tested.
[0011] Optionally, the above method also includes: based on the address of the web page to be tested, obtaining a page image set corresponding to the web page to be tested, and sending the access address of the page image set corresponding to the web page to be tested to the detection end; the page image set corresponding to the web page to be tested includes page images of each test page corresponding to the web page to be tested.
[0012] According to a second aspect of an embodiment of the present disclosure, a web page testing device is provided, including a processing unit, an acquisition unit and a determination unit; the processing unit is used to splice at least one query parameter group with the address of a web page to be tested, respectively, to obtain at least one test address; the query parameter group includes at least one query parameter and a query parameter value corresponding to at least one query parameter; the acquisition unit is used to perform a simulated access operation on the web page to be tested based on at least one test address, and obtain a page image of the test page opened during the simulated access operation; the determination unit is used to compare the page image of the test page with a preset image to obtain a comparison result; the comparison result is used to determine whether the web page to be tested passes the test.
[0013] Optionally, the web page testing device further includes a generating unit; the generating unit is used to generate a query parameter value corresponding to at least one query parameter according to a generating rule corresponding to at least one query parameter; the determining unit is further used to determine at least one query parameter group according to at least one query parameter and the query parameter value corresponding to at least one query parameter.
[0014] Optionally, the above-mentioned determination unit is specifically used to obtain the similarity between the page image of the test page and the preset image, and determine the similarity as the comparison result.
[0015] Optionally, the above-mentioned determination unit is further used to determine that the page to be tested passes the test when the similarity is greater than or equal to a preset threshold.
[0016] Optionally, the above-mentioned determination unit is also used to generate an alarm message when the similarity is less than a preset threshold; the alarm message includes the address of the web page to be tested.
[0017] Optionally, the above-mentioned web page testing device also includes a judgment unit; the judgment unit is used to judge whether there is a blank area in the element placeholder area in the page image of the test page when there is no blank area in the element placeholder area in the preset image; the element placeholder area is the area corresponding to the web page element in the web page; the determination unit is specifically used to compare the page image of the test page with the preset image to obtain a comparison result when there is no blank area in the element placeholder area in the page image of the test page.
[0018] Optionally, the above-mentioned determination unit is further used to randomly determine at least one query parameter from the parameters included in the web page to be tested.
[0019] Optionally, the above-mentioned web page testing device also includes a sending unit; the acquisition unit is also used to acquire a page image set corresponding to the web page to be tested based on the address of the web page to be tested; the page image set corresponding to the web page to be tested includes page images of each test page corresponding to the web page to be tested; the sending unit is used to send the access address of the page image set corresponding to the web page to be tested to the detection end.
[0020] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute instructions to implement the web page testing method provided in the first aspect.
[0021] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, the computer-readable storage medium comprising instructions; when the instructions are executed by a processor of an electronic device, the electronic device executes the web page testing method provided in the first aspect.
[0022] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided. The computer program product includes instructions. When the instructions are executed on a processor of an electronic device, the electronic device executes the web page testing method provided in the first aspect.
[0023] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: the present disclosure generates at least one test address through a query parameter group and the address of the web page to be tested, and obtains the page image of the test page opened during the simulated access operation by performing a simulated access operation on the web page to be tested based on the at least one test address; by comparing the page images of these test pages with the preset images, it can be determined whether the web page to be tested has passed the test according to the comparison result. Since the address corresponding to the test page can be automatically generated by the address of the web page to be tested in combination with the query parameters, and the corresponding simulated access operation is performed, there is no need to rely on manual methods to test the web pages to be tested one by one, avoiding the manual inspection method, and thus can save a lot of manpower costs and time costs.
[0024] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0026] Figure 1 It is a schematic diagram of the architecture of an implementation environment according to an exemplary embodiment.
[0027] Figure 2 This is one of the flowchart diagrams of a web page testing method according to an exemplary embodiment.
[0028] Figure 3 This is a second flowchart of a web page testing method according to an exemplary embodiment.
[0029] Figure 4 This is a third flowchart of a web page testing method according to an exemplary embodiment.
[0030] Figure 5 The figure is a schematic diagram of an element placeholder area of a web page to be tested according to an exemplary embodiment.
[0031] Figure 6 This is a fourth flowchart of a web page testing method according to an exemplary embodiment.
[0032] Figure 7 This is a fifth flowchart of a web page testing method according to an exemplary embodiment.
[0033] Figure 8 The figure is a schematic diagram showing the structure of a web page testing device according to an exemplary embodiment.
[0034] Fig. 9 The diagram is a schematic structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0035] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0036] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0037] In the related art, the performance test of a website usually requires manual determination of a large number of test cases and regression cases corresponding to the test cases, and then determines the performance of the website and whether it is running normally by combining these test cases with the corresponding regression cases. Since the website test may involve multiple test pages, and each test page requires a large amount of test data, or periodic testing, when relying on manual methods to test the website performance, a lot of manpower may be wasted and it takes a long time. In addition, this testing method may cause the possibility of false detection due to the mistakes of the inspection personnel.
[0038] In response to the above problems, an embodiment of the present disclosure provides a web page testing method, which generates multiple test addresses through a query parameter group and the address of the web page to be tested, and opens the test pages corresponding to these test addresses through a headless browser. By comparing the page images of these test pages with the corresponding preset images, it can be determined whether the test page has an abnormality. If the page image of the test page is the same as the corresponding preset image, it can be determined that the test page has no abnormality, that is, it has passed the test. Since the test address corresponding to the test page here can be automatically generated by the address of the web page to be tested in combination with the query parameter group, and the headless browser is used to open the test page and obtain the page image, there is no need to rely on manual methods to test the web pages to be tested one by one, avoiding the method of manual inspection, so it can save a lot of manpower costs and time costs. And because the web page testing method provided by the present disclosure can be implemented by electronic equipment, avoiding human participation, the possibility of manual misdetection can be avoided.
[0039] Figure 1 is an architecture diagram of an implementation environment according to an exemplary embodiment. Figure 1 As shown, the following webpage testing method can be applied in the implementation environment. The implementation environment includes a terminal 01 and an electronic device 02. The terminal 01 can establish a communication connection with the electronic device 02.
[0040] In an practicable manner, the electronic device 02 may be a server, a server cluster consisting of multiple servers, or a cloud computing service center. The electronic device 02 may include a processor, a memory, a network interface, and the like.
[0041] In an operative manner, the terminal 01 is used to provide voice and / or data connectivity services to the user. The terminal 01 may have different names, such as UE, end, terminal unit, terminal station, mobile station, mobile station, remote station, remote terminal, mobile device, wireless communication device, vehicle user equipment, terminal agent or terminal device, etc.
[0042] Optionally, the terminal 01 may be any handheld device, vehicle-mounted device, wearable device, or computer with communication functions, which is not limited in the embodiments of the present disclosure. For example, the handheld device may be a smart phone. The vehicle-mounted device may be a vehicle-mounted navigation system. The wearable device may be a smart bracelet. The computer may be a personal digital assistant (PDA), a tablet computer, or a laptop computer.
[0043] Those skilled in the art should understand that the above terminals are only examples, and other existing or future terminals, if applicable to the present disclosure, should also be included in the protection scope of the present disclosure and are included here by reference.
[0044] Based on the above implementation environment, the specific implementation process of the web page testing method provided by the embodiment of the present disclosure is as follows:
[0045] The web page testing method provided by the embodiment of the present disclosure is exemplarily described below in conjunction with the accompanying drawings.
[0046] Figure 2 is a flow chart of a web page testing method according to an exemplary embodiment. Figure 2 As shown, the web page testing method can be applied to the above-mentioned terminal or electronic device, and the method includes the following S11 to S13.
[0047] S11. The electronic device concatenates at least one query parameter group with the address of the web page to be tested to obtain at least one test address.
[0048] The query parameter group includes at least one query parameter and a query parameter value corresponding to at least one query parameter.
[0049] As a possible implementation, the address of the web page to be tested is a uniform resource locator (URL), such as the format of the address can be protocol: / / hostname / path, where protocol refers to the transmission protocol used by the web page to be tested, such as hypertext transfer protocol (HTTP), hypertext transfer protocol over secure socket layer (HTTPS), etc. Hostname refers to the host name of the web page to be tested, which is used to indicate the domain name system of the server storing resources. Path is used to indicate a directory or file address on the host.
[0050] The above-mentioned query parameters are the transmission parameters of the dynamic URL, which are used to indicate the acquisition of data corresponding to the query parameters. For example, the query parameter can be a user ID, or a product ID, etc. When the query parameter is a user ID, the corresponding dynamic URL can be used to obtain user information corresponding to the user ID. When the query parameter is a product ID, the corresponding dynamic URL can be used to obtain product information corresponding to the product ID. When a dynamic URL is used to build a corresponding website, the data of the website is stored in a database. At this time, the dynamic URL is used to obtain the corresponding data in the database, such as user information, product information, etc.
[0051] In some possible implementations, the above multiple query parameters can be combined to form a query parameter group to query data corresponding to more specific parameters. For example, the query parameter group can include a user ID and a product ID, and the dynamic URL corresponding to the query parameter group is used to obtain product information corresponding to the user ID.
[0052] The above test address is a dynamic URL. For example, if the address is protocol: / / hostname / path, and the query parameter group includes a user ID and a product ID, then the query parameter group is concatenated with the address, and the obtained test address can be protocol: / / hostname / path?userId=10000065&itemId=10000005321. Among them, userId is the user ID, and 10000065 is the query parameter value corresponding to the user ID. itemId is the product ID, and 10000005321 is the query parameter value corresponding to the product ID. The query parameter group here is only exemplary. In practice, the query parameter group can include more query parameters, which can be combined to indicate the acquisition of different website data.
[0053] It should be noted that the address and the query parameter group are separated by "?", and different query parameters in the query parameter group are separated by "&".
[0054] Exemplarily, the query parameters corresponding to the web page to be tested may include a first query parameter, a second query parameter, a third query parameter, a fourth query parameter, and a fifth query parameter, and these query parameters may indicate obtaining different data. At this time, the first query parameter group may include the first query parameter and the second query parameter, the second query parameter group may include the first query parameter, the third query parameter, and the fourth query parameter, the third query parameter group may include the second query parameter and the fifth query parameter, etc. Of course, the query parameter group may also include other query parameter combinations, which are not limited here.
[0055] Here, the first query parameter group and the address can be concatenated to obtain the first test address, the second query parameter group and the address can be concatenated to obtain the second test address, and the third query parameter group and the address can be concatenated to obtain the third test address.
[0056] When determining a query parameter group based on query parameters, the query parameters in the query parameter group have a certain association relationship. When querying product information, the query parameters corresponding to the product include product identification parameters, inventory information parameters, and distribution information parameters. In this case, the product identification parameters, inventory information parameters, and distribution information parameters can be combined to determine a query parameter group. When there is no association relationship between query parameters, these query parameters are not suitable for being added to the same query parameter group.
[0057] In the present disclosure, the concatenation of the query parameter group and the address can be implemented by a program script. For example, the address and the query parameter are built into the program script, and the script can determine the query parameter group according to the association between different query parameters, and then concatenate the query parameter group to the address.
[0058] S12: The electronic device performs a simulated access operation on the web page to be tested based on at least one test address, and obtains a page image of the test page opened during the simulated access operation.
[0059] As a possible implementation manner, the electronic device opens a test page corresponding to at least one test address through a headless browser, and obtains a page image of the test page opened during the simulated access operation.
[0060] It should be noted that a headless browser refers to a browser without a user graphical interface. The functions of a headless browser are the same as those of a normal browser.
[0061] The test address determined by S11 above is the dynamic URL corresponding to the web page to be tested, and the test page corresponding to the test address can be opened through a headless browser. The test page here refers to the page when the web page to be tested displays different data. For example, the test address determined by S11 includes a first test address, a second test address, and a third test address. The first test page corresponding to the first test address, the second test page corresponding to the second test address, and the third test page corresponding to the third test address can be opened through a headless browser. The test addresses corresponding to these test pages may only include different query parameter groups, so these test pages actually refer to displaying different data in the web page to be tested, such as displaying user information or product information.
[0062] After the headless browser opens the test page corresponding to the test address, it can take a screenshot of the opened test page to obtain the page image of the test page. For example, the test page includes a first test page, a second test page and a third test page, then the page images of the first test page, the second test page and the third test page can be taken here respectively.
[0063] In a possible implementation, the page image of the test page can be a screenshot of the entire web page of the test page, or it can be a screenshot of each page area of the test page. For example, the test page can be divided into an upper area and a lower area, or divided into a left area or a right area, etc., in which case these sub-areas can be screenshotted separately, such as the upper area and the lower area of the test page. The screenshot of the test page is not limited to the above method, and those skilled in the art can set the screenshot method as needed. For example, the present disclosure adopts a method of taking a screenshot of the entire web page of the test page.
[0064] Here, opening the test page corresponding to the test address through a headless browser and taking a screenshot of the test page can be realized by the above-mentioned headless browser. Since the program script can realize the splicing of the test address, after obtaining the test address, the program script can call the headless browser to open the test page corresponding to the test address. After opening the test page, the headless browser can take a screenshot of the opened test page.
[0065] It should be noted that before opening the test page corresponding to the test address through the headless browser, the test environment, page type, page image type and other information of the headless browser can be set in advance. The specific details are the same as the conventional technical means in this field and will not be repeated here.
[0066] S13, the electronic device compares the page image of the test page with the preset image to obtain a comparison result
[0067] The comparison result is used to determine whether the web page to be tested passes the test.
[0068] As a possible implementation method, the preset image can be a page image of an expected page that is displayed without abnormality by the website maintenance personnel when building the web page to be tested. Corresponding to the test page, the expected page also includes multiple pages. For example, the test page includes a first test page, a second test page, and a third test page, then the expected page includes a first expected page, a second expected page, and a third expected page, wherein the first test page corresponds to the first expected page, the second test page corresponds to the second expected page, and the third test page corresponds to the third expected page. Correspondingly, at this time, the page image of the test page includes the page image of the first test page, the page image of the second test page, and the page image of the third test page, and the preset image includes the page image of the first expected page, the page image of the second expected page, and the page image of the third expected page.
[0069] Since the preset image is predetermined, after the page image of the test page is determined in S12, the page image of the test page can be compared with the corresponding preset image, such as comparing the page image of the first test page with the page image of the first expected page, comparing the page image of the second test page with the page image of the second expected page, and comparing the page image of the third test page with the page image of the third expected page.
[0070] Exemplarily, the comparison results may include comparison results of the page image of the first test page with the page image of the first expected page, comparison results of the page image of the second test page with the page image of the second expected page, and comparison results of the page image of the third test page with the page image of the third expected page.
[0071] In a possible implementation, when comparing the page image of the test page with the corresponding preset image, if the page image of any test page is inconsistent with the corresponding preset image, it can be determined that there is an abnormality in the tested web page and the test of the tested web page cannot be passed.
[0072] When the page image of the test page is consistent with the corresponding preset image, the electronic device determines that the web page to be tested passes the test.
[0073] It can be understood that when the page image of the first test page is consistent with the page image of the first expected page, the page image of the second test page is consistent with the page image of the second expected page, and the page image of the third test page is consistent with the page image of the third expected page, it can be determined that there is no abnormality in the web page to be tested, and the test of the web page to be tested can be passed.
[0074] The technical solution provided by the above embodiment has at least the following beneficial effects: the present disclosure generates at least one test address through a query parameter group and the address of the web page to be tested, and obtains the page image of the test page opened during the simulated access operation by performing a simulated access operation on the web page to be tested based on the at least one test address. By comparing the page images of these test pages with the preset images, it can be determined whether the web page to be tested has passed the test based on the comparison results. Since the address corresponding to the test page here can be automatically generated by the address of the web page to be tested in combination with the query parameters, and the corresponding simulated access operation is performed, in this way, there is no need to rely on manual methods to test the web pages to be tested one by one, avoiding the manual inspection method, and thus can save a lot of manpower costs and time costs.
[0075] In one practicable manner, combining Figure 2 ,like Figure 3 As shown, before step S11, steps S10a-S10b are also included.
[0076] S10a: The electronic device generates a query parameter value corresponding to at least one query parameter according to a generation rule corresponding to at least one query parameter.
[0077] As a possible implementation manner, the dynamic URL corresponding to the web page to be tested may include multiple query parameters, and the query parameter values corresponding to these query parameters may be determined according to certain generation rules.
[0078] S10b: The electronic device determines at least one query parameter group according to at least one query parameter and a query parameter value corresponding to the at least one query parameter.
[0079] Exemplarily, the query parameters include a first query parameter, a second query parameter, and a third query parameter. The query parameter values corresponding to these query parameters may be fixed or may be numbers that vary within a certain range. For example, the first query parameter may be a user identifier, and the second query parameter may be a product identifier. In this case, the generation rules of the first query parameter and the second query parameter may be incremented from 1 in sequence, and the query parameter value corresponding to the first query parameter may be a 6-digit number, and the query parameter value corresponding to the second query parameter may be an 8-digit number. The third query parameter may be a distribution identifier, which is used to indicate whether the corresponding product is distributed. For example, when the third query parameter is 0, it indicates that the corresponding product is not distributed. When the third query parameter is 1, it indicates that the corresponding product is distributed.
[0080] Here, a large number of query parameter pairs can be generated according to the generation rules corresponding to the query parameters, and the query parameter pairs include query parameters and query parameter values corresponding to the query parameters. For query parameters, a large number of query parameter values corresponding to the query parameters can be generated according to the generation rules corresponding to the query parameters. At this time, multiple query parameter groups can be determined respectively according to the large number of query parameter values corresponding to the query parameters.
[0081] Exemplarily, according to the generation rule corresponding to the first query parameter, the first query parameter value 1, the first query parameter value 2, the first query parameter value 3, ..., the first query parameter value n can be generated. According to the generation rule corresponding to the second query parameter, the second query parameter value 1, the second query parameter value 2, the second query parameter value 3, ..., the second query parameter value m can be generated. According to the generation rule corresponding to the third query parameter, the third query parameter value 1 and the third query parameter value 2 can be generated. At this time, the query parameter pair can be the first query parameter and the first query parameter value 1, or the first query parameter and the first query parameter value 2, or the second query parameter and the second query parameter value 1, and so on.
[0082] Further, after determining a plurality of query parameter pairs, these query parameter pairs may be combined to determine a query parameter group. For example, the first query parameter pair 1 includes the first query parameter and the first query parameter value 1, the first query parameter pair 2 includes the first query parameter and the first query parameter value 2, the second query parameter pair 1 includes the second query parameter and the second query parameter value 1, and the second query parameter pair 2 includes the second query parameter and the second query parameter value 2. In this case, the query parameter group may include the first query parameter pair 1 and the second query parameter pair 1, or the first query parameter pair 1 and the second query parameter pair 2, or the first query parameter pair 2 and the second query parameter pair 1, etc.
[0083] Different test pages can be obtained according to the query parameter groups determined above, thereby implementing the test of all test pages corresponding to the web page to be tested.
[0084] Similarly, the query parameter values corresponding to the query parameters here can be determined by the program script according to the generation rule. After the query parameter values corresponding to the query parameters are determined, the query parameter group can also be determined according to the association relationship between different query parameters.
[0085] It should be noted that the association relationship between different query parameters can be preset, for example, the first query parameter is associated with the second query parameter and the third query parameter. In this case, the first query parameter, the second query parameter and the third query parameter can be combined to determine a query parameter group.
[0086] The technical solution provided by the above-mentioned embodiment has at least the following beneficial effects: the present disclosure can automatically generate multiple query parameter pairs according to the query parameters of the web page to be tested and the generation rules of the query parameter values corresponding to the query parameters, and determine the query parameter group according to the association relationship between different query parameters, and then determine the dynamic URL corresponding to the web page to be tested, and provide a test address for the headless browser to test the test page. Since the test address is automatically generated by the query parameters and the generation rules corresponding to the query parameters, the process of manually inputting the test address is avoided, which saves a lot of manpower costs. And compared with manual efficiency, the efficiency of automatically generating the query parameter group here is higher, which saves a lot of time costs.
[0087] In one design, the webpage testing method provided by the embodiment of the present disclosure may further include SS10c before the above S10a:
[0088] S10c: The electronic device randomly determines at least one query parameter from the parameters included in the web page to be tested.
[0089] As a possible implementation manner, the electronic device may migrate and obtain parameters included in the web page to be tested, and randomly select one or more parameters from the parameters included in the web page to be tested as the at least one query parameter.
[0090] The technical solution provided by the above embodiment has at least the following beneficial effects: by using at least one randomly determined query parameter to generate the address of the test page, the test page for simulated access can also be randomly determined, which can further improve the accuracy of the comparison result of the web page to be tested.
[0091] In one practicable manner, combining Figure 2 ,like Figure 4 As shown, S13 provided in the embodiment of the present disclosure specifically includes the following S21-S22.
[0092] S21. The electronic device determines the similarity between the page image of the test page and a preset image.
[0093] As a possible implementation manner, the similarity between the page image of the test page and the corresponding preset image can be determined based on the OpenCV icon recognition technology, or based on a pre-trained machine learning model.
[0094] Exemplarily, the similarity between the page image of the test page and the corresponding preset image can be identified based on the OpenCV icon recognition technology. When the page image of the test page includes the page image of the first test page, the page image of the second test page, and the page image of the third test page, the first similarity between the page image of the first test page and the page image of the corresponding first expected page, the second similarity between the page image of the second test page and the page image of the corresponding second expected page, and the third similarity between the page image of the third test page and the page image of the corresponding third expected page can be determined respectively by the OpenCV icon recognition technology.
[0095] S22. The electronic device determines the similarity as a comparison result.
[0096] Exemplarily, the electronic device determines the first similarity, the second similarity and the third similarity as the comparison result.
[0097] The technical solution provided by the above-mentioned embodiments has at least the following beneficial effects: the present disclosure tests the similarity between the page image of the test page and the corresponding preset image, and determines the similarity as the comparison result, thereby eliminating the need for manual inspection and avoiding the large amount of manpower and time costs that may be incurred when manually checking the page image of the test page.
[0098] In one design, the web page testing method provided by the embodiment of the present disclosure further includes the following S23 and S24 after S22.
[0099] S23: When the similarity is greater than or equal to the threshold, the electronic device determines that the page to be tested passes the test.
[0100] Exemplarily, when the electronic device determines that the first similarity, the second similarity and the third similarity are all greater than or equal to a preset threshold, it can be determined that the page image of the test page is consistent with the corresponding preset image. The preset threshold here can be 90% or 95%.
[0101] It should be noted that the above-mentioned preset threshold value can be set in advance in the electronic device by operation and maintenance personnel.
[0102] The technical solution provided by the above embodiment has at least the following beneficial effects: by comparing the similarity with the preset threshold, a specific implementation method for determining whether the web page to be tested passes the test can be provided.
[0103] S24: When the similarity is less than a preset threshold, the electronic device generates an alarm message.
[0104] The warning information includes the address of the web page to be tested. The warning information is used to indicate that the web page to be tested has not passed the test.
[0105] Exemplarily, when the electronic device determines that any one of the first similarity, the second similarity, and the third similarity is less than the above-mentioned preset threshold, it can be determined that the page image of the test page is inconsistent with the corresponding preset image, and then it is determined that the web page to be tested has failed the test. In this case, the electronic device generates an alarm message and sends the alarm message externally.
[0106] It should be noted that the difference between the page image of the test page and the corresponding preset image may be caused by the difference in the corresponding page image screenshots, such as the page image area of the test page is different from the page image area of the expected page. When the web page to be tested includes multiple test pages, these test pages need to be compared with the preset images for comparison one by one.
[0107] The technical solution provided by the above embodiment has at least the following beneficial effects: when the web page to be tested fails the test, a specific implementation method can be provided to promptly remind the operation and maintenance personnel to handle the problem.
[0108] In one practicable manner, the element placeholder area in the preset image can be as follows: Figure 5 As shown, the element placeholder area includes a first element placeholder area, a second element placeholder area, and a third element placeholder area, etc., and these element placeholder areas are used to fill web page elements, such as text, pictures, etc. Therefore, there is no blank area in the element placeholder area in the preset image. The element placeholder area refers to the area corresponding to each web page element in the web page to be tested, such as the area position occupied by the text element in the web page to be tested, the area position occupied by the picture element in the web page to be tested, etc.
[0109] In one practicable manner, combining Figure 2 ,like Figure 6 As shown, after step S12, the following S14 is also included.
[0110] S14: When there is no blank area in the element placeholder area in the preset image, the electronic device determines whether there is a blank area in the element placeholder area in the page image of the test page.
[0111] The element placeholder area is the area corresponding to the web page element in the web page.
[0112] In this case, S13 provided in the embodiment of the present disclosure may specifically include the following S131.
[0113] S131 . When there is no blank area in the element placeholder area in the page image of the test page, the electronic device compares the page image of the test page with a preset image to obtain a comparison result.
[0114] As a possible implementation, the web page to be tested may include multiple page elements, and these page elements may be distributed in different element placeholder areas of the web page to be tested, so a normal web page to be tested does not have a blank area. Therefore, by determining whether there is a blank area in the element placeholder area in the page image of the test page, and when there is no blank area in the element placeholder area in the page image of the test page, the page image of the test page is compared with the preset image to obtain a comparison result.
[0115] For example, corresponding to the web page to be tested, the element placeholder area of the test page is the same as the element placeholder area of the web page to be tested. For example, the test page includes a first element placeholder area, a second element placeholder area, a third element placeholder area, ..., an xth element placeholder area. At this time, the blank areas of each element placeholder area in the test page can also be identified through OpenCV icon recognition technology or a pre-trained machine learning model.
[0116] Correspondingly, when there are multiple test pages, it is also necessary to determine whether there are blank areas on these test pages one by one, and then determine whether the page images of these test pages continue to perform subsequent comparison actions.
[0117] In another case, if the electronic device determines that there is a blank area in the element placeholder area within the page image of the test page, it can directly determine that the page image of the test page is inconsistent with the corresponding preset image, and then determine that the web page to be tested has failed the test.
[0118] The technical solution provided by the above embodiment has at least the following beneficial effects: the present disclosure determines whether to continue to perform subsequent comparison actions by testing whether there is a blank area on the page. On the one hand, when there is a blank area in the element placeholder area in the page image of the test page, it can directly determine that the web page to be tested has not passed the test, saving the computing resources of the electronic device. On the other hand, when there is no blank area in the element placeholder area in the page image of the test page, the page image of the test page is compared with the preset image to obtain a comparison result, which can ensure the validity of the subsequent determination of the comparison result.
[0119] In one practicable manner, Figure 7 As shown, after the page image of the test page is determined in step S12, the web page testing method provided by the embodiment of the present disclosure may further include the following S15-S16.
[0120] S15. The electronic device obtains a set of page images corresponding to the web page to be tested based on the address of the web page to be tested.
[0121] The page image set corresponding to the web page to be tested includes page images of each test page corresponding to the web page to be tested.
[0122] As a possible implementation method, the electronic device can classify the page images of these test pages according to the addresses in the corresponding test addresses to store the page images of these test pages in different folders. For example, the first test address corresponding to the first test page is protocol: / / hostname / path?userId=10000065&itemId=10000005321, and the second test address corresponding to the second test page is protocol: / / hostname / path?userId=10003165&itemId=10000405521. Since the addresses in the first test address and the second test address are both protocol: / / hostname / path, the page image of the first test page and the page image of the second test page can be stored in the same folder. For another example, the third test address corresponding to the third test page is protocol: / / hostname / path1? userId=10000315&itemId=10000205341. At this time, since the address in the third test address is protocol: / / hostname / path1, which is different from the addresses in the first test address and the second test address, the page image of the third test page can be stored in another folder.
[0123] It should be noted that when establishing folders for storing page images of test pages, these folders can be named with increasing numbers, such as increasing the folder name from 1. Of course, the present disclosure names the folders as addresses within the corresponding test addresses. For example, the address of the test page corresponding to the page image stored in the folder is protocol: / / hostname / path, and the folder can be named protocol: / / hostname / path. This method of naming folders by address makes it easy for inspection personnel to quickly determine the data corresponding to the abnormal page images therein. When uploading folders to the cloud, in order to achieve the overall upload of page images, these folders need to be packaged and compressed, and the name of the compressed file is the same as the name of the corresponding folder.
[0124] S16. The electronic device sends the access address of the page image set corresponding to the web page to be tested to the detection end.
[0125] As a possible implementation method, after the electronic device stores the page image sets of all the test pages in different folders in turn, it can upload these files to the cloud, and then obtain the access address of the page image set corresponding to the web page to be tested. Further, the electronic device sends the access address of the page image set corresponding to the web page to be tested to the detection end.
[0126] It should be noted that uploading the file to the cloud here may be uploading to a cloud server or uploading to a content delivery network (CDN), etc., which is not limited here.
[0127] In one possible implementation, after uploading these compressed files to the cloud, the cloud can return the access address of the compressed file. For example, when uploading the compressed file to the CDN, the storage address of the compressed file in the CDN can be returned. The electronic device determines the received storage address as the access address. At this time, the present disclosure can also use manual inspection to check the test page. For example, the inspection personnel can use the access address in the detection terminal to download the compressed file from the CDN, and after decompression, check whether there is a blank area in the page image of each test page in the compressed file to determine whether there is an abnormality in the corresponding test page.
[0128] The technical solution provided by the above embodiment has at least the following beneficial effects: by downloading the compressed file by the inspector and checking the page images of each test page therein, the test page can be further checked, thereby avoiding possible errors and omissions when inspecting the test page through the script program and the headless browser, and improving the accuracy of the test of the web page to be tested. Of course, here, the web page to be tested can also be tested only through the above program script, or the inspector can check the page images in the compressed file to complete the test of the web page to be tested.
[0129] In one practicable manner, since the number of users of a website varies in different time periods, and different numbers of users may cause different problems in the operation of the website, a script program for web page testing may be run in real time every day, or periodically, to timely discover possible problems in the operation of the website.
[0130] Figure 8 is a schematic structural diagram of a web page testing device according to an exemplary embodiment. Figure 8 As shown, the web page testing device 30 includes a processing unit 301 , an acquiring unit 302 and a determining unit 303 .
[0131] The processing unit 301 is used to concatenate at least one query parameter group with the address of the web page to be tested to obtain at least one test address. The query parameter group includes at least one query parameter and a query parameter value corresponding to the at least one query parameter.
[0132] The acquisition unit 302 is used to perform a simulated access operation on the web page to be tested based on the at least one test address, and acquire a page image of the test page opened during the simulated access operation.
[0133] The determination unit 303 is used to compare the page image of the test page with a preset image to obtain a comparison result. The comparison result is used to determine whether the web page to be tested passes the test.
[0134] Optional, such as Figure 8 As shown, the web page testing device 30 provided in the embodiment of the present disclosure further includes a generating unit 304 .
[0135] The generating unit 304 is configured to generate a query parameter value corresponding to the at least one query parameter according to a generation rule corresponding to the at least one query parameter.
[0136] The determining unit 303 is further configured to determine the at least one query parameter group according to the at least one query parameter and a query parameter value corresponding to the at least one query parameter.
[0137] Optional, such as Figure 8 As shown, the determination unit 303 provided in the embodiment of the present disclosure is specifically used to obtain the similarity between the page image of the test page and the preset image, and determine the similarity as the comparison result.
[0138] Optional, such as Figure 8 As shown, the determination unit 303 provided in the embodiment of the present disclosure is further configured to determine that the page to be tested passes the test when the similarity is greater than or equal to a preset threshold.
[0139] Optional, such as Figure 8 As shown, the determination unit 303 provided in the embodiment of the present disclosure is further configured to generate warning information when the similarity is less than a preset threshold value. The warning information includes the address of the web page to be tested.
[0140] Optional, such as Figure 8 As shown, the web page testing device 30 provided by the embodiment of the present disclosure further includes a judgment unit 305 .
[0141] The judging unit 305 is used to judge whether there is a blank area in the element placeholder area in the page image of the test page when there is no blank area in the element placeholder area in the preset image. The element placeholder area is the area corresponding to the web page element in the web page.
[0142] The determining unit 303 is specifically configured to compare the page image of the test page with the preset image to obtain the comparison result when there is no blank area in the element placeholder area in the page image of the test page.
[0143] Optional, such as Figure 8As shown, the determination unit 303 provided in the embodiment of the present disclosure is further configured to randomly determine the at least one query parameter from the parameters included in the web page to be tested.
[0144] Optional, such as Figure 8 As shown, the web page testing device 30 provided in the embodiment of the present disclosure further includes a sending unit 306 .
[0145] The acquisition unit 302 is further configured to acquire a page image set corresponding to the web page to be tested based on the address of the web page to be tested. The page image set corresponding to the web page to be tested includes page images of each of the test pages corresponding to the web page to be tested.
[0146] The sending unit 306 is used to send the access address of the page image set corresponding to the web page to be tested to the detection end.
[0147] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0148] Fig. 9 4 is a schematic diagram of the structure of an electronic device 40 provided by the present disclosure. Fig. 9 The electronic device 40 may include at least one processor 401 and a memory 403 for storing executable instructions of the processor 401. The processor 401 is configured to execute the instructions in the memory 403 to implement the webpage testing method in the above embodiment.
[0149] As an example, combining Figure 8 The functions implemented by the address processing unit 301, the acquisition unit 302, the determination unit 303, the generation unit 304, the judgment unit 305 and the sending unit 306 in the web page testing device are similar to those implemented by the address processing unit 301, the acquisition unit 302, the determination unit 303, the generation unit 304, the judgment unit 305 and the sending unit 306 in the web page testing device. Fig. 9 The function of processor 401 in is the same.
[0150] In addition, the electronic device 40 may further include a communication bus 402 and at least one communication interface 404 .
[0151] Processor 401 may be a GPU, a microprocessing unit, an ASIC, or one or more integrated circuits for controlling the execution of the program of the disclosed solution.
[0152] Communication bus 402 may include a pathway for transmitting information between the above-mentioned components.
[0153] The communication interface 404 uses any transceiver or other device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.
[0154] The memory 403 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processing unit via a bus. The memory may also be integrated with the processing unit and be a volatile storage medium in the GPU.
[0155] The memory 403 is used to store instructions for executing the solution of the present disclosure, and the execution is controlled by the processor 401. The processor 401 is used to execute the instructions stored in the memory 403, so as to realize the functions in the method of the present disclosure.
[0156] In a specific implementation, as an embodiment, the processor 401 may include one or more GPUs, such as Fig. 9 GPU0 and GPU1 in .
[0157] In a specific implementation, as an embodiment, the electronic device 40 may include multiple processors, such as Fig. 9 401 and processor 407 in FIG. Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-GPU) processor. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0158] In a specific implementation, as an embodiment, the electronic device 40 may further include an output device 405 and an input device 406. The output device 405 communicates with the processor 401 and may display information in a variety of ways. For example, the output device 405 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. The input device 406 communicates with the processor 401 and may receive user input in a variety of ways. For example, the input device 406 may be a mouse, a keyboard, a touch screen device, or a sensor device.
[0159] Those skilled in the art will understand that Fig. 9 The structure shown in the figure does not constitute a limitation on the electronic device 40, and may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.
[0160] In addition, the present disclosure also provides a computer-readable storage medium, which includes instructions. When the instructions are executed by a processor of an electronic device, the electronic device executes the web page testing method provided in the above embodiment.
[0161] In addition, the present disclosure also provides a computer program product, which includes instructions. When the instructions are executed on a processor of an electronic device, the electronic device executes the web page testing method provided in the above embodiment.
[0162] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0163] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A web page testing method, characterized in that: include: Randomly determine at least one query parameter from the parameters included in the web page to be tested; splicing at least one query parameter group with the address of the web page to be tested respectively to obtain at least one test address; the query parameter group includes the at least one query parameter and the query parameter value corresponding to the at least one query parameter; Performing a simulated access operation on the web page to be tested based on the at least one test address, and acquiring a page image of the test page opened during the simulated access operation; The page image of the test page is compared with a preset image to obtain a comparison result; the comparison result is used to determine whether the web page to be tested passes the test.
2. The web page testing method according to claim 1, characterized in that: Also includes: generating a query parameter value corresponding to the at least one query parameter according to a generation rule corresponding to the at least one query parameter; The at least one query parameter group is determined according to the at least one query parameter and a query parameter value corresponding to the at least one query parameter.
3. The web page testing method according to claim 1 or 2, characterized in that: The step of comparing the page image of the test page with the preset image to obtain a comparison result includes: The similarity between the page image of the test page and the preset image is obtained, and the similarity is determined as the comparison result.
4. The web page testing method according to claim 3, characterized in that: The method further comprises: When the similarity is greater than or equal to a preset threshold, it is determined that the page to be tested passes the test.
5. The web page testing method according to claim 3, characterized in that: Also includes: When the similarity is less than a preset threshold, generating an alarm message; The warning information includes the address of the web page to be tested.
6. The web page testing method according to claim 1 or 2, characterized in that: The method further comprises: In the case that there is no blank area in the element placeholder area in the preset image, determining whether there is a blank area in the element placeholder area in the page image of the test page; the element placeholder area is the area corresponding to the web page element in the web page; The step of comparing the page image of the test page with the preset image to obtain a comparison result includes: When there is no blank area in the element placeholder area in the page image of the test page, the page image of the test page is compared with the preset image to obtain the comparison result.
7. The web page testing method according to claim 1 or 2, characterized in that: The method further comprises: Based on the address of the web page to be tested, a page image set corresponding to the web page to be tested is obtained, and the access address of the page image set corresponding to the web page to be tested is sent to the detection end; the page image set corresponding to the web page to be tested includes page images of each of the test pages corresponding to the web page to be tested.
8. A web page testing device, characterized in that: It includes a processing unit, an acquisition unit and a determination unit; The processing unit is used to concatenate at least one query parameter group with the address of the web page to be tested to obtain at least one test address; the query parameter group includes at least one query parameter and a query parameter value corresponding to the at least one query parameter; The acquisition unit is used to perform a simulated access operation on the web page to be tested based on the at least one test address, and acquire a page image of the test page opened during the simulated access operation; The determination unit is used to compare the page image of the test page with a preset image to obtain a comparison result; the comparison result is used to determine whether the web page to be tested passes the test; The determining unit is further configured to randomly determine the at least one query parameter from the parameters included in the web page to be tested.
9. The web page testing device according to claim 8, characterized in that: The web page testing device also includes a generating unit; The generating unit is configured to generate a query parameter value corresponding to the at least one query parameter according to a generating rule corresponding to the at least one query parameter; The determining unit is further configured to determine the at least one query parameter group according to the at least one query parameter and a query parameter value corresponding to the at least one query parameter.
10. The web page testing device according to claim 8 or 9, characterized in that: The determining unit is specifically configured to obtain a similarity between the page image of the test page and the preset image, and determine the similarity as the comparison result.
11. The web page testing device according to claim 10, characterized in that: The determining unit is further configured to determine that the page to be tested passes the test when the similarity is greater than or equal to a preset threshold.
12. The web page testing device according to claim 10, characterized in that: The determination unit is further configured to generate an alarm message when the similarity is less than a preset threshold; the alarm message includes the address of the web page to be tested.
13. The web page testing device according to claim 8 or 9, characterized in that: The web page testing device also includes a judgment unit; The judging unit is used to judge whether there is a blank area in the element placeholder area in the page image of the test page when there is no blank area in the element placeholder area in the preset image; the element placeholder area is the area corresponding to the web page element in the web page; The determining unit is specifically configured to compare the page image of the test page with the preset image to obtain the comparison result when there is no blank area in the element placeholder area within the page image of the test page.
14. The web page testing device according to claim 8 or 9, characterized in that: The web page testing device also includes a sending unit; The acquisition unit is further used to acquire a page image set corresponding to the web page to be tested based on the address of the web page to be tested; the page image set corresponding to the web page to be tested includes page images of each of the test pages corresponding to the web page to be tested; The sending unit is used to send the access address of the page image set corresponding to the web page to be tested to the detection end.
15. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the web page testing method according to any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes instructions; when the instructions are executed by a processor of an electronic device, the electronic device executes the web page testing method as described in any one of claims 1 to 7.
17. A computer program product, characterized in that The computer program product comprises instructions, and when the instructions are executed on a processor of an electronic device, the electronic device executes the web page testing method according to any one of claims 1 to 7.
