A page display result test method and device, a storage medium and an equipment

By comparing the pixel dimensions of a screenshot taken with a headless browser with a benchmark image, this method solves the problem of complex and time-consuming automated testing of page display effects in existing technologies, and achieves efficient and accurate testing of page display effects.

CN114116440BActive Publication Date: 2026-11-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010906468.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-01
Publication Date
2026-11-27
Estimated Expiration
2040-09-01

AI Technical Summary

Technical Problem

In existing technologies, automated testing of page display effects requires highly skilled testers, has low script reusability, and relies on browser interfaces, resulting in a complex and time-consuming execution environment, making it impossible to comprehensively test page display effects.

Method used

The target page is accessed using a headless browser, a screenshot is taken and compared pixel by pixel with a baseline image. The resemble.js tool is used for pixel comparison to determine the page display result.

Benefits of technology

It decouples automated testing of page display effects from page design, reduces the workload of testers, improves testing efficiency and accuracy, and adapts to various execution environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114116440B_ABST
    Figure CN114116440B_ABST
Patent Text Reader

Abstract

The application discloses a page display result test method and device, a storage medium and equipment, and the method comprises the following steps: obtaining a target page address; accessing the target page address through a non-interface browser to obtain an access result; taking a screenshot of the access result in the non-interface browser to obtain a screenshot picture; obtaining a reference picture corresponding to the target page address, wherein the reference picture is a picture of a design page corresponding to the target page address; performing pixel comparison on the screenshot picture and the reference picture to obtain a pixel comparison result; and determining a test result of the page display result according to the pixel comparison result. The update of the reference picture and the update of the code to be tested do not affect the reuse of the test method, so that the test method of the page display result is decoupled from the page design and the page development process, the test script no longer needs to be frequently modified, the test effect is significantly improved, and the pressure of the tester is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of page testing, and in particular to a method, apparatus, storage medium, and device for testing page display results. Background Technology

[0002] In the internet industry, a website typically consists of dozens or even hundreds of individual pages. Due to constantly evolving requirements, developers frequently modify page structure, styles, and content. On the other hand, the level of automation in testing is limited; automated testing usually focuses more on testing user actions. Page inspection typically only includes element positioning and CSS style property checks, with insufficient monitoring of the overall page style, making it difficult to guarantee quality. The frequent updates to the pages under test and the lack of automation lead to excessively high manual testing costs. Frequent modifications to test scripts place a heavy burden on testers and reduce the stability of the testing process.

[0003] Furthermore, existing automated testing places high demands on test scripts. For example, detecting page element styles requires testers to be familiar with the relevant code and organize test cases to obtain the desired results. Each page update also necessitates modifying the test scripts, adding extra workload for both developers and testers. Summary of the Invention

[0004] To improve the efficiency of automated testing of page display effects and to provide a testing scheme for page display effects that can adapt to various execution environments, embodiments of this specification disclose a method, apparatus, storage medium, and device for testing page display results.

[0005] On the one hand, this specification provides a method for testing page display results, the method comprising:

[0006] Get the target page address;

[0007] Access the target page address through a headless browser to obtain the access result;

[0008] Take a screenshot of the access results in the headless browser to obtain a screenshot image;

[0009] The screenshot image and the reference image are compared pixel by pixel to obtain the pixel comparison result, wherein the reference image is the image corresponding to the design page corresponding to the target page address;

[0010] The test result of the page display result is determined based on the pixel comparison result.

[0011] On the other hand, this specification provides a page display result testing device, the device comprising:

[0012] The target page address acquisition module is used to obtain the target page address;

[0013] The access result acquisition module is used to access the target page address through a headless browser and obtain the access result.

[0014] The screenshot module is used to take screenshots of the access results in the headless browser and obtain screenshot images;

[0015] A pixel comparison module is used to perform pixel comparison between the screenshot image and the reference image to obtain a pixel comparison result, wherein the reference image is the image corresponding to the design page corresponding to the target page address;

[0016] The test result determination module is used to determine the test result of the page display result based on the pixel comparison result.

[0017] On the other hand, this specification provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores at least one instruction or at least one program, which is loaded and executed by a processor to implement the above-described page display result testing method.

[0018] On the other hand, this specification provides a page display result testing device, characterized in that it includes at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the at least one processor implements the above-mentioned page display result testing method by executing the instructions stored in the memory.

[0019] This specification provides a method, apparatus, storage medium, and device for testing page display results. This specification achieves page display effect testing by using a headless browser to access and capture the page under test, and then comparing the screenshot results with a benchmark image pixel by pixel. The benchmark image is independent of the test code; therefore, updates to the benchmark image and the corresponding code under test will not affect the reusability of the test method. This decouples the page display result testing method from the page design and the page development process, eliminating the need for frequent modifications to test scripts, significantly improving testing effectiveness, and reducing the workload of testers. Attached Figure Description

[0020] To more clearly illustrate the technical solutions and advantages in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 This is a schematic diagram of a page display result testing method provided in this manual;

[0022] Figure 2 This is a schematic diagram of the process of accessing the target page address through a headless browser, as provided in this manual;

[0023] Figure 3 This manual provides a schematic diagram of the device environment configuration for running the headless browser according to testing requirements.

[0024] Figure 4 This is a schematic diagram of the page display provided in this manual;

[0025] Figure 5 This is a flowchart illustrating the process of accessing the page pointed to by the target page address in the tab and obtaining the access result, as provided in this specification.

[0026] Figure 6 This is a flowchart illustrating the process of comparing the pixels of the screenshot image and the reference image to obtain the pixel comparison result, provided in this specification.

[0027] Figure 7 This is a schematic diagram of the test result process for determining the page display result based on the pixel comparison results provided in this specification;

[0028] Figure 8 This is the first target schematic diagram for pixel comparison provided in this manual;

[0029] Figure 9 This is a schematic diagram of the second target for pixel comparison provided in this manual;

[0030] Figure 10 This is a schematic diagram of the pixel comparison results provided in this manual;

[0031] Figure 11 This is a block diagram of a page display result testing device provided in this manual;

[0032] Figure 12 This is a schematic diagram of the hardware structure of a device for implementing the methods provided in the embodiments of this specification. Detailed Implementation

[0033] The technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0034] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention 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 so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or 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 server 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 devices.

[0035] To make the objectives, technical solutions, and advantages disclosed in the embodiments of this specification clearer, the embodiments of this specification will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the embodiments of this specification and are not intended to limit the scope of the embodiments described herein.

[0036] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise stated, "multiple" means two or more. To facilitate understanding of the technical solutions described in the embodiments of this specification and their resulting technical effects, the embodiments of this specification first explain the relevant technical terms:

[0037] Headless browsers: These are browsers that do not require a graphical user interface, also known as headless browsers. Headless browsers can use scripts to perform various operations of browsers with interfaces, simulating various usage scenarios of real browsers with interfaces.

[0038] PhantomJS: A headless browser that not only provides features such as CSS selectors, support for web standards, DOM manipulation, JSON, HTML5, Canvas, and SVG as an invisible browser, but also provides file I / O handling capabilities.

[0039] Puppeteer: A headless browser, the official headless tool from the Google Chrome team, providing a high-level application programming interface (API) for controlling the headless browser. Most tasks that users perform manually in a browser can be accomplished through commands in Puppeteer.

[0040] resemble.js: An open-source image pixel comparison tool. The calling method can be simply understood as taking two images as input and returning a composite image along with comparison parameters such as the degree of difference.

[0041] CSS (Cascading Style Sheets) is a stylesheet language used to describe the rendering of an HTML document. CSS describes how elements should be rendered on screen, print, audio, and other media.

[0042] RTF stands for Rich Text Format; it's a cross-platform document format. As a very popular file structure, rich text is supported by many text editors. Common formatting settings, such as font and paragraph settings, page setup, etc., can be stored in RTF format. Rich text can include formulas, fonts, images, layout, special characters, etc.

[0043] Automated testing: Automated testing is the process of using programs to verify program functionality instead of human intervention. By writing test cases, programs can automatically execute events, such as simulating user clicks, obtaining corresponding output results, and comparing them with expected results. Commonly used frameworks for automated web page testing include Selenium and JMeter.

[0044] JMeter: A Java-based stress testing tool developed by the Apache Software Foundation, capable of performing performance and interface tests on HTTP and FTP servers.

[0045] Selenium is a web-based automated testing tool that provides a series of test functions to support web automation testing. These functions can locate UI elements in various ways. With the introduction of WebDriver in Selenium 2.x, a completely different way of interacting with the browser was enabled. This involved using the browser's native application programming interface (API), encapsulated into a more object-oriented Selenium WebDriver API, to directly manipulate elements within the browser page and even control the browser itself (screenshotting, window resizing, starting, closing, installing plugins, configuring certificates, etc.). Because it uses the browser's native API, the speed is greatly improved, and the stability of the calls is entrusted to the browser vendor, which is clearly a more efficient approach.

[0046] DOM: Document Object Model; it is a standard that defines a set of properties, methods, and events for accessing HTML document objects.

[0047] HTML: Hyper Text Markup Language; it is a markup language. It consists of a series of tags. These tags can standardize the format of documents on the web, connecting scattered online resources into a logical whole. HTML text is descriptive text composed of HTML commands, which can specify text, graphics, animations, sounds, tables, links, etc.

[0048] The technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0049] In existing technologies, automated testing of page display effects requires a high level of human expertise. Testers need to write test scripts based on a thorough understanding of the page's rendering code and user operating habits, and then automate the testing of page display effects by running test cases. This testing method places high demands on testers, and modifications to page code, user operation paths, and operation commands may lead to modifications of the test scripts. The reusability of test scripts is low, which places a heavy burden on testers.

[0050] To improve the efficiency of automated testing of page display effects and reduce the burden on testers, existing technologies offer an image comparison testing solution. For example, image comparison can be implemented based on the automated testing framework Selenium WebDriver to automate testing and achieve the goal of testing page display effects. Specifically, this solution involves launching a real browser with a GUI to take screenshots of the page, and then comparing the screenshots to achieve the purpose of testing page display effects. However, this solution relies on a browser with a GUI, making the execution environment complex and time-consuming; when the page is too long, exceeding the length of one screen, it is impossible to capture the undisplayed portion of the screen, thus making it impossible to test the display effects of the undisplayed parts of the page.

[0051] In view of this, in order to improve the efficiency of automated testing of page display effects and to provide a testing scheme for page display effects that can adapt to various execution environments, this specification provides a method for testing page display results.

[0052] The following describes one method for testing page display results in this manual. Figure 1 This is a flowchart illustrating a page display result testing method provided in an embodiment of this specification. This specification provides the operational steps of the method described in the embodiment or flowchart, but based on conventional or non-inventive labor, more or fewer operational steps may be included. The order of steps listed in the embodiment is merely one possible execution order among many and does not represent the only possible execution order. In actual system or server product execution, the method can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment) as shown in the embodiment or accompanying drawings. Specifically, as... Figure 1 As shown, the method may include:

[0053] S101. Obtain the target page address.

[0054] Specifically, the target page address can be recorded in a configuration file or a test script file. The target page address can be the website's homepage address, or any address determined during various feasible operations on the website. The target page address points to the page to be rendered. The page can be based on CSS layout or can express various data in rich text format. This specification does not impose special limitations on the specific structure and content of the page in the embodiments.

[0055] S103. Access the target page address through a headless browser to obtain the access result.

[0056] In one embodiment, the headless browser can be PhantomJS or Puppeteer, and the headless browser can simulate the runtime environment of a real browser with a user interface.

[0057] The method of accessing the target page address through a headless browser, such as Figure 2 As shown, it includes:

[0058] S1031. Launch the headless browser.

[0059] Taking Puppeteer as an example of a headless browser, Puppeteer can be launched using the `pupperteer.launch()` method.

[0060] In one embodiment, a corresponding device environment can be set for the headless browser to achieve the purpose of testing multiple devices based on the headless browser. Specifically, the device environment may include at least one of the following: device model, device type, size information, visible area of ​​the device, and resolution of the visible area. For example, the size information of commonly used terminal devices can be understood as the size information of terminal devices currently sold on the market, such as 375px, 534px, and 768px. This size information of terminal devices can be used to form the device environment.

[0061] For example, before launching the headless browser, the process includes: configuring the device environment in which the headless browser runs according to testing requirements.

[0062] Specifically, the device environment for running the headless browser is configured according to testing requirements, such as... Figure 3 As shown, it includes:

[0063] S1. Set the visible area parameters adapted to the tabs in the headless browser. The visible area parameters are used to characterize the range information of the visible area of ​​the device, such as size, position and other information.

[0064] In one embodiment, parameter settings can be implemented through a viewport class. The viewport class can be set to a default value or changed according to specific testing requirements. For example, in Puppeteer, the `defaultViewport` viewport class can be used to represent the initial viewport-related parameters. During actual setup, the `setViewport()` method can be used to set the specific data of the viewport class. For example, the following command can be used to set a viewport with a width of 1080 and a height of 1920:

[0065] await page.setViewport({

[0066] width:1080,

[0067] height: 1920,

[0068] });

[0069] Where "page" represents the tab opened by the headless browser.

[0070] S2. Set the device that the tabs in the headless browser are adapted to, and the headless browser uses the device as the running device to access the tabs to simulate the tab access process.

[0071] Accordingly, after the headless browser is launched, the device environment can be used as the running environment when the headless browser accesses tabs.

[0072] For example, the device can be set to an iPhone 6. After opening a headless browser, the device can be imported into the headless browser, and the browser can then simulate the device opening a tab. Using Puppeteer as an example, the device can be imported through the DeviceDescriptors tool, and the emulate() method can be used to simulate the device opening a tab. Specifically, the following command can be executed:

[0073]

[0074] The embodiments in this specification enable a headless browser to simulate the effects of running in various device environments by setting the visible area class and device, thereby improving the coverage of test scenarios and facilitating the testing of the display effect of the page in different device environments.

[0075] S1033. Open a tab in the headless browser.

[0076] Specifically, the tab can be a blank new tab, which can be opened in Puppeteer using the newPage() method.

[0077] S1035. Access the page pointed to by the target page address in the tab.

[0078] Specifically, in Puppeteer, the goto() method can be used to access the page pointed to by the target page address and wait for the page to finish rendering.

[0079] Furthermore, in scenarios where a page is opened from the target page address via a tab, there may be scopes, content, or objects that do not require testing, such as user personal data. If the page contains user personal data, the display results of the rendered personal data portion may differ between different users. In other words, the display of personal data on the page is personalized, and the testing of the page display effect should filter out the personalized effects and focus on whether the display of the page's own elements is reasonable. For example, layout and the display of non-user personal data are elements of the page itself. For instance, testing the page display effect includes, but is not limited to, testing the reasonableness of text rendering, formula rendering, formatting, font rendering, paragraph rendering, etc., in the display of non-user personal data. The display of non-user personal data can be in the form of rich text or simple text content; this specification does not impose any special limitations on these embodiments.

[0080] like Figure 4 As shown, taking user personal data as an example, the part enclosed in the box belongs to the user's personal data. Obviously, the content and amount of personal data of different users are different, which may cause the displayed part enclosed in the box to be different. However, this difference is not an error. Therefore, this interference should be eliminated when testing the page display effect.

[0081] For example, in one embodiment, the step of accessing the page pointed to by the target page address in the tab and obtaining the access result is as follows: Figure 5 As shown, it includes:

[0082] S10351. Obtain the script code corresponding to the page in the tab.

[0083] S10353. Extract at least one target node from the script code, wherein the page element corresponding to the target node does not participate in pixel comparison.

[0084] Specifically, in the embodiments of this specification, the page display effect is evaluated by pixel comparison. In step S10353, by excluding the page element corresponding to the target node from the pixel comparison process, the display result of the page element of the target node does not affect the pixel comparison result, and thus does not affect the test result. This eliminates the interference of the scope, content or object that does not need to be tested on the page display effect.

[0085] Specifically, the target node can be marked using the `html class` attribute. For example, developers can mark page elements that do not need to participate in page display testing during page programming, and in S10353, these page elements can be extracted based on the markings to obtain the target node.

[0086] For example, the html class of nodes in the DOM corresponding to the script code of the page that do not need to be compared by pixels can be marked as not-compare; accordingly, the target node can be obtained by extracting the nodes marked as not-compare in step S10353.

[0087] S10355. The execution result of the script code in the tab is combined with the target node set formed by the at least one target node as the access result.

[0088] S105. Take a screenshot of the access results in the headless browser to obtain a screenshot image.

[0089] Specifically, taking the headless browser Puppeteer as an example, you can use the `screenshot()` method to take a screenshot of the page and save the screenshot as an image. For example, the following code can be executed to save the screenshot:

[0090] await page.screenshot({path:test.png'}); / / Take a screenshot in the page tab and save it as a PNG image.

[0091] Specifically, if the display result of the page corresponding to the access result is too long and exceeds the screen display length limited by the device adapted to the tab, the undisplayed part is also captured and used together with the displayed part as a complete screenshot image, so that the screenshot image can reflect the complete display result without being limited by the physical size of the screen.

[0092] S107. Obtain the reference image corresponding to the target page address, wherein the reference image is an image of the design page corresponding to the target page address.

[0093] Specifically, the reference image can be a design draft in image format that corresponds to the visual effect of the target page address, actually designed by the page design engineer. Specifically, the design page may or may not be related to the specific device environment. The design page is unrelated to historical access behavior to the target page address.

[0094] S109. Perform pixel comparison between the screenshot image and the reference image to obtain the pixel comparison result.

[0095] In one embodiment, if the access result includes a target node set, then the screenshot image and the reference image are compared pixel by pixel to obtain a pixel comparison result, such as... Figure 6 As shown, it includes:

[0096] S1091. Determine a first comparison image based on the screenshot image, wherein the first comparison image does not contain the page element matched by the target node set;

[0097] S1093. Determine a second comparison image based on the reference image, wherein the second comparison image does not contain the page elements matched by the target node set;

[0098] S1095. Perform pixel comparison between the first comparison image and the second comparison image to obtain the pixel comparison result.

[0099] In one embodiment, pixel comparison can be performed based on an image pixel comparison tool. Specifically, the compareTo() method of resemble.js can be used for pixel comparison.

[0100] S1011. Determine the test result of the page display result based on the pixel comparison result.

[0101] Specifically, the test result for determining the page display result based on the pixel comparison result is as follows: Figure 7 As shown, it includes:

[0102] S10111. Obtain the difference similarity based on the pixel comparison results.

[0103] Specifically, if the compareTo() method of resemble.js is used for pixel comparison, the difference similarity can be obtained through the misMatchPercentage property. The difference similarity represents the proportion of the difference in the pixel comparison result. The higher the difference similarity, the greater the difference between the objects participating in the pixel comparison. A difference similarity of 1 indicates that the objects participating in the pixel comparison are completely different.

[0104] S10113. If the difference similarity is less than a preset threshold, the page display result is determined to be normal.

[0105] S10115. If the difference similarity is greater than or equal to a preset threshold, the page display result is determined to be abnormal.

[0106] In one embodiment, if the page displays an abnormal result, an error alarm is output.

[0107] In another embodiment, the pixel comparison results can be directly output, and the differences in the pixel comparison results can be labeled. Please refer to [reference needed]. Figure 8 It shows the first target for pixel comparison; please refer to Figure 9 This shows the second target for pixel matching; please refer to... Figure 10 It shows the pixel comparison results, in Figure 10The differences between the two targets are marked in black, while the similarities are marked in white.

[0108] This specification discloses a method for testing page display results. It utilizes a headless browser to access and capture the page under test, then compares the screenshots with a baseline image pixel by pixel to test the page display effect. The baseline image is independent of the test code; therefore, updates to the baseline image and the corresponding code under test do not affect the reusability of the test method. This decouples the page display result testing method from the page design and development process, eliminating the need for frequent modifications to test scripts, significantly improving testing effectiveness, and reducing the workload of testers. Clearly, the testing method in this specification is particularly suitable for scenarios with frequent iterations in the design or development stages. It can significantly save testing time, ensure development quality, reduce style errors, and thus effectively improve user access quality, providing users with a better visual experience.

[0109] Furthermore, compared to existing technologies that use real GUI browsers, headless browsers are more convenient for automated testing using scripts, have a simpler execution environment, and higher testing efficiency. By comparing pixels with a benchmark image to obtain pixel comparison results, and then obtaining test results based on the pixel comparison results, both reliability and automation are significantly improved.

[0110] This specification also discloses a page display result testing device, such as... Figure 11 As shown, the device includes:

[0111] The target page address acquisition module 201 is used to acquire the target page address.

[0112] The access result acquisition module 203 is used to access the target page address through a headless browser and obtain the access result.

[0113] Screenshot module 205 is used to take a screenshot of the access results in the headless browser and obtain a screenshot image;

[0114] The pixel comparison module 207 is used to perform pixel comparison between the screenshot image and the reference image to obtain a pixel comparison result, wherein the reference image is the image corresponding to the design page corresponding to the target page address;

[0115] The test result determination module 209 is used to determine the test result of the page display result based on the pixel comparison result.

[0116] Specifically, the page display result testing device disclosed in this specification and the corresponding method embodiment described above are both based on the same inventive concept. For details, please refer to the method embodiment; further elaboration will not be repeated here.

[0117] This specification also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the page display result testing method described above.

[0118] This specification also provides a computer-readable storage medium that can store multiple instructions. These instructions are adaptable for loading and execution by a processor of a page display result testing method described in this specification.

[0119] Furthermore, Figure 12 A schematic diagram of a hardware structure for implementing the methods provided in the embodiments of this specification is shown. This device may constitute or include the apparatus or system provided in the embodiments of this specification. Figure 12 As shown, device 10 may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 12 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, device 10 may also include a... Figure 12 The more or fewer components shown, or having the same Figure 12 The different configurations shown.

[0120] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuitry are generally referred to herein as "data processing circuitry". This data processing circuitry may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuitry may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within device 10 (or mobile device). As described in the embodiments of this specification, this data processing circuitry serves as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0121] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the methods described in the embodiments of this specification. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the above-described page display result testing method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the device 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0122] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of device 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a radio frequency (RF) module used for wireless communication with the Internet.

[0123] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows a user to interact with the user interface of device 10 (or a mobile device).

[0124] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments of this specification have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0125] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and server embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0126] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0127] The above description is only a preferred embodiment of this specification and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for testing page display results, characterized in that, The method includes: Read the target page address from the test script; According to the testing requirements, the visible area parameters adapted to the tabs in the headless browser are set. The visible area parameters are used to characterize the range information of the visible area of ​​the device. The device adapted to the tabs in the headless browser is set. The headless browser uses the device as the running device to access the tabs to simulate the access process of the tabs, so that the headless browser simulates the effect of running in the environment of the device. The environment of the device is used as the operating environment when the headless browser accesses the tab. The headless browser is launched and the tab is opened in the headless browser. Obtain the script code corresponding to the page in the tab; extract at least one target node from the script code; the target node is a page element marked in the DOM by the developer during programming, indicating that it will not participate in the test; use the execution result of the script code in the tab and the target node set composed of the at least one target node as the access result; The portion of the access result that exceeds the screen display length limit of the device is captured together with the portion that does not exceed the display length to obtain a screenshot image; a first comparison image is determined based on the screenshot image, the first comparison image does not contain the page elements matched by the target node set; A second comparison image is determined based on a reference image. The second comparison image does not contain the page elements matched by the target node set. The reference image is a design draft that expresses the performance effect of the target page, and the design draft is independent of the specific device environment, historical access behavior for the target page address, and code. Pixel comparison is performed on the first comparison image and the second comparison image to obtain the pixel comparison result; the test result of the page display result is determined based on the pixel comparison result.

2. The method according to claim 1, characterized in that, The test result for determining the page display result based on the pixel comparison result includes: The difference similarity is obtained based on the pixel comparison results; If the difference similarity is less than a preset threshold, the page display result is determined to be normal; If the difference similarity is greater than or equal to a preset threshold, the page display result is determined to be abnormal.

3. A page display result testing device, characterized in that, include: The target page address acquisition module is used to read the target page address in the test script; The device is also used to: set the visible area parameters adapted to the tabs in the headless browser according to the test requirements, wherein the visible area parameters are used to characterize the range information of the visible area of ​​the device; The browser is configured to adapt to the devices of the tabs in the headless browser. The headless browser uses the device as the running device to access the tabs and simulates the access process of the tabs, so that the headless browser simulates the effect of running in the environment of the device. The access result acquisition module is used to use the environment of the device as the running environment when the headless browser accesses the tab, launch the headless browser, open the tab in the headless browser, acquire the script code corresponding to the page in the tab, and extract at least one target node from the script code; the target node is a page element marked in the DOM by the developer during programming, indicating that it will not participate in the test; The execution result of the script code in the tab and the target node set formed by the at least one target node are used as the access result; The screenshot module is used to capture the portion of the access result that exceeds the screen display length limit of the device, together with the portion that does not exceed the display length, to obtain a screenshot image; The device is further configured to: determine a first comparison image based on the screenshot image, wherein the first comparison image does not contain the page element hit by the target node set; A second comparison image is determined based on a reference image. The second comparison image does not contain the page elements matched by the target node set. The reference image is a design draft that expresses the performance effect of the target page, and the design draft is independent of the specific device environment, historical access behavior for the target page address, and code. A pixel comparison module is used to perform pixel comparison between the first comparison image and the second comparison image to obtain a pixel comparison result. The test result determination module is used to determine the test result of the page display result based on the pixel comparison result.

4. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction, which is loaded and executed by a processor to implement a page display result testing method as described in claim 1 or 2.

5. A page display result testing device, characterized in that, It includes at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that are executed by the at least one processor, and the at least one processor implements a page display result testing method as described in claim 1 or 2 by executing the instructions stored in the memory.

6. A computer program product, characterized in that, The computer program product may include computer instructions stored in a computer-readable storage medium; the processor of the computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform a page display result testing method as described in claim 1 or 2.

Citation Information

Patent Citations

  • User page testing method based on image recognition and related equipment

    CN110399291A