Test method and device of page, storage medium and processor
By acquiring the location information of the target page and preset images, the system triggers target commands to perform operations and conducts tests based on image comparisons. This solves the problem of the inability to effectively test Canvas pages in existing technologies and achieves accurate and continuous testing results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HILLSTONE NETWORKS CO LTD
- Filing Date
- 2022-12-05
- Publication Date
- 2026-06-12
AI Technical Summary
Existing automated testing frameworks for web pages cannot effectively test Canvas pages, cannot fully confirm the display effect, and cannot perform continuous interactive testing and user-perspective testing.
By obtaining the location information of the target page and preset images, the target instructions are triggered to perform operations on the page, and the normality of the page is determined by comparing the images.
It enables effective testing of Canvas pages, improves the accuracy and continuity of testing, fully confirms the display effect, and simulates user operations for testing.
Smart Images

Figure CN115757182B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a method and apparatus for testing pages, a storage medium, and a processor. Background Technology
[0002] In related technology one, standard testing frameworks are generally used to automate page testing. Specifically, web pages exist in browser memory as a DOM tree (document tree). Each element on the page can be found as a corresponding node in the DOM tree. When the structure of the DOM tree changes, or the style of a DOM node changes, the page also changes. Directly manipulating DOM nodes (document nodes) in memory has the same effect as directly clicking with a mouse or typing on the page. Therefore, the automation framework implements click and keyboard input operations by manipulating the DOM tree. Furthermore, after performing these operations, it's necessary to verify the page's correctness. This is done by checking if the corresponding DOM nodes exist, or if the corresponding attributes of the displayed DOM nodes exist and if their values are correct. Executing the API (interface) in the testing framework that manipulates the DOM tree (finding the corresponding DOM nodes using XPath (document tree path lookup language) and reading their information) can determine if the corresponding DOM elements exist and if their attributes are correct.
[0003] However, the relevant technology has the following drawbacks:
[0004] (1) It depends on the DOM nodes of the page. If it is a canvas, it cannot determine whether the page is normal.
[0005] (2) It can only check the nodes and attributes of the page, but cannot determine whether it is actually displayed correctly. (Because of the cumulative effect of CSS (Cascading Style Sheets), judging only the node attributes cannot fully confirm whether the display is correct).
[0006] (3) Continuous interactive testing of canvas and other pages is not possible.
[0007] In related technology two, image comparison is generally used to determine if a page is functioning correctly. Specifically, first, a normally functioning page is launched, and tools are used to capture some images for testing and comparison. The test framework is then run, the page is launched, and a screenshot of the entire page or a portion of the page is taken. The screenshot is then compared with a preset image to check for similarities and determine if the page is functioning correctly.
[0008] However, the second related technology has the following drawbacks: it can only perform complete image comparisons, cannot flexibly perform business arrangement tests on the page, and the comparison ends when the page undergoes partial changes, thus it cannot continuously perform page testing.
[0009] Therefore, in related technologies, the following three problems exist for automated testing of web pages:
[0010] (1) The inability to test the Canvas in web pages using existing automated frameworks. That is, web testing frameworks determine their correctness by finding DOM nodes and then judging their attribute values. However, the canvas is displayed on the drawing surface in real time, and web pages cannot be tested by checking the validity of the DOM.
[0011] (2) It cannot reproduce the true WYSIWYG scenario. That is, in the process of automated testing of web pages, in most cases, the corresponding DOM node is found by the test framework, and then its attributes are judged to confirm whether the current page is correct. However, it is impossible to fully confirm that the actual display during the test is the ideal display effect. This solution can supplement the test display effect on the basis that the test node is correct.
[0012] (3) Testing cannot be conducted entirely from the user's perspective (the test scenario and display are exactly the same as the user's actual operation).
[0013] There is currently no effective solution to the problem of poor performance of test pages in related technologies. Summary of the Invention
[0014] The main objective of this application is to provide a method, apparatus, storage medium, and processor for testing pages, in order to solve the problem of poor page testing performance in related technologies.
[0015] To achieve the above objectives, according to one aspect of this application, a method for testing a page is provided. The method includes: acquiring a target image and a first preset image, wherein the target image is an image corresponding to a target page to be tested, and the first preset image is an image corresponding to a node in the target page; acquiring position information of the first preset image in the target image; triggering a target instruction based on the position information of the first preset image in the target image, wherein the target instruction indicates performing a target operation on the first preset image in the target page; and testing the target page based on the target instruction.
[0016] Further, testing the target page based on the target instruction includes: responding to the target instruction, performing a target operation on the first preset image on the target page to obtain a first page, wherein the first page includes at least the node and its corresponding child nodes; taking a screenshot of the first page to generate a first image; obtaining a second preset image corresponding to the child node; and testing the target page based on the first image, the first preset image, and the second preset image.
[0017] Further, testing the target page based on the first image, the first preset image, and the second preset image includes: determining whether the first preset image and the second preset image exist in the first image; if the first preset image and the second preset image exist in the first image, then obtaining the attribute information of the first preset image and the second preset image in the first image respectively; determining whether the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and determining whether the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page; if the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page, then the target page is normal; if the attribute information of the first preset image in the first image is different from the attribute information of the node in the target page, and / or, the attribute information of the second preset image in the first image is different from the attribute information of the child node in the first page, then the target page is abnormal.
[0018] Further, obtaining the position information of the first preset image in the target image includes: determining whether the first preset image exists in the target image; if the first preset image exists in the target image, obtaining the attribute information of the first preset image in the target image; determining whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page, obtaining the position information of the first preset image in the target image.
[0019] Furthermore, after acquiring the target image and the first preset image, the method further includes: determining whether the first preset image exists in the target image; if the first preset image exists in the target image, acquiring the attribute information of the first preset image in the target image; determining whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page, it indicates that the target page is normal; if the attribute information of the first preset image in the target image is different from the attribute information of the node in the target page, it indicates that the target page is abnormal.
[0020] Furthermore, obtaining the target image includes: obtaining the target page to be tested; setting the size of the target page to obtain a second page; obtaining a script for converting the page into an image; and executing the script to convert the second page into the target image.
[0021] Further, executing the script to convert the second page into the target image includes: executing the script to obtain the ID information of each node in the second page; and obtaining the target image based on the ID information of each node in the second page.
[0022] To achieve the above objectives, according to another aspect of this application, a page testing apparatus is provided. The apparatus includes: a first acquisition module, configured to acquire a target image and a first preset image, wherein the target image is an image corresponding to a target page to be tested, and the first preset image is an image corresponding to a node in the target page; a second acquisition module, configured to acquire position information of the first preset image in the target image; a first triggering module, configured to trigger a target instruction based on the position information of the first preset image in the target image, wherein the target instruction indicates that a target operation is performed on the first preset image in the target page; and a first testing module, configured to test the target page based on the target instruction.
[0023] Further, the first testing module includes: a first response unit, configured to respond to the target instruction and perform a target operation on the first preset image on the target page to obtain a first page, wherein the first page includes at least the node and its corresponding child nodes; a first generation unit, configured to take a screenshot of the first page to generate a first image; a first acquisition unit, configured to acquire a second preset image corresponding to the child node; and a first testing unit, configured to test the target page based on the first image, the first preset image, and the second preset image.
[0024] Further, the first testing unit includes: a first judgment submodule, used to determine whether the first preset image and the second preset image exist in the first image; a first acquisition submodule, used to acquire the attribute information of the first preset image and the second preset image in the first image respectively if the first preset image and the second preset image exist in the first image; a second judgment submodule, used to determine whether the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and to determine whether the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page; a first determination submodule, used to indicate that the target page is normal if the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page; and a second determination submodule, used to indicate that the target page is abnormal if the attribute information of the first preset image in the first image is not the same as the attribute information of the node in the target page, and / or the attribute information of the second preset image in the first image is not the same as the attribute information of the child node in the first page.
[0025] Further, the second acquisition module includes: a first judgment unit, configured to determine whether the first preset image exists in the target image; a second acquisition unit, configured to acquire attribute information of the first preset image in the target image if the first preset image exists in the target image; a second judgment unit, configured to determine whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; and a third acquisition unit, configured to acquire position information of the first preset image in the target image if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page.
[0026] Furthermore, the device further includes: a first judging module, configured to judge whether the first preset image exists in the target image after acquiring the target image and the first preset image; a third acquiring module, configured to acquire the attribute information of the first preset image in the target image if the first preset image exists in the target image; a second judging module, configured to judge whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; a first determining module, configured to indicate that the target page is normal if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; and a second determining module, configured to indicate that the target page is abnormal if the attribute information of the first preset image in the target image is not the same as the attribute information of the node in the target page.
[0027] Further, the first acquisition module includes: a fourth acquisition unit for acquiring a target page to be tested; a first setting unit for setting the size of the target page to obtain a second page; a fifth acquisition unit for acquiring a script for converting the page into an image; and a first conversion unit for executing the script to convert the second page into the target image.
[0028] Furthermore, the first conversion unit includes: a second acquisition submodule, used to execute the script and acquire the ID information of each node in the second page; and a third determination submodule, used to obtain the target image based on the ID information of each node in the second page.
[0029] To achieve the above objectives, according to another aspect of this application, a computer-readable storage medium is provided, the storage medium storing a program, wherein the program executes the page testing method described in any of the preceding claims.
[0030] To achieve the above objectives, according to another aspect of this application, a processor is provided for running a program, wherein the program executes the page testing method described in any of the above-described embodiments.
[0031] This application employs the following steps: obtaining a target image and a first preset image, wherein the target image is the image corresponding to the target page to be tested, and the first preset image is the image corresponding to a node in the target page; obtaining the position information of the first preset image in the target image; triggering a target instruction based on the position information of the first preset image in the target image, wherein the target instruction is used to indicate performing a target operation on the first preset image in the target page; and testing the target page based on the target instruction, thus solving the problem of poor test page performance in related technologies. By triggering a target instruction based on the obtained position information of the first preset image in the target image, and testing the target page based on the target instruction, continuous page testing can be performed, improving the accuracy of the test page and thus enhancing the test page performance. Attached Figure Description
[0032] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0033] Figure 1 This is a flowchart of a page testing method provided according to an embodiment of this application;
[0034] Figure 2 This is a flowchart of the page testing method provided in the embodiments of this application. Figure 1 ;
[0035] Figure 3 This is a flowchart of an optional page testing method provided according to an embodiment of this application;
[0036] Figure 4 This is a schematic diagram of a page image captured in an embodiment of this application;
[0037] Figure 5 This is a schematic diagram of a screenshot image generated after clicking on a page element in an embodiment of this application;
[0038] Figure 6 This is a schematic diagram of a test apparatus for a page provided according to an embodiment of this application. Detailed Implementation
[0039] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0040] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0041] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0042] Example 1
[0043] The present invention will now be described in conjunction with preferred implementation steps. Figure 1 This is a flowchart of a page testing method provided according to an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:
[0044] Step S101: Obtain the target image and the first preset image, wherein the target image is the image corresponding to the target page to be tested, and the first preset image is the image corresponding to the node in the target page.
[0045] For example, the target page mentioned above can be the webpage to be tested. First, the webpage can be cropped according to requirements to obtain a screenshot of the webpage (the target image mentioned above), and the node elements in the webpage can be cropped to generate screenshot images corresponding to the elements in the webpage (the first preset image mentioned above).
[0046] Step S102: Obtain the position information of the first preset image in the target image.
[0047] For example, using the image corresponding to an element on the webpage (the first preset image mentioned above), find the position of the first preset image in the screenshot image of the webpage (the target image mentioned above).
[0048] Step S103: Based on the position information of the first preset image in the target image, trigger the target instruction, wherein the target instruction is used to indicate that a target operation is performed on the first preset image in the target page.
[0049] For example, after locating the position of the first preset image within a screenshot of the webpage (the aforementioned target image), target instructions are triggered to perform actions such as mouse movement and keyboard input. In other words, these triggered action instructions manipulate the image (the aforementioned first preset image) corresponding to the elements on the webpage.
[0050] Step S104: Test the target page based on the target instructions.
[0051] For example, based on the triggered target instruction, test whether the webpage is working properly.
[0052] Through the above steps S101 to S104, by using the obtained position information of the first preset image in the target image, a target instruction is triggered, and the target page is tested based on the target instruction. This allows for continuous testing of the page, improves the accuracy of the test page, and ultimately enhances the effectiveness of the test page.
[0053] To quickly and accurately obtain the target image, the page testing method provided in this application embodiment can also obtain the target image through the following steps: obtaining the target page to be tested; setting the size of the target page to obtain a second page; obtaining a script for converting the page into an image; and executing the script to convert the second page into the target image.
[0054] For example, a web page can be started and loaded using a web automation testing tool; then the page size can be set, meaning that the page can be set to different sizes during the test to complete tests at different page sizes; then a script to generate an image can be injected, meaning that a JavaScript script can be injected into the browser through a web testing framework, and then the script can be used to generate an image (the target image mentioned above).
[0055] The above method allows for quick and accurate acquisition of screenshots of the page. Furthermore, by adjusting the page size, it's possible to test display at different resolutions and precisely match the location of test points.
[0056] To obtain the target image quickly and accurately, the page testing method provided in this application embodiment can also obtain the target image through the following steps: executing a script to obtain the ID information of each node in the second page; and obtaining the target image based on the ID information of each node in the second page.
[0057] For example, if the testing framework doesn't support image generation, it can be done using JavaScript. The JavaScript is injected into the browser through the web testing framework. This injected JavaScript is then invoked by the testing tools to generate the corresponding image based on the passed parameters. For example, it can generate an image based on the ID of a DOM node, or generate an image of the entire page. The generated image is then sent back to the testing framework.
[0058] Using the above method and scripts, you can quickly and accurately obtain screenshots of the page.
[0059] To quickly and accurately obtain the location information of the first preset image in the target image, the page testing method provided in this application embodiment can also obtain the location information of the first preset image in the target image through the following steps: determining whether the first preset image exists in the target image; if the first preset image exists in the target image, obtaining the attribute information of the first preset image in the target image; determining whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page, obtaining the location information of the first preset image in the target image.
[0060] For example, after cropping an image according to requirements, the information needed for subsequent operations can be obtained from the cropped image and the preset image (the first preset image mentioned above).
[0061] For example, images can be recognized and matched using open-source libraries. The test framework reads the preset image (or text) and the image generated by the page in the current step and inputs them into the image recognition system. It checks whether the corresponding image exists and its corresponding coordinates (there can be multiple coordinates), as well as the size and quantity of the preset image in the new image. It then makes a judgment. If all the above information is confirmed to be correct, the subsequent operation continues to obtain the position of the first preset image in the screenshot of the webpage (the target image mentioned above). If there are any errors in the above information, the subsequent operation cannot continue, that is, the position of the first preset image in the screenshot of the webpage (the target image mentioned above) cannot be obtained, and it is necessary to obtain this information again and make a judgment.
[0062] The above method can quickly and accurately determine the position of the preset image in the screenshot of the page.
[0063] Figure 2 This is a flowchart of the page testing method provided in the embodiments of this application. Figure 1 ,like Figure 2 As shown, in the page testing method provided in this application embodiment, testing the target page based on the target instruction includes:
[0064] Step S201: In response to the target instruction, perform target operation on the first preset image on the target page to obtain the first page, wherein the first page includes at least a node and the child nodes corresponding to the node;
[0065] Step S202: Take a screenshot of the first page and generate the first image;
[0066] Step S203: Obtain the second preset image corresponding to the child node;
[0067] Step S204: Test the target page based on the first image, the first preset image, and the second preset image.
[0068] For example, after obtaining subsequent operation information (such as the coordinates of the image), operations such as mouse movement and text input can be performed based on the corresponding information. For instance, moving the mouse to a specified coordinate can trigger a click operation. Specifically, first, the position of the corresponding node within the entire image is obtained, then the mouse movement position is calculated, and then the mouse is moved to the calculated mouse movement position and a click operation is performed (interaction can be performed using testing framework methods). Then, conditional checks are performed, such as checking if the image (or text) exists, checking if the complete image is consistent, etc., and the webpage is tested based on the results.
[0069] The above solutions can address the shortcomings of basic web testing frameworks in terms of coverage (such as canvas testing), enabling comprehensive page testing.
[0070] To quickly and accurately test the target page, the page testing method provided in this application embodiment can also test the target page through the following steps: determining whether a first preset image and a second preset image exist in the first image; if the first preset image and the second preset image exist in the first image, then obtaining the attribute information of the first preset image and the second preset image in the first image respectively; determining whether the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and determining whether the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page; if the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page, then the target page is normal; if the attribute information of the first preset image in the first image is different from the attribute information of the node in the target page, and / or, the attribute information of the second preset image in the first image is different from the attribute information of the child node in the first page, then the target page is abnormal.
[0071] For example, after moving the mouse to the calculated mouse position and performing a click operation, the specific process for conditional judgment can be: checking if the image (or text) exists, checking if the complete image is consistent, or other methods that can be used for image judgment. If the judgment is successful and there are subsequent operations, continue to execute the subsequent operations. If there are no subsequent operations, it means that the webpage is normal. If the judgment fails, it means that the webpage is abnormal and the test ends.
[0072] The above method allows for quick and accurate testing of the page.
[0073] To quickly and accurately test the target page, the page testing method provided in this application embodiment can also test the target page through the following steps: determining whether a first preset image exists in the target image; if the first preset image exists in the target image, obtaining the attribute information of the first preset image in the target image; determining whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page, it indicates that the target page is normal; if the attribute information of the first preset image in the target image is different from the attribute information of the node in the target page, it indicates that the target page is abnormal.
[0074] For example, after entering the page and capturing the entire page, the system can first determine if a preset image (the first preset image mentioned above) exists. If it exists, the image recognition function is then called to find the preset image's attribute information, such as whether the number of preset images in the complete screenshot matches the preset real data, whether the size of the preset images in the complete screenshot matches the preset real data, and whether the position of the preset images in the complete screenshot matches the preset real data. If all of the above attribute information is correctly determined, the page is normal. If any one or more of the above attribute information is incorrect, the page is abnormal. Additionally, if the preset image (the first preset image mentioned above) is determined not to exist, it also indicates a page abnormality.
[0075] The above solution simplifies the testing process. Users only need to know the operation flow and perform interactive operations based on visual matching to complete automated testing.
[0076] For example, Figure 3 This is a flowchart of an optional page testing method provided according to an embodiment of this application, such as... Figure 3 As shown, automated page testing can be achieved by combining web testing tools with image recognition results. Optional page testing methods include the following steps:
[0077] 1. Start and load the web page using a web automation testing tool.
[0078] 2. Set the page size. During testing, the page can be set to different sizes to complete tests at different page dimensions. Setting the page size is mainly for testing display at different resolutions and accurately matching the position of test points (such as the position of a button on the page).
[0079] 3. Injecting Image Generation Script: If the testing framework can take screenshots, you can directly use the automation framework's screenshot function; if you want to generate images of specific DOM nodes, you can use that; if the testing framework doesn't support image generation, you can use JavaScript to generate the image. Inject the JavaScript script into the browser through the web testing framework. The injected JavaScript script is called by the testing tools to generate the corresponding image based on the passed parameters. For example, generating an image based on a DOM node's ID; generating an image of the entire page, etc. The generated image is then sent back to the testing framework.
[0080] 4. Cropping images as needed. Image cropping can be done using the testing framework's API; if the framework doesn't support it, injected JavaScript methods can be used.
[0081] 5. Obtain the information needed for subsequent operations based on the captured image and the preset image.
[0082] Images can be recognized and matched using open-source libraries. The test framework reads the preset image (or text) and the image generated by the page in the current step and feeds them into the image recognition system to check if the corresponding image exists and its corresponding coordinates (multiple coordinates are allowed).
[0083] Pre = Preset Image
[0084] New = Generate image
[0085] Determine if an image exists
[0086] OpenCV.isExist(Pre, New)
[0087] Get the coordinates of the image
[0088] OpenCV.getCoodinate(Pre, New)
[0089] Get the preset size in the new drawing.
[0090] OpenCV.getSize(Pre, New)
[0091] 6. Once identified, subsequent operation information can be obtained and condition judgments can be made.
[0092] (1) Obtaining subsequent operation information
[0093] After obtaining the information for subsequent operations (such as obtaining the x and y coordinates of the image), operations such as mouse movement and text input are performed based on the corresponding information.
[0094] For example, moving the mouse to a specified coordinate to perform a click operation.
[0095] First, obtain the position of the corresponding node in the entire image.
[0096] {x, y} = OpenCV.getCoodinate(Pre, New)
[0097] Calculate the position the mouse moves.
[0098] {x1, y1} = calculate(x, y)
[0099] Move the mouse to x1, y1 and click (you can use the test framework's methods for interaction).
[0100] (2) Conditional judgment
[0101] Determine if an image (or text) exists.
[0102] Determine if the complete image is consistent.
[0103] Other methods that can be used for image identification.
[0104] If the judgment is successful, continue with the subsequent operations; if the judgment fails, the test ends.
[0105] 7. If there are subsequent steps and step 6 is successful, the test can continue, and the operation returns to step 4; if there are no subsequent steps, the test ends.
[0106] For example, testing a graphical topology can be divided into the following steps:
[0107] (1) Upon entering the page, first capture the entire page, and the captured page should look like this: Figure 4 As shown, Figure 4 This is a schematic diagram of a page image captured in an embodiment of this application.
[0108] (2) Call the image recognition function to find preset nodes (such as...) Figure 4 (As shown) Whether the number in the complete screenshot matches the preset real data.
[0109] (3) Locate the "Suzhou 1" preset node in the complete image (e.g., Figure 4 (as shown in the image)
[0110] (4) Move the mouse to the coordinates of the preset image position and click.
[0111] (5) Take a screenshot for judgment, and the screenshot should look like this. Figure 5 As shown, Figure 5 This is a schematic diagram of a screenshot image generated after clicking on a page element in an embodiment of this application. Figure 5 The numbers in the address represent IP (Internet Protocol) addresses.
[0112] (6) Confirm the expanded effect: Locate the "Suzhou 1" preset node in the expanded image (e.g., Figure 5 (As shown), check if it exists.
[0113] (7) Confirm the expanded effect: Locate the preset child nodes in the expanded image (e.g., Figure 5 (As shown), check if it exists.
[0114] (8) Find the pre-defined node "Suzhou 1" (e.g., Figure 5 The coordinates are shown in the figure.
[0115] (9) Move the mouse to the appropriate coordinates calculated based on the found coordinates and click.
[0116] (10) Compare the screenshot with the original screenshot to see if they are the same. At this point, a test case for expanding and collapsing nodes based on image recognition is complete.
[0117] In summary, the page testing method provided in this application, by acquiring a target image and a first preset image (where the target image is the image corresponding to the target page to be tested, and the first preset image is the image corresponding to a node in the target page), acquiring the position information of the first preset image in the target image, triggering a target instruction based on the position information of the first preset image in the target image (where the target instruction indicates a target operation on the first preset image in the target page), and testing the target page based on the target instruction, solves the problem of poor page testing performance in related technologies. By triggering a target instruction based on the acquired position information of the first preset image in the target image, and testing the target page based on the target instruction, continuous page testing can be performed, improving the accuracy of page testing and thus enhancing the effectiveness of page testing.
[0118] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0119] Example 2
[0120] This application also provides a page testing apparatus. It should be noted that the page testing apparatus of this application can be used to execute the page testing method provided in this application. The page testing apparatus provided in this application will be described below.
[0121] Figure 6 This is a schematic diagram of a test apparatus for a page according to an embodiment of this application. For example... Figure 6 As shown, the device includes: a first acquisition module 601, a second acquisition module 602, a first trigger module 603, and a first test module 604.
[0122] Specifically, the first acquisition module 601 is used to acquire a target image and a first preset image, wherein the target image is the image corresponding to the target page to be tested, and the first preset image is the image corresponding to the node in the target page;
[0123] The second acquisition module 602 is used to acquire the position information of the first preset image in the target image;
[0124] The first triggering module 603 is used to trigger a target instruction based on the position information of the first preset image in the target image, wherein the target instruction is used to indicate that a target operation is performed on the first preset image in the target page;
[0125] The first test module 604 is used to test the target page based on the target instructions.
[0126] In summary, the page testing device provided in this application embodiment acquires a target image and a first preset image through a first acquisition module 601, wherein the target image is the image corresponding to the target page to be tested, and the first preset image is the image corresponding to a node in the target page; a second acquisition module 602 acquires the position information of the first preset image in the target image; a first trigger module 603 triggers a target instruction based on the position information of the first preset image in the target image, wherein the target instruction is used to indicate that a target operation is performed on the first preset image in the target page; and a first testing module 604 tests the target page based on the target instruction, thus solving the problem of poor page testing effect in related technologies. By triggering the target instruction based on the acquired position information of the first preset image in the target image, and testing the target page based on the target instruction, continuous page testing can be performed, and the accuracy of page testing can be improved, thereby improving the effect of page testing.
[0127] Optionally, in the page testing device provided in this application embodiment, the first testing module includes: a first response unit, used to respond to a target instruction and perform a target operation on a first preset image in the target page to obtain a first page, wherein the first page includes at least nodes and child nodes corresponding to the nodes; a first generation unit, used to take a screenshot of the first page to generate a first image; a first acquisition unit, used to acquire a second preset image corresponding to the child node; and a first testing unit, used to test the target page based on the first image, the first preset image, and the second preset image.
[0128] For example, after obtaining subsequent operation information (such as the coordinates of the image), operations such as mouse movement and text input can be performed based on the corresponding information. For instance, moving the mouse to a specified coordinate can trigger a click operation. Specifically, first, the position of the corresponding node within the entire image is obtained, then the mouse movement position is calculated, and then the mouse is moved to the calculated mouse movement position and a click operation is performed (interaction can be performed using testing framework methods). Then, conditional checks are performed, such as checking if the image (or text) exists, checking if the complete image is consistent, etc., and the webpage is tested based on the results.
[0129] The above solutions can address the shortcomings of basic web testing frameworks in terms of coverage (such as canvas testing), enabling comprehensive page testing.
[0130] Optionally, in the page testing device provided in this application embodiment, the first testing unit includes: a first judgment submodule, used to determine whether a first preset image and a second preset image exist in the first image; a first acquisition submodule, used to acquire the attribute information of the first preset image and the second preset image in the first image respectively if the first preset image and the second preset image exist in the first image; a second judgment submodule, used to determine whether the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and to determine whether the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page; a first determination submodule, used to indicate that the target page is normal if the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page; and a second determination submodule, used to indicate that the target page is abnormal if the attribute information of the first preset image in the first image is not the same as the attribute information of the node in the target page, and / or the attribute information of the second preset image in the first image is not the same as the attribute information of the child node in the first page.
[0131] For example, after moving the mouse to the calculated mouse position and performing a click operation, the specific process for conditional judgment can be: checking if the image (or text) exists, checking if the complete image is consistent, or other methods that can be used for image judgment. If the judgment is successful and there are subsequent operations, continue to execute the subsequent operations. If there are no subsequent operations, it means that the webpage is normal. If the judgment fails, it means that the webpage is abnormal and the test ends.
[0132] The above method allows for quick and accurate testing of the page.
[0133] Optionally, in the page testing device provided in this application embodiment, the second acquisition module includes: a first judgment unit, used to determine whether a first preset image exists in the target image; a second acquisition unit, used to acquire the attribute information of the first preset image in the target image if the first preset image exists in the target image; a second judgment unit, used to determine whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; and a third acquisition unit, used to acquire the position information of the first preset image in the target image if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page.
[0134] For example, after cropping an image according to requirements, the information needed for subsequent operations can be obtained from the cropped image and the preset image (the first preset image mentioned above).
[0135] For example, images can be recognized and matched using open-source libraries. The test framework reads the preset image (or text) and the image generated by the page in the current step and inputs them into the image recognition system. It checks whether the corresponding image exists and its corresponding coordinates (there can be multiple coordinates), as well as the size and quantity of the preset image in the new image. It then makes a judgment. If all the above information is confirmed to be correct, the subsequent operation continues to obtain the position of the first preset image in the screenshot of the webpage (the target image mentioned above). If there are any errors in the above information, the subsequent operation cannot continue, that is, the position of the first preset image in the screenshot of the webpage (the target image mentioned above) cannot be obtained, and it is necessary to obtain this information again and make a judgment.
[0136] The above method can quickly and accurately determine the position of the preset image in the screenshot of the page.
[0137] Optionally, in the page testing device provided in the embodiments of this application, the device further includes: a first judgment module, used to determine whether the first preset image exists in the target image after acquiring the target image and the first preset image; a third acquisition module, used to acquire the attribute information of the first preset image in the target image if the first preset image exists in the target image; a second judgment module, used to determine whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; a first determination module, used to indicate that the target page is normal if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; and a second determination module, used to indicate that the target page is abnormal if the attribute information of the first preset image in the target image is different from the attribute information of the node in the target page.
[0138] For example, after entering the page and capturing the entire page, the system can first determine if a preset image (the first preset image mentioned above) exists. If it exists, the image recognition function is then called to find the preset image's attribute information, such as whether the number of preset images in the complete screenshot matches the preset real data, whether the size of the preset images in the complete screenshot matches the preset real data, and whether the position of the preset images in the complete screenshot matches the preset real data. If all of the above attribute information is correctly determined, the page is normal. If any one or more of the above attribute information is incorrect, the page is abnormal. Additionally, if the preset image (the first preset image mentioned above) is determined not to exist, it also indicates a page abnormality.
[0139] The above solution simplifies the testing process. Users only need to know the operation flow and perform interactive operations based on visual matching to complete automated testing.
[0140] Optionally, in the page testing device provided in the embodiments of this application, the first acquisition module includes: a fourth acquisition unit for acquiring the target page to be tested; a first setting unit for setting the size of the target page to obtain a second page; a fifth acquisition unit for acquiring a script for converting the page into an image; and a first conversion unit for executing the script to convert the second page into a target image.
[0141] For example, a web page can be started and loaded using a web automation testing tool; then the page size can be set, meaning that the page can be set to different sizes during the test to complete tests at different page sizes; then a script to generate an image can be injected, meaning that a JavaScript script can be injected into the browser through a web testing framework, and then the script can be used to generate an image (the target image mentioned above).
[0142] The above method allows for quick and accurate acquisition of screenshots of the page. Furthermore, by adjusting the page size, it's possible to test display at different resolutions and precisely match the location of test points.
[0143] Optionally, in the page testing device provided in the embodiments of this application, the first conversion unit includes: a second acquisition submodule, used to execute a script to acquire the ID information of each node in the second page; and a third determination submodule, used to obtain a target image based on the ID information of each node in the second page.
[0144] For example, if the testing framework doesn't support image generation, it can be done using JavaScript. The JavaScript is injected into the browser through the web testing framework. This injected JavaScript is then invoked by the testing tools to generate the corresponding image based on the passed parameters. For example, it can generate an image based on the ID of a DOM node, or generate an image of the entire page. The generated image is then sent back to the testing framework.
[0145] Using the above method and scripts, you can quickly and accurately obtain screenshots of the page.
[0146] The testing device for the page includes a processor and a memory. The first acquisition module 601, the second acquisition module 602, the first trigger module 603, and the first test module 604 are all stored in the memory as program units. The processor executes the program units stored in the memory to achieve the corresponding functions.
[0147] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and the performance of the test page can be improved by adjusting kernel parameters.
[0148] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0149] This invention provides a computer-readable storage medium storing a program thereon, which, when executed by a processor, implements a method for testing the page.
[0150] This invention provides a processor for running a program, wherein the program executes a test method for the page during runtime.
[0151] This invention provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: acquiring a target image and a first preset image, wherein the target image is an image corresponding to a target page to be tested, and the first preset image is an image corresponding to a node in the target page; acquiring the position information of the first preset image in the target image; triggering a target instruction based on the position information of the first preset image in the target image, wherein the target instruction indicates that a target operation is performed on the first preset image in the target page; and testing the target page based on the target instruction.
[0152] When the processor executes the program, it also performs the following steps: testing the target page based on the target instruction includes: responding to the target instruction, performing a target operation on the first preset image on the target page to obtain a first page, wherein the first page includes at least the node and the child nodes corresponding to the node; taking a screenshot of the first page to generate a first image; obtaining a second preset image corresponding to the child node; and testing the target page based on the first image, the first preset image, and the second preset image.
[0153] When the processor executes the program, it also performs the following steps: testing the target page based on the first image, the first preset image, and the second preset image, including: determining whether the first preset image and the second preset image exist in the first image; if the first preset image and the second preset image exist in the first image, then obtaining the attribute information of the first preset image and the second preset image in the first image respectively; determining whether the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and determining whether the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page; if the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page, then the target page is normal; if the attribute information of the first preset image in the first image is different from the attribute information of the node in the target page, and / or, the attribute information of the second preset image in the first image is different from the attribute information of the child node in the first page, then the target page is abnormal.
[0154] When the processor executes the program, it also performs the following steps: obtaining the position information of the first preset image in the target image includes: determining whether the first preset image exists in the target image; if the first preset image exists in the target image, obtaining the attribute information of the first preset image in the target image; determining whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page, obtaining the position information of the first preset image in the target image.
[0155] When the processor executes the program, it also performs the following steps: After acquiring the target image and the first preset image, the method further includes: determining whether the first preset image exists in the target image; if the first preset image exists in the target image, acquiring the attribute information of the first preset image in the target image; determining whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page, it indicates that the target page is normal; if the attribute information of the first preset image in the target image is different from the attribute information of the node in the target page, it indicates that the target page is abnormal.
[0156] When the processor executes the program, it also performs the following steps: obtaining the target image includes: obtaining the target page to be tested; setting the size of the target page to obtain a second page; obtaining a script for converting the page into an image; and executing the script to convert the second page into the target image.
[0157] When the processor executes the program, it also performs the following steps: executing the script to convert the second page into the target image includes: executing the script to obtain the ID information of each node in the second page; and obtaining the target image based on the ID information of each node in the second page.
[0158] The devices mentioned in this article can be servers, PCs, tablets, mobile phones, etc.
[0159] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: acquiring a target image and a first preset image, wherein the target image is an image corresponding to a target page to be tested, and the first preset image is an image corresponding to a node in the target page; acquiring the position information of the first preset image in the target image; triggering a target instruction based on the position information of the first preset image in the target image, wherein the target instruction is used to indicate performing a target operation on the first preset image in the target page; and testing the target page based on the target instruction.
[0160] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: testing the target page based on the target instruction includes: responding to the target instruction, performing a target operation on the first preset image on the target page to obtain a first page, wherein the first page includes at least the node and the child nodes corresponding to the node; taking a screenshot of the first page to generate a first image; obtaining a second preset image corresponding to the child node; and testing the target page based on the first image, the first preset image, and the second preset image.
[0161] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: Testing the target page based on the first image, the first preset image, and the second preset image, including: determining whether the first preset image and the second preset image exist in the first image; if the first preset image and the second preset image exist in the first image, then obtaining the attribute information of the first preset image and the second preset image in the first image respectively; determining whether the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and determining whether the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page; if the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page, then the target page is normal; if the attribute information of the first preset image in the first image is different from the attribute information of the node in the target page, and / or, the attribute information of the second preset image in the first image is different from the attribute information of the child node in the first page, then the target page is abnormal.
[0162] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: obtaining the position information of the first preset image in the target image includes: determining whether the first preset image exists in the target image; if the first preset image exists in the target image, obtaining the attribute information of the first preset image in the target image; determining whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page, obtaining the position information of the first preset image in the target image.
[0163] When executed on a data processing device, the method is also suitable for executing an initialization program with the following steps: after acquiring a target image and a first preset image, the method further includes: determining whether the first preset image exists in the target image; if the first preset image exists in the target image, acquiring the attribute information of the first preset image in the target image; determining whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; if the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page, the target page is normal; if the attribute information of the first preset image in the target image is different from the attribute information of the node in the target page, the target page is abnormal.
[0164] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: obtaining a target image includes: obtaining a target page to be tested; setting the size of the target page to obtain a second page; obtaining a script for converting the page into an image; and executing the script to convert the second page into the target image.
[0165] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: executing the script to convert the second page into the target image includes: executing the script to obtain the ID information of each node in the second page; and obtaining the target image based on the ID information of each node in the second page.
[0166] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0167] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0168] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0169] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0170] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0171] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0172] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0173] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0174] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0175] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method of testing a page, characterized by, include: Obtain a target image and a first preset image, wherein the target image is the image corresponding to the target page to be tested, and the first preset image is the image corresponding to a node in the target page; Obtain the position information of the first preset image in the target image; Based on the position information of the first preset image in the target image, a target instruction is triggered, wherein the target instruction is used to indicate that a target operation is performed on the first preset image in the target page; Based on the target instruction, testing the target page includes: responding to the target instruction, performing a target operation on the first preset image on the target page to obtain a first page, wherein the first page includes at least the node and the child nodes corresponding to the node; taking a screenshot of the first page to generate a first image; obtaining a second preset image corresponding to the child node; and testing the target page based on the first image, the first preset image, and the second preset image. The testing of the target page based on the first image, the first preset image, and the second preset image includes: determining whether the first preset image and the second preset image exist in the first image; if the first preset image and the second preset image exist in the first image, obtaining the attribute information of the first preset image and the second preset image in the first image respectively; determining whether the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and determining whether the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page; if the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page, then the target page is normal; if the attribute information of the first preset image in the first image is different from the attribute information of the node in the target page, and / or, the attribute information of the second preset image in the first image is different from the attribute information of the child node in the first page, then the target page is abnormal.
2. The method of claim 1, wherein, Obtaining the position information of the first preset image in the target image includes: Determine whether the first preset image exists in the target image; If the first preset image exists in the target image, then obtain the attribute information of the first preset image in the target image; Determine whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; If the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page, then the position information of the first preset image in the target image is obtained.
3. The method according to claim 1, characterized in that, After acquiring the target image and the first preset image, the method further includes: Determine whether the first preset image exists in the target image; If the first preset image exists in the target image, then obtain the attribute information of the first preset image in the target image; Determine whether the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page; If the attribute information of the first preset image in the target image is the same as the attribute information of the node in the target page, then the target page is normal; If the attribute information of the first preset image in the target image is different from the attribute information of the node in the target page, it indicates that the target page is abnormal.
4. The method according to claim 1, characterized in that, Obtaining the target image includes: Get the target page to be tested; The size of the target page is set to obtain the second page; Get the script used to convert the page into an image; The script is executed to convert the second page into the target image.
5. The method according to claim 4, characterized in that, Executing the script to convert the second page into the target image includes: Execute the script to obtain the ID information of each node in the second page; The target image is obtained based on the ID information of each node in the second page.
6. A page testing device, characterized in that, include: The first acquisition module is used to acquire a target image and a first preset image, wherein the target image is an image corresponding to the target page to be tested, and the first preset image is an image corresponding to a node in the target page; The second acquisition module is used to acquire the position information of the first preset image in the target image; The first triggering module is used to trigger a target instruction based on the position information of the first preset image in the target image, wherein the target instruction is used to indicate that a target operation is performed on the first preset image in the target page; The first testing module is used to test the target page based on the target instruction; The first testing module includes: a first response unit, configured to respond to the target instruction and perform a target operation on the first preset image on the target page to obtain a first page, wherein the first page includes at least the node and its corresponding child nodes; a first generation unit, configured to take a screenshot of the first page to generate a first image; a first acquisition unit, configured to acquire a second preset image corresponding to the child node; and a first testing unit, configured to test the target page based on the first image, the first preset image, and the second preset image. The first testing unit includes: a first judgment submodule, used to determine whether the first preset image and the second preset image exist in the first image; a first acquisition submodule, used to acquire the attribute information of the first preset image and the second preset image in the first image if the first preset image and the second preset image exist in the first image; a second judgment submodule, used to determine whether the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and to determine whether the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page; a first determination submodule, used to indicate that the target page is normal if the attribute information of the first preset image in the first image is the same as the attribute information of the node in the target page, and the attribute information of the second preset image in the first image is the same as the attribute information of the child node in the first page; and a second determination submodule, used to indicate that the target page is abnormal if the attribute information of the first preset image in the first image is not the same as the attribute information of the node in the target page, and / or the attribute information of the second preset image in the first image is not the same as the attribute information of the child node in the first page.
7. A computer-readable storage medium, characterized in that, The storage medium stores a program, wherein the program executes the page testing method according to any one of claims 1 to 5.
8. A processor for a page testing method, characterized in that, The processor is used to run a program, wherein the program executes the page testing method according to any one of claims 1 to 5 when it runs.