CN114153729A - Webpage testing method and device, electronic equipment and storage medium - Google Patents

Webpage testing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114153729A
CN114153729A CN202111450103.4A CN202111450103A CN114153729A CN 114153729 A CN114153729 A CN 114153729A CN 202111450103 A CN202111450103 A CN 202111450103A CN 114153729 A CN114153729 A CN 114153729A
Authority
CN
China
Prior art keywords
page
test
query parameter
webpage
image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111450103.4A
Other languages
Chinese (zh)
Inventor
李亚楠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202111450103.4A priority Critical patent/CN114153729A/en
Publication of CN114153729A publication Critical patent/CN114153729A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management

Abstract

The disclosure relates to a webpage testing method, a webpage testing device, electronic equipment and a storage medium, relates to the technical field of software testing, and at least solves the problems of huge workload and higher time cost when the performance of a website is manually tested in the related technology. The method comprises the following steps: splicing the at least one query parameter group with the address of the webpage to be tested respectively to obtain at least one test address; the query parameter group comprises at least one query parameter and a query parameter value corresponding to the at least one query parameter; executing simulated access operation on the webpage to be tested based on at least one test address, and acquiring a page image of a test page opened in the simulated access operation process; comparing the page image of the test page with a preset image to obtain a comparison result; and the comparison result is used for determining whether the webpage to be tested passes the test or not.

Description

Webpage testing method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of software testing technologies, and in particular, to a method and an apparatus for testing a web page, an electronic device, and a storage medium.
Background
In the related art, the testing of the website is usually realized by a manual inspection mode, and an inspector compares an obtained response result with an expected result by simulating the operation behavior of a user to obtain a testing result. Because the test of website needs a large amount of regression tests, when the website is patrolled by the patrolling personnel manually, the workload of the patrolling personnel is huge, and the required time cost is higher.
Disclosure of Invention
The disclosure provides a webpage testing method, a webpage testing device, electronic equipment and a storage medium, and aims to at least solve the problems of huge workload and high time cost when the performance of a website is manually tested in the related art. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, a method for testing a web page is provided, which includes: splicing the at least one query parameter group with the address of the webpage to be tested respectively to obtain at least one test address; the query parameter group comprises at least one query parameter and a query parameter value corresponding to the at least one query parameter; executing simulated access operation on the webpage to be tested based on at least one test address, and acquiring a page image of a test page opened in the simulated access operation process; comparing the page image of the test page with a preset image to obtain a comparison result; and the comparison result is used for determining whether the webpage to be tested passes the test or not.
Optionally, the method further includes: generating a query parameter value corresponding to at least one query parameter according to a generation rule corresponding to the at least one query parameter; and determining at least one query parameter group according to the at least one query parameter and the query parameter value corresponding to the at least one query parameter.
Optionally, the comparing the page image of the test page with the preset image to obtain a comparison result includes: and acquiring the similarity between the page image of the test page and a preset image, and determining the similarity as a comparison result.
Optionally, the method further includes: and determining that the page to be tested passes the test under the condition that the similarity is greater than or equal to the preset threshold value.
Optionally, the method further includes: generating alarm information under the condition that the similarity is smaller than a preset threshold value; the alarm information comprises the address of the webpage to be detected.
Optionally, the method further includes: under the condition that the element occupying area in the preset image does not have a blank area, judging whether the element occupying area in the page image of the test page has the blank area or not; the element occupying area is an area corresponding to the webpage element in the webpage; comparing the page image of the test page with a preset image to obtain a comparison result, wherein the comparison result comprises the following steps: and comparing the page image of the test page with a preset image to obtain a comparison result under the condition that no blank area exists in the element occupying area in the page image of the test page.
Optionally, the method further includes: and randomly determining at least one query parameter from the parameters included in the webpage to be tested.
Optionally, the method further includes: acquiring a page image set corresponding to the webpage to be detected based on the address of the webpage to be detected, and sending an access address of the page image set corresponding to the webpage to be detected to a detection end; the page image set corresponding to the webpage to be tested comprises page images of all test pages corresponding to the webpage to be tested.
According to a second aspect of the embodiments of the present disclosure, there is provided a web page testing apparatus, including a processing unit, an obtaining unit, and a determining unit; the processing unit is used for splicing the at least one query parameter group with the address of the webpage to be tested respectively to obtain at least one test address; the query parameter group comprises at least one query parameter and a query parameter value corresponding to the at least one query parameter; the acquisition unit is used for executing the simulated access operation on the webpage to be tested based on at least one test address and acquiring a page image of a test page opened in the process of the simulated access operation; the determining unit is used for comparing the page image of the test page with a preset image to obtain a comparison result; and the comparison result is used for determining whether the webpage to be tested passes the test or not.
Optionally, the web page testing apparatus further includes a generating unit; the generating unit is used for generating a query parameter value corresponding to 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 at least one query parameter group according to the at least one query parameter and the query parameter value corresponding to the at least one query parameter.
Optionally, the determining unit is specifically configured to obtain a similarity between a page image of the test page and a preset image, and determine the similarity as a comparison result.
Optionally, 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.
Optionally, the determining unit is further configured to generate warning information when the similarity is smaller than a preset threshold; the alarm information comprises the address of the webpage to be detected.
Optionally, the web page testing apparatus further includes a determining unit; the judging unit is used for judging whether the element occupying area in the page image of the test page has a blank area or not under the condition that the blank area does not exist in the element occupying area in the preset image; the element occupying area is an area corresponding to the webpage element in the webpage; the determining unit is specifically configured to compare the page image of the test page with a preset image to obtain a comparison result under the condition that no blank area exists in the element occupying area in the page image of the test page.
Optionally, the determining unit is further configured to randomly determine at least one query parameter from parameters included in the webpage to be tested.
Optionally, the web page testing apparatus further includes a sending unit; the acquisition unit is also used for acquiring a page image set corresponding to the webpage to be detected based on the address of the webpage to be detected; the page image set corresponding to the webpage to be tested comprises page images of all test pages corresponding to the webpage to be tested; and the sending unit is used for sending the access address of the page image set corresponding to the webpage to be detected to the detection end.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the web page testing method as provided in the first aspect.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium comprising instructions; the instructions, when executed by a processor of an electronic device, cause the electronic device to perform a web page testing method as provided by the first aspect.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising instructions which, when run on a processor of an electronic device, cause the electronic device to perform the web page testing method as provided in the first aspect.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects: the method comprises the steps of generating at least one test address through a query parameter group and an address of a webpage to be tested, and acquiring a page image of a test page opened in the process of simulated access operation by executing simulated access operation on the webpage to be tested based on the at least one test address; through comparison of the page images of the test pages and the preset images, whether the to-be-tested web page passes the test or not can be judged according to the comparison result. The address corresponding to the test page can be automatically generated by combining the address of the webpage to be tested with the query parameter and executing corresponding simulated access operation, so that the webpage to be tested does not need to be tested one by means of a manual method, a manual inspection mode is avoided, and a large amount of labor cost and time cost can be saved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1 is an architectural diagram illustrating one implementation environment in accordance with an exemplary embodiment.
FIG. 2 is one of flow diagrams illustrating a method for web page testing according to an example embodiment.
Fig. 3 is a second flowchart illustrating a web page testing method according to an exemplary embodiment.
Fig. 4 is a third flowchart illustrating a web page testing method according to an exemplary embodiment.
FIG. 5 is a schematic diagram illustrating an element footprint of a web page to be tested, according to an example embodiment.
FIG. 6 is a fourth flowchart illustrating a method for testing a web page, according to an example embodiment.
FIG. 7 is a fifth flowchart illustrating a method for testing a web page, according to an example embodiment.
Fig. 8 is a schematic structural diagram illustrating a web page testing apparatus according to an exemplary embodiment.
Fig. 9 is a schematic structural diagram of an electronic device according to an exemplary embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
In the related art, generally, performance testing of a website needs to manually determine a large number of test cases and regression cases corresponding to the test cases, and the performance and the operation of the website are determined by combining the test cases and the corresponding regression cases. Because a plurality of test pages may be involved in the test of the website, and each test page requires a large amount of test data, or a periodic test, a lot of manpower may be wasted and time may be consumed when the website performance is tested manually. In addition, the testing mode can cause the possibility of false detection due to the error and the omission of the inspection personnel.
In view of the above problems, an embodiment of the present disclosure provides a web page testing method, which generates a plurality of test addresses by querying a parameter set and an address of a web page to be tested, and opens a test page corresponding to the test addresses through a headless browser. By comparing the page images of the test pages with the corresponding preset images, whether the test pages are abnormal or not can be determined. If the page image of the test page is the same as the corresponding preset image, it can be determined that the test page is not abnormal, that is, the test is passed. The test address corresponding to the test page can be automatically generated by combining the address of the webpage to be tested with the query parameter group, the test page is opened and the page image is acquired by the headless browser, the webpage to be tested is not required to be tested one by a manual method, and a manual inspection mode is avoided, so that a large amount of labor cost and time cost can be saved. And because the webpage testing method provided by the disclosure can be realized by electronic equipment, manual participation is avoided, and the possibility of manual false detection can be avoided.
FIG. 1 is an architecture diagram illustrating an implementation environment in which the following web page testing method may be applied, as shown in FIG. 1, according to an example embodiment. The implementation environment includes a terminal 01 and an electronic device 02. Wherein the terminal 01 can establish a communication connection with the electronic device 02.
In an implementation manner, the electronic device 02 may be a server, a server cluster composed of a plurality of servers, or a cloud computing service center. The electronic device 02 may include a processor, memory, and a network interface, among others.
In one implementable manner, terminal 01 is used to provide voice and/or data connectivity services to a user. Terminal 01 may have different names such as UE, terminal unit, terminal station, mobile station, remote terminal, mobile device, wireless communication device, vehicle user equipment, terminal agent, or terminal device, etc.
Optionally, the terminal 01 may be various handheld devices, vehicle-mounted devices, wearable devices, and computers with communication functions, which is not limited in this disclosure. For example, the handheld device may be a smartphone. The in-vehicle device may be an in-vehicle navigation system. The wearable device may be a smart bracelet. The computer may be a Personal Digital Assistant (PDA) computer, a tablet computer, and a laptop computer.
Those skilled in the art should appreciate that the above-described terminals are merely exemplary and that other existing or future terminals, which may be suitable for use with the present disclosure, are also encompassed within the scope of the present disclosure and are hereby incorporated by reference.
Based on the implementation environment, the webpage testing method provided by the embodiment of the disclosure is specifically implemented as follows:
the following describes an exemplary web page testing method provided by the embodiments of the present disclosure with reference to the drawings.
Fig. 2 is a flowchart illustrating a web page test method according to an exemplary embodiment, and as shown in fig. 2, the web page test method may be applied to the above-mentioned terminal or electronic device, and the method includes the following S11 to S13.
And S11, the electronic equipment splices the at least one query parameter group with the address of the webpage to be tested respectively to obtain at least one test address.
The query parameter group comprises at least one query parameter and a query parameter value corresponding to the at least one query parameter.
As a possible implementation manner, the address of the web page to be tested is a Uniform Resource Locator (URL), and for example, the format of the address may be protocol:// hostname/path, where the protocol refers to a transmission protocol used by the web page to be tested, and for example, the protocol may be a hypertext transfer protocol (HTTP), a hypertext transfer protocol over secure session protocol (HTTPs), or the like. The hostname refers to the host name of the web page to be tested and is used for indicating the domain name system of the server storing the resources. Path is used to indicate a directory or file address on the host.
The query parameter is a transfer parameter of the dynamic URL, and is used to instruct to acquire data corresponding to the query parameter. For example, the query parameter may be a user identifier, a product identifier, or the like. When the query parameter is the user identifier, the corresponding dynamic URL may be used to obtain user information corresponding to the user identifier. When the query parameter is the commodity identification, the corresponding dynamic URL may be used to obtain commodity information corresponding to the commodity identification. When a corresponding website is constructed by using the dynamic URL, the data of the website is stored in the database, and at this time, the dynamic URL is used for acquiring the corresponding data in the database, such as user information, commodity information, and the like.
In some possible implementations, the combination of the plurality of query parameters may be determined as a query parameter set to query data corresponding to more specific parameters. For example, the query parameter group may include a user identifier and a product identifier, where a dynamic URL corresponding to the query parameter group is used to obtain product information of a user corresponding to the user identifier.
The test address is a dynamic URL, for example, the address is protocol:// hostname/path, the query parameter group includes a user identifier and a commodity identifier, the query parameter group is concatenated with the address, and the obtained test address may be protocol:// hostname/pathuserId 10000065& itemld 10000005321. Wherein, userId is the user identifier, and 10000065 is the query parameter value corresponding to the user identifier. itemId is the commodity identification, and 10000005321 is the corresponding query parameter value of the commodity identification. The query parameter set is merely exemplary, and in practice, the query parameter set may include more query parameters, which together may indicate that different website data is to be obtained.
It should be noted that "? "separate, and the different query parameters in the set of query parameters are separated by" & ".
For example, the corresponding query parameters of 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, which may indicate that different data is to be obtained. 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, and so on. Of course, the query parameter set may also include other combinations of query parameters, and is not limited herein.
Here, the first query parameter set and the address may be respectively concatenated to obtain the first test address. And splicing the second query parameter group and the address to obtain a second test address. And splicing the third query parameter group and the address to obtain a third test address.
When the query parameter group is determined according to the query parameters, the query parameters in the query parameter group have a certain incidence relation, when the information of the commodity is queried, the query parameters corresponding to the commodity comprise a commodity identification parameter, an inventory information parameter and a distribution information parameter, and at the moment, the commodity identification parameter, the inventory information parameter and the distribution information parameter can be combined together to be determined as the query parameter group. When there is no correlation between the query parameters, the query parameters are not suitable for being added to the same query parameter group.
In the present disclosure, the concatenation of the query parameter set and the address may be implemented by a program script. For example, the address and the query parameter are embedded in a program script, and the script can determine the query parameter group according to the incidence relation between different query parameters, and then the query parameter group is spliced to the address.
S12, the electronic equipment executes the simulation access operation of the webpage to be tested based on the at least one test address, and obtains the page image of the test page opened in the simulation access operation process.
As a possible implementation manner, the electronic device opens a test page corresponding to at least one test address through the headless browser, and obtains a page image of the test page opened in the simulation access operation process.
It should be noted that the headless browser refers to a browser without a graphical user interface, and the function of the headless browser is the same as that of a common browser.
The test address determined in S11 is the dynamic URL corresponding to the web page to be tested, and the test page corresponding to the test address can be opened by the headless browser. The test page refers to a page when the web page to be tested displays different data, for example, the test address determined in S11 includes a first test address, a second test address, and a third test address, and 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 by the headless browser. The test addresses corresponding to the test pages may only include different sets of query parameters, and therefore the test pages actually refer to displaying different data in the web page to be tested, such as displaying user information or commodity information.
After the headless browser opens the test page corresponding to the test address, screenshot can be performed on the opened test page to obtain a page image of the test page. For example, the test pages include a first test page, a second test page, and a third test page, and here, page images of the first test page, the second test page, and the third test page may be respectively.
In a possible implementation manner, the page image of the test page may be obtained by performing screenshot on the entire web page of the test page, or by performing screenshot on the page areas of the test page, for example, the test page may be divided into an upper area and a lower area, or divided into a left area or a right area, and at this time, the screenshot may be performed on the sub-areas, for example, the screenshot may be performed on the upper area and the lower area of the test page. For the screenshot of the test page, the method is not limited to the above method, and a person skilled in the art can set the screenshot method as needed. For example, the present disclosure employs screenshots of an entire web page of a test page.
Here, the test page corresponding to the test address is opened through the headless browser, and the screenshot of the test page can be realized by the headless browser. The program script can realize the splicing of the test address, and after the test address is obtained, the program script can call the headless browser to open the test page corresponding to the test address. After the test page is opened, the headless browser realizes screenshot on the opened test page.
It should be noted that, before the test page corresponding to the test address is opened by the headless browser, information such as a test environment, a page type, and a page image type of the headless browser may be set in advance, which is the same as the conventional technical means in the field and is not described herein again.
S13, the electronic equipment compares the page image of the test page with the preset image to obtain a comparison result
And the comparison result is used for determining whether the webpage to be tested passes the test or not.
As a possible implementation manner, the preset image may be a page image of an expected page without abnormality displayed by a website maintainer when a to-be-detected page is built. The expected page also includes a plurality corresponding to the test page. For example, if the test page includes a first test page, a second test page, and a third test page, the expected page includes a first expected page, a second expected page, and a third expected page, where 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, the page image of the test page at this time includes a page image of a first test page, a page image of a second test page, and a page image of a third test page, and the preset image includes a page image of a first expected page, a page image of a second expected page, and a page image of a third expected page.
Since the preset image is predetermined, after the page image of the test page is determined at S12, the page image of the test page may be compared with the corresponding preset image. If the page image of the first test page is compared with the page image of the first expected page, the page image of the second test page is compared with the page image of the second expected page, and the page image of the third test page is compared with the page image of the third expected page.
For example, the comparison result may include a comparison result between the page image of the first test page and the page image of the first expected page, a comparison result between the page image of the second test page and the page image of the second expected page, and a comparison result between the page image of the third test page and the page image of the third expected page.
In a possible implementation manner, when the page image of the test page is compared with the corresponding preset image, if the page image of any one of the test pages is inconsistent with the corresponding preset image, it may be determined that the web page to be tested has an abnormality, and the test on the web page to be tested cannot be passed at this time.
And under the condition that the page image of the test page is consistent with the corresponding preset image, the electronic equipment determines that the to-be-tested page passes the test.
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 the web page to be tested is not abnormal, and at this time, the test on the web page to be tested can be passed.
The technical scheme provided by the embodiment at least has the following beneficial effects: the method comprises the steps of generating at least one test address through a query parameter group and an address of a webpage to be tested, and acquiring a page image of a test page opened in the process of simulated access operation by executing simulated access operation on the webpage to be tested based on the at least one test address. Through comparison of the page images of the test pages and the preset images, whether the to-be-tested web page passes the test or not can be judged according to the comparison result. The address corresponding to the test page can be automatically generated by combining the address of the webpage to be tested with the query parameter and executing corresponding simulated access operation, so that the webpage to be tested does not need to be tested one by means of a manual method, a manual inspection mode is avoided, and a large amount of labor cost and time cost can be saved.
In a practical manner, as shown in fig. 3 in conjunction with fig. 2, before step S11, S10a-S10b are further included.
S10a, the electronic device generates a query parameter value corresponding to at least one query parameter according to a generation rule corresponding to the at least one query parameter.
As a possible implementation manner, the dynamic URL corresponding to the web page to be tested may include a plurality of query parameters, and query parameter values corresponding to the query parameters may be determined according to a certain generation rule.
S10b, the electronic device determines at least one query parameter group according to the at least one query parameter and the query parameter value corresponding to the at least one query parameter.
Illustratively, the query parameters include a first query parameter, a second query parameter, and a third query parameter, and the values of the query parameters corresponding to these query parameters may be fixed or may be numbers that vary within a certain range. If the first query parameter may be a user identifier, the second query parameter may be a product identifier, at this time, the generation rules of the first query parameter and the second query parameter may be sequentially increased from 1, and the query parameter value corresponding to the first query parameter may be 6 digits, and the query parameter value corresponding to the second query parameter may be 8 digits. The third inquiry parameter may be a distribution identifier for indicating whether distribution of the corresponding item exists, for example, when the third inquiry parameter is 0, it indicates that distribution of the corresponding item does not exist. When the third query parameter is 1, it indicates that the corresponding item exists for distribution.
Here, a large number of query parameter pairs can be generated according to the generation rule corresponding to the query parameters, and the query parameter pairs include the query parameters and the query parameter values corresponding to the query parameters. For the query parameters, a large number of query parameter values corresponding to the query parameters can be generated according to the corresponding generation rules. At this time, a plurality of query parameter sets may be determined according to a large number of query parameter values corresponding to the query parameters.
Illustratively, the first query parameter value 1, the first query parameter value 2, the first query parameter value 3, …, and the first query parameter value n may be generated according to a generation rule corresponding to the first query parameter. According to the generation rule corresponding to the second query parameter, a second query parameter value 1, a second query parameter value 2, a second query parameter value 3, …, and a second query parameter value m may be generated. Third query parameter value 1 and third query parameter value 2 may be generated according to the generation rule corresponding to the third query parameter. In this case, the query parameter pair may be the first query parameter and the first query parameter value 1, or may be 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.
Further, after determining a plurality of query parameter pairs, the query parameter pairs may be combined to determine the set of query parameters. For example, the first query parameter pair 1 includes a first query parameter and a first query parameter value 1, the first query parameter pair 2 includes a first query parameter and a first query parameter value 2, the second query parameter pair 1 includes a second query parameter and a second query parameter value 1, and the second query parameter pair 2 includes a second query parameter and a second query parameter value 2, where 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, and so on.
According to the determined query parameter groups, different test pages can be obtained, and then all test pages corresponding to the web page to be tested are tested.
Similarly, the query parameter value corresponding to the query parameter may be determined by the program script according to the generation rule, and after the query parameter value corresponding to the query parameter is determined, the query parameter group may also be determined according to the association relationship between different query parameters.
It should be noted that the association relationship between different query parameters may be preset, for example, the first query parameter is associated with the second query parameter and the third query parameter, and at this time, the first query parameter, the second query parameter and the third query parameter may be combined to determine the query parameter group.
The technical scheme provided by the embodiment at least has the following beneficial effects: according to the method and the device, a plurality of query parameter pairs can be automatically generated according to the query parameters of the webpage to be tested and the generation rules of the query parameter values corresponding to the query parameters, the query parameter groups are determined according to the incidence relation among different query parameters, the dynamic URL corresponding to the webpage to be tested is further determined, and a test address is provided for the headless browser to test the test page. The test address is generated automatically by the query parameter and the generation rule corresponding to the query parameter, so that the process of manually inputting the test address is avoided, and a large amount of labor cost is saved. Compared with manual efficiency, the efficiency of automatically generating the query parameter set is higher, and a large amount of time cost is saved.
In one design, the web page testing method provided by the embodiment of the present disclosure, before the above S10a, may further include an SS10 c:
s10c, the electronic equipment randomly determines at least one query parameter from the parameters included in the webpage to be tested.
As a possible implementation manner, the electronic device may migrate to 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.
The technical scheme provided by the embodiment at least has the following beneficial effects: the address of the test page is generated by adopting the at least one randomly determined query parameter, so that the test page accessed by simulation is also randomly determined, and the accuracy of the comparison result of the detected webpage can be further improved.
In a practical manner, in conjunction with fig. 2, as shown in fig. 4, the S13 provided in the embodiments of the present disclosure specifically includes the following S21-S22.
And S21, the electronic equipment determines the similarity between the page image of the test page and the preset image.
As a possible implementation manner, the similarity between the page image of the test page and the corresponding preset image may be determined according to an OpenCV icon recognition technology, or may be determined according to a machine learning model trained in advance.
For example, the similarity between the page image of the test page and the corresponding preset image may be identified according to an OpenCV icon recognition technology. When the page images of the test pages comprise 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, a first similarity between the page image of the first test page and the page image of the corresponding first expected page, a second similarity between the page image of the second test page and the page image of the corresponding second expected page and a third similarity between the page image of the third test page and the page image of the corresponding third expected page can be respectively determined through an OpenCV icon recognition technology.
And S22, the electronic equipment determines the similarity as a comparison result.
Exemplarily, the electronic device determines the first similarity, the second similarity and the third similarity as the comparison result.
The technical scheme provided by the embodiment at least has the following beneficial effects: according to the method and the device, the similarity between the page image of the test page and the corresponding preset image is determined as the comparison result, manual inspection is not needed, and a large amount of labor cost and time cost which are possibly caused when the page image of the test page is manually inspected are avoided.
In one design, after S22, the web page testing method provided in the embodiments of the present disclosure further includes the following S23 and S24.
And S23, determining that the page to be tested passes the test by the electronic equipment under the condition that the similarity is greater than or equal to the threshold value.
For example, 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 may be determined that the page image of the test page is consistent with the corresponding preset image. The preset threshold value here may be 90% or 95%, etc.
It should be noted that the preset threshold may be preset in the electronic device by the operation and maintenance staff.
The technical scheme provided by the embodiment at least has the following beneficial effects: through comparison of the similarity with a preset threshold value, a specific implementation mode for determining whether the webpage to be tested passes the test or not can be provided.
And S24, generating alarm information by the electronic equipment under the condition that the similarity is smaller than a preset threshold value.
The alarm information comprises the address of the webpage to be detected. The alarm information is used for indicating that the webpage to be tested does not pass the test.
For example, when the electronic device determines that any one of the first similarity, the second similarity and the third similarity is smaller than the preset threshold, it may be determined that the page image of the test page is inconsistent with the corresponding preset image, and it is further determined that the to-be-tested page fails to be tested. In this case, the electronic device generates alarm information and transmits the alarm information to the outside.
It should be noted that, a difference exists between the page image of the test page and the corresponding preset image, which may be caused by a difference in screen capture of the corresponding page image, for example, a page image area of the test page is different from a page image area of the expected page. When the web page to be tested includes a plurality of test pages, the test pages need to be compared with the compared preset images one by one.
The technical scheme provided by the embodiment at least has the following beneficial effects: under the condition that the webpage to be tested does not pass the test, a specific implementation mode for timely reminding operation and maintenance personnel to process can be provided.
In an implementable manner, the element occupying regions in the preset image may be as shown in fig. 5, the element occupying regions include a first element occupying region, a second element occupying region, a third element occupying region and the like, and the element occupying regions are all used for filling webpage elements such as characters, pictures and the like. Thus, no empty area exists for the element footprint within the preset image. The element occupying area refers to an area corresponding to each web page element in the web page to be tested, such as an area position occupied by a character element in the web page to be tested, an area position occupied by a picture element in the web page to be tested, and the like.
In a practical manner, as shown in fig. 6 in conjunction with fig. 2, after step S12, the following step S14 is further included.
S14, under the condition that the blank area does not exist in the element occupying area in the preset image, the electronic equipment judges whether the blank area exists in the element occupying area in the page image of the test page.
The element occupying area is an area corresponding to the webpage element in the webpage.
In this case, S13 provided in the embodiment of the present disclosure may specifically include S131 described below.
S131, under the condition that no blank area exists in the element occupying area in the page image of the test page, the electronic equipment compares the page image of the test page with a preset image to obtain a comparison result.
As a possible implementation manner, the webpage to be tested may include a plurality of page elements, and the page elements may be distributed in occupied areas of different elements of the webpage to be tested, so that a normal webpage to be tested does not have a blank area. Therefore, the comparison result is obtained by judging whether the element occupying area in the page image of the test page has a blank area or not and comparing the page image of the test page with the preset image under the condition that the element occupying area in the page image of the test page does not have the blank area.
For example, corresponding to the web page to be tested, the element occupying region of the test page is the same as the element occupying region of the web page to be tested, and if the test page includes the first element occupying region, the second element occupying region, the third element occupying region, …, and the xth element occupying region, the blank region of each element occupying region in the test page may also be identified by an OpenCV icon identification technique or a pre-trained machine learning model at this time.
Correspondingly, when the test pages include a plurality of test pages, it is also necessary to determine whether blank areas exist in the test pages one by one, and then determine whether the page images of the test pages continue to perform subsequent comparison operations.
In another case, if the electronic device determines that the empty area exists in the element occupying area in the page image of the test page, it may be directly determined that the page image of the test page is inconsistent with the corresponding preset image, and it is further determined that the to-be-tested web page fails the test.
The technical scheme provided by the embodiment at least has the following beneficial effects: according to the method and the device, whether the subsequent comparison action is continuously executed or not is judged by testing whether the blank area exists in the page, on one hand, the situation that the webpage to be tested does not pass the test can be directly determined under the condition that the blank area exists in the element occupying area in the page image of the test page, and therefore the computing resources of the electronic equipment are saved. In another aspect, under the condition that no blank area exists in the element occupying 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, so that the validity of the comparison result can be ensured to be determined subsequently.
In a practical manner, as shown in fig. 7, after determining the page image of the test page in step S12, the web page test method provided by the embodiment of the present disclosure may further include the following steps S15-S16.
S15, the electronic equipment obtains a page image set corresponding to the webpage to be detected based on the address of the webpage to be detected.
The page image set corresponding to the webpage to be tested comprises page images of all test pages corresponding to the webpage to be tested.
As a possible implementation manner, the electronic device may classify the page images of the test pages according to addresses in the corresponding test addresses, so as to store the page images of the test pages in different folders. For example, the first test address corresponding to the first test page is protocol:// hostname/pathuserId:// 10000065& itemId ═ 10000005321, the second test address corresponding to the second test page is protocol:// hostname/pathuserId: 10003165& itemId ═ 10000405521, and 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 at this time. For another example, the third test address corresponding to the third test page is protocol:// hostname/path1 userld 10000315& itemld 10000205341, and 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 may be stored in another folder.
It should be noted that, when creating folders storing page images of test pages, the folders may be named with increasing numbers, such as the folder name increasing from 1. Of course, this 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 at this time, the folder may be named protocol:// hostname/path. The mode of naming the folder by the address can facilitate the patrol personnel to quickly determine the data corresponding to the abnormal page image in the patrol personnel. When the folders are uploaded to the cloud, in order to achieve the overall uploading of the page images, the folders need to be packed and compressed, and the names of the compressed files are the same as the names of the corresponding folders.
And S16, the electronic equipment sends the access address of the page image set corresponding to the webpage to be detected to the detection end.
As a possible implementation manner, after the electronic device sequentially stores the page image sets of all the test pages in different folders, the files can be uploaded to the cloud, and then the access address of the page image set corresponding to the to-be-tested page is obtained. Further, the electronic equipment sends the access address of the page image set corresponding to the webpage to be detected to the detection end.
It should be noted that, uploading the file to the cloud may be uploading to a cloud server, or uploading to a Content Delivery Network (CDN), and the like, and this is not limited herein.
In one possible implementation, after uploading the compressed files to the cloud, the cloud may return the access addresses of the compressed files. For example, when uploading a compressed file to the CDN, the storage address of the compressed file within the CDN may be returned. The electronic device determines the received memory address as the access address. At this moment, this disclosure can also adopt the mode of artifical patrolling and examining to test the page. For example, the inspection personnel may download the compressed file from the CDN by using the access address in the detection end, and check whether a blank area exists in the page image of each test page in the compressed file after decompression, so as to determine whether the corresponding test page is abnormal.
The technical scheme provided by the embodiment at least has the following beneficial effects: the compressed file is downloaded by inspection personnel, the page images of all the test pages in the compressed file are inspected, the test pages can be further inspected, possible mistakes and omissions are avoided when the test pages are inspected through a script program and a headless browser, and the accuracy of the test on the to-be-tested web page is improved. Of course, the web page to be tested may be tested only by the above program script, or the inspection personnel may inspect the page image in the compressed file to complete the test of the web page to be tested.
In an implementation manner, since the number of users of a website in different time periods is different, and different users are different, different problems may exist in the operation of the website. Therefore, the script program for webpage testing can be run daily in real time, or periodically, and the possible problems of the website running can be discovered.
Fig. 8 is a schematic structural diagram illustrating a web page testing apparatus according to an exemplary embodiment, and as shown in fig. 8, the web page testing apparatus 30 includes a processing unit 301, an obtaining unit 302, and a determining unit 303.
The processing unit 301 is configured to splice at least one query parameter group with the address of the web page to be tested, so as to obtain at least one test address. The query parameter group comprises at least one query parameter and a query parameter value corresponding to the at least one query parameter.
The obtaining unit 302 is configured to execute a simulated access operation on the to-be-tested web page based on the at least one test address, and obtain a page image of a test page opened in the simulated access operation process.
The determining unit 303 is configured to compare the page image of the test page with a preset image to obtain a comparison result. And the comparison result is used for determining whether the webpage to be tested passes the test or not.
Optionally, as shown in fig. 8, the web page testing apparatus 30 provided in the embodiment of the present disclosure further includes a generating unit 304.
The generating unit 304 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 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.
Optionally, as shown in fig. 8, the determining unit 303 provided in the embodiment of the present disclosure is specifically configured to obtain a similarity between a page image of the test page and the preset image, and determine the similarity as the comparison result.
Optionally, as shown in fig. 8, the determining 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.
Optionally, as shown in fig. 8, the determining unit 303 provided in the embodiment of the present disclosure is further configured to generate warning information when the similarity is smaller than a preset threshold. The alarm information comprises the address of the webpage to be detected.
Optionally, as shown in fig. 8, the web page testing apparatus 30 provided in the embodiment of the present disclosure further includes a determining unit 305.
The determining unit 305 is configured to determine whether an empty space exists in an element occupying area in a page image of the test page under the condition that the empty space does not exist in the element occupying area in the preset image. The element footprint is the area of the web page that the web page element corresponds to.
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 occupying area in the page image of the test page.
Optionally, as shown in fig. 8, the determining unit 303 provided in the embodiment of the present disclosure is further configured to randomly determine the at least one query parameter from parameters included in the to-be-detected web page.
Optionally, as shown in fig. 8, the web page testing apparatus 30 provided in the embodiment of the present disclosure further includes a sending unit 306.
The obtaining unit 302 is further configured to obtain a page image set corresponding to the web page to be detected based on the address of the web page to be detected. The page image set corresponding to the webpage to be tested comprises page images of all the test pages corresponding to the webpage to be tested.
The sending unit 306 is configured to send the access address of the page image set corresponding to the webpage to be detected to the detection end.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 9 is a schematic structural diagram of an electronic device 40 provided by the present disclosure. As shown in fig. 9, the electronic device 40 may include at least one processor 401 and a memory 403 for storing instructions executable by the processor 401. Wherein the processor 401 is configured to execute the instructions in the memory 403 to implement the web page test method in the above-described embodiment.
As an example, in conjunction with fig. 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 transmission unit 306 in the web test apparatus are the same as those of the processor 401 in fig. 9.
Additionally, the electronic device 40 may also include a communication bus 402 and at least one communication interface 404.
Processor 401 may be a GPU, a micro-processing unit, an ASIC, or one or more integrated circuits for controlling the execution of programs in accordance with the disclosed aspects.
Communication bus 402 may include a path that transfers information between the above components.
The communication interface 404 may be any device, such as a transceiver, for communicating with other devices or communication networks, such as an ethernet, a Radio Access Network (RAN), a Wireless Local Area Network (WLAN), etc.
The memory 403 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a Random Access Memory (RAM) or other type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disk storage, optical disk storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to these. The memory may be self-contained and connected to the processing unit by a bus. The memory may also be integrated with the processing unit as a volatile storage medium in the GPU.
The memory 403 is used for storing instructions for executing the disclosed solution, and is controlled by the processor 401. The processor 401 is configured to execute instructions stored in the memory 403 to implement the functions of the disclosed method.
In particular implementations, processor 401 may include one or more GPUs, such as GPU0 and GPU1 in fig. 9, as one embodiment.
In particular implementations, electronic device 40 may include multiple processors, such as processor 401 and processor 407 in FIG. 9, for example, as an embodiment. Each of these processors may be a single-Core (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).
In particular implementations, electronic device 40 may also include an output device 405 and an input device 406, as one embodiment. An output device 405 is in communication 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, a projector (projector), or the like. The input device 406 is in communication with the processor 401 and can accept 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 sensing device, among others.
Those skilled in the art will appreciate that the configuration shown in fig. 9 does not constitute a limitation of the electronic device 40, and may include more or fewer components than those shown, or combine certain components, or employ a different arrangement of components.
In addition, the present disclosure also provides a computer-readable storage medium including instructions that, when executed by a processor of an electronic device, cause the electronic device to perform the web page testing method provided in the above embodiment.
In addition, the present disclosure also provides a computer program product, which includes instructions that, when executed on a processor of an electronic device, cause the electronic device to execute the web page testing method provided in the above embodiment.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements 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 (10)

1. A web page testing method is characterized by comprising the following steps:
splicing the at least one query parameter group with the address of the webpage to be tested respectively to obtain at least one test address; the query parameter group comprises at least one query parameter and a query parameter value corresponding to the at least one query parameter;
executing a simulation access operation on the webpage to be tested based on the at least one test address, and acquiring a page image of a test page opened in the simulation access operation process;
comparing the page image of the test page with a preset image to obtain a comparison result; and the comparison result is used for determining whether the webpage to be tested passes the test or not.
2. The web page testing method according to claim 1, further comprising:
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;
and determining the at least one query parameter group according to the at least one query parameter and the query parameter value corresponding to the at least one query parameter.
3. The method for testing web pages according to claim 1 or 2, wherein the comparing the page image of the test page with a preset image to obtain a comparison result comprises:
and acquiring the similarity between the page image of the test page and the preset image, and determining the similarity as the comparison result.
4. The web page testing method of claim 3, wherein the method further comprises:
and determining that the page to be tested passes the test under the condition that the similarity is greater than or equal to a preset threshold value.
5. The web page testing method according to claim 3, further comprising:
generating alarm information under the condition that the similarity is smaller than a preset threshold value; the alarm information comprises the address of the webpage to be detected.
6. The web page testing method according to claim 1 or 2, wherein the method further comprises:
under the condition that the element occupying area in the preset image does not have a blank area, judging whether the element occupying area in the page image of the test page has the blank area; the element occupying area is an area corresponding to the webpage element in the webpage;
the comparing the page image of the test page with a preset image to obtain a comparison result comprises:
and comparing the page image of the test page with the preset image to obtain the comparison result under the condition that no blank area exists in the element occupying area in the page image of the test page.
7. The webpage testing device is characterized by comprising a processing unit, an acquisition unit and a determination unit;
the processing unit is used for splicing the at least one query parameter group with the address of the webpage to be tested respectively to obtain at least one test address; the query parameter group comprises at least one query parameter and a query parameter value corresponding to the at least one query parameter;
the acquisition unit is used for executing the simulated access operation on the webpage to be tested based on the at least one test address and acquiring a page image of a test page opened in the simulated access operation process;
the determining unit is used for comparing the page image of the test page with a preset image to obtain a comparison result; and the comparison result is used for determining whether the webpage to be tested passes the test or not.
8. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the web page testing method of any one of claims 1 to 6.
9. A computer-readable storage medium, wherein the computer-readable storage medium comprises instructions; the instructions, when executed by a processor of an electronic device, cause the electronic device to perform the web page testing method of any of claims 1 to 6.
10. A computer program product, characterized in that it comprises instructions which, when run on a processor of an electronic device, cause the electronic device to perform the web page testing method according to any one of claims 1 to 6.
CN202111450103.4A 2021-11-30 2021-11-30 Webpage testing method and device, electronic equipment and storage medium Pending CN114153729A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111450103.4A CN114153729A (en) 2021-11-30 2021-11-30 Webpage testing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111450103.4A CN114153729A (en) 2021-11-30 2021-11-30 Webpage testing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114153729A true CN114153729A (en) 2022-03-08

Family

ID=80455463

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111450103.4A Pending CN114153729A (en) 2021-11-30 2021-11-30 Webpage testing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114153729A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117725975A (en) * 2024-02-08 2024-03-19 支付宝(杭州)信息技术有限公司 Training method of decision model, and small program inspection method and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117725975A (en) * 2024-02-08 2024-03-19 支付宝(杭州)信息技术有限公司 Training method of decision model, and small program inspection method and device

Similar Documents

Publication Publication Date Title
US10970641B1 (en) Heuristic context prediction engine
CN113987074A (en) Distributed service full-link monitoring method and device, electronic equipment and storage medium
CN105260299A (en) Method, device, and system for software test
US20190147539A1 (en) Method and apparatus for outputting information
US11412070B2 (en) Method and apparatus for generating information
CN109726108B (en) Front-end code testing method, device, system and medium based on analog data
US11244153B2 (en) Method and apparatus for processing information
CN105306495A (en) User identification method and device
CN109814868B (en) Network transmission simulation method and device, computer equipment and storage medium
CN106033361A (en) Method and device for showing application page, and method and device for updating application page data
US20190147540A1 (en) Method and apparatus for outputting information
CN111352836A (en) Pressure testing method and related device
CN108694120B (en) Method and device for testing service component
CN114153729A (en) Webpage testing method and device, electronic equipment and storage medium
CN107402878B (en) Test method and device
CN111431767A (en) Multi-browser resource synchronization method and device, computer equipment and storage medium
CN113535577B (en) Application testing method and device based on knowledge graph, electronic equipment and medium
CN109886015A (en) The detection method and device of the installation kit of application program
CN115242684B (en) Full-link pressure measurement method and device, computer equipment and storage medium
CN115086194B (en) Cloud application data transmission method, computing device and computer storage medium
CN105975389A (en) Process data extraction method and apparatus
CN109472012A (en) A kind of management method and device of electronization test report
CN111045935B (en) Automatic version auditing method, device, equipment and storage medium
CN115203178A (en) Data quality inspection method and device, electronic equipment and storage medium
CN114371969A (en) Page performance testing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination