Test method, device, equipment and medium

By creating a virtual display in a Docker container without a graphical interface and configuring an environment variable lock, the problem of not being able to run a headless browser in a container without a graphical interface is solved, and efficient automated testing is achieved in a non-graphical environment.

CN120723638APending Publication Date: 2025-09-30SHENZHEN QIANHAI HUANRONG LIANYI INFORMATION TECHNOLOGY SERVICES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510830614.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-19
Publication Date
2025-09-30

AI Technical Summary

Technical Problem

It is not possible to effectively run a headless browser in a non-GUI container, which makes it impossible to perform automated tests that rely on real browser GUI interactions.

Method used

Create a virtual display in a Docker container without a graphical interface, and loop through the detection of the occupancy of the environment variable lock. Configure the environment variable lock corresponding to the virtual display, bind the virtual display to the headless browser, and implement parallel execution of test cases.

Benefits of technology

In a non-graphical interface environment, it effectively solves the operation problems of headless browsers, realizes automated testing that relies on real graphical interface interaction, and improves testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723638A_ABST
    Figure CN120723638A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of testing, and provides a testing method and device, equipment and a medium, which can create at least one virtual display in a Docker container without a graphical interface so as to provide normal operation conditions for a test case needing a header browser. Circularly detecting the occupancy condition of the environment variable lock, and configuring the environment variable lock corresponding to each virtual display according to the detection result corresponding to each virtual display and the display identifier of each virtual display, each virtual display and the corresponding head browser are bound according to the environment variable lock corresponding to each virtual display, so that starting failure caused by the fact that threads of the virtual displays preempt the environment variables is avoided; according to the embodiment of the invention, the test case corresponding to the header browser is executed in parallel based on each virtual display, so that the problem that the header browser cannot run on a non-graphical interface to efficiently execute an automatic test can be effectively solved in a test scene needing to depend on real graphical interface interaction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of testing technology, and in particular to a testing method, device, equipment and medium. Background Art

[0002] Traditional automated testing typically runs on operating systems equipped with graphical interfaces (GUIs). However, to improve efficiency, distributed deployment using containers without GUIs is necessary. However, containers without GUIs typically only run headless browsers without an interface.

[0003] In addition, there are many limitations to automated testing on headless browsers without an interface, especially for application scenarios that rely on real graphical interface interactions of the browser, such as visual rendering verification, browser plug-in dependencies, complex interaction simulation, etc. These operations cannot be implemented. Summary of the Invention

[0004] In view of the above, it is necessary to provide a testing method, apparatus, device and medium to solve the problem of being unable to run a headless browser on a non-graphical interface to efficiently perform automated testing.

[0005] A testing method, comprising:

[0006] In response to a test instruction based on a non-graphical interface and a headless browser, create at least one virtual display in the non-graphical interface Docker container, and record a display identifier of each virtual display;

[0007] After creating each virtual display, cyclically detect the occupancy of the environment variable lock to obtain the detection result corresponding to each virtual display;

[0008] configuring an environment variable lock corresponding to each virtual display according to a detection result corresponding to each virtual display and a display identifier of each virtual display;

[0009] Bind each virtual display to the corresponding head browser according to the environment variables corresponding to each virtual display;

[0010] Based on each virtual display, the test cases of the corresponding head browser are executed in parallel to obtain the test results.

[0011] According to a preferred embodiment of the present invention, creating at least one virtual display in the Docker container without a graphical interface includes:

[0012] Obtaining the number of the head browsers as a preset number;

[0013] In the Docker container without a graphical interface, a virtual frame buffer server is controlled based on a PyVirtualDisplay library to start the preset number of virtual display screens.

[0014] According to a preferred embodiment of the present invention, the cyclic detection of the occupancy of the environment variable lock includes:

[0015] Loop to check whether the DISPLAY environment variable has a value.

[0016] According to a preferred embodiment of the present invention, configuring an environment variable lock corresponding to each virtual display according to the detection result corresponding to each virtual display and the display identifier of each virtual display includes:

[0017] When the detection result is that the DISPLAY environment variable has no value, the value of the DISPLAY environment variable is configured as a display identifier corresponding to the virtual display.

[0018] According to a preferred embodiment of the present invention, binding each virtual display to a corresponding headed browser according to an environment variable corresponding to each virtual display includes:

[0019] Launching the head browser based on an automated testing framework;

[0020] Bind each virtual display with a corresponding headed browser via the DISPLAY environment variable.

[0021] According to a preferred embodiment of the present invention, after binding each virtual display to the corresponding head browser according to the environment variable corresponding to each virtual display, the method further includes:

[0022] For each virtual display, delete the DISPLAY environment variable to release the environment variable lock.

[0023] According to a preferred embodiment of the present invention, after obtaining the test results, the method further includes:

[0024] Feedback the test result to the trigger of the test instruction.

[0025] A testing device, comprising:

[0026] a creation unit, configured to create at least one virtual display in the Docker container without a graphical interface in response to a test instruction based on the non-graphical interface and the headless browser, and record a display identifier of each virtual display;

[0027] A detection unit, configured to, after creating each virtual display, cyclically detect the occupancy of the environment variable lock and obtain a detection result corresponding to each virtual display;

[0028] a configuration unit, configured to configure an environment variable lock corresponding to each virtual display according to a detection result corresponding to each virtual display and a display identifier of each virtual display;

[0029] A binding unit, configured to bind each virtual display to a corresponding head browser according to an environment variable corresponding to each virtual display;

[0030] The execution unit is used to execute the test cases of the corresponding head browser in parallel based on each virtual display to obtain the test results.

[0031] A computer device, comprising:

[0032] a memory storing at least one instruction; and

[0033] A processor executes the instructions stored in the memory to implement the testing method.

[0034] A computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the testing method.

[0035] It can be seen from the above technical solutions that the present invention can create at least one virtual display in a Docker container without a graphical interface, so as to provide normal operating conditions for test cases that require a head browser; cyclically detect the occupancy of the environment variable lock, configure the environment variable lock corresponding to each virtual display according to the detection result corresponding to each virtual display and the display identifier of each virtual display, and bind each virtual display to the corresponding head browser according to the environment variable lock corresponding to each virtual display, thereby avoiding startup failure due to the preemption of environment variables between virtual display threads; based on each virtual display, the test case corresponding to the head browser is executed in parallel, which can effectively solve the problem of not being able to run a head browser on a non-graphical interface in a test scenario that needs to rely on real graphical interface interaction to efficiently perform automated testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 It is a flow chart of a preferred embodiment of the testing method of the present invention.

[0037] Figure 2 It is a functional module diagram of a preferred embodiment of the testing device of the present invention.

[0038] Figure 3 It is a structural diagram of a computer device of a preferred embodiment of the testing method of the present invention. DETAILED DESCRIPTION

[0039] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments.

[0040] like Figure 1 FIG. 1 is a flow chart of a preferred embodiment of the testing method of the present invention. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted.

[0041] The testing method is applied to one or more computer devices, which are devices that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. Their hardware includes but is not limited to microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0042] The computer device can be any electronic product that can interact with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.

[0043] The computer device may also include a network device and / or a user device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud based on cloud computing consisting of a large number of hosts or network servers.

[0044] The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0045] Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0046] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.

[0047] The network where the computer device is located includes but is not limited to the Internet, wide area network, metropolitan area network, local area network, virtual private network (VPN), etc.

[0048] S10 , in response to a test instruction based on a non-graphical interface and a headless browser, create at least one virtual display in the non-graphical interface Docker container, and record a display identifier of each virtual display.

[0049] In this embodiment, the test instruction can be triggered by relevant technical personnel according to actual test requirements.

[0050] In this embodiment, the non-graphical interface is also called "headless mode," which means that when running software or programs, the traditional graphical user interface (GUI) is not displayed, and operations are performed in the background using pure code or command lines. In this mode, the program runs entirely on the computer's computing resources and does not require visual interaction with the user.

[0051] In this embodiment, the headless browser refers to a traditional browser with a graphical user interface. When running, the headless browser displays a visual window interface, including elements such as an address bar, a menu bar, and a web page display area. Users can interact with the browser through mouse clicks and keyboard input to intuitively browse web page content, view images, watch videos, and operate various buttons and forms on the web page.

[0052] In this embodiment, creating at least one virtual display in the Docker container without a graphical interface includes:

[0053] Obtaining the number of the head browsers as a preset number;

[0054] In the Docker container without a graphical interface, a virtual frame buffer server is controlled based on a PyVirtualDisplay library to start the preset number of virtual display screens.

[0055] The virtual frame buffer server may include Xvfb (X Virtual Framebuffer), etc. Xvfb is a virtual X server used to run graphical interface applications in an environment without a physical display device (such as a monitor).

[0056] After creating the virtual display, you can then allow the headless browser to run normally and perform automated testing without a graphical interface.

[0057] In the above embodiment, a virtual display buffer layer may be created by a virtual frame buffer server so that an independent DISPLAY port may be allocated to each browser instance subsequently.

[0058] In this embodiment, the display identification of each virtual display may be an identifier such as a display ID of each virtual display that can be used to uniquely identify each virtual display.

[0059] S11, after creating each virtual display, cyclically detecting the occupancy of the environment variable lock to obtain a detection result corresponding to each virtual display.

[0060] In this embodiment, after each virtual display is created, the cyclic detection of the occupancy of the environment variable lock includes:

[0061] Loop to check whether the DISPLAY environment variable has a value.

[0062] The DISPLAY environment variable is used in Unix-like systems (e.g., Linux and macOS) to specify the output destination of a graphical interface. The DISPLAY environment variable indicates which terminal, screen, or remote server the application should display the graphics on.

[0063] Specifically, if the DISPLAY environment variable has a value, the loop detection continues; if the DISPLAY environment variable has no value, subsequent operations can be performed.

[0064] S12: configuring an environment variable lock corresponding to each virtual display according to the detection result corresponding to each virtual display and the display identifier of each virtual display.

[0065] In this embodiment, configuring the environment variable lock corresponding to each virtual display according to the detection result corresponding to each virtual display and the display identifier of each virtual display includes:

[0066] When the detection result is that the DISPLAY environment variable has no value, the value of the DISPLAY environment variable is configured as a display identifier corresponding to the virtual display.

[0067] This embodiment implements thread safety for creating a virtual display through an operating system-level environment variable lock, which can effectively prevent startup failures caused by threads seizing the DISPLAY environment variable.

[0068] S13, binding each virtual display to a corresponding head browser according to the environment variables corresponding to each virtual display.

[0069] In this embodiment, binding each virtual display to the corresponding head browser according to the environment variable corresponding to each virtual display includes:

[0070] Launching the head browser based on an automated testing framework;

[0071] Bind each virtual display with a corresponding headed browser via the DISPLAY environment variable.

[0072] The automated testing framework may include, but is not limited to, Selenium, DrissionPage, etc.

[0073] Through the above embodiment, an independent DISPLAY port can be allocated to each browser instance.

[0074] In this embodiment, after binding each virtual display to the corresponding headed browser according to the environment variable corresponding to each virtual display, the method further includes:

[0075] For each virtual display, delete the DISPLAY environment variable to release the environment variable lock.

[0076] Through the above embodiment, the environment variable lock can be released to facilitate subsequent processing.

[0077] This embodiment implements dynamic mounting and release of displays based on PyVirtualDisplay, forming a "1Docker container - N virtual displays - N headed browsers" architecture, which enables multiple browsers to run and control in parallel, effectively improving execution efficiency.

[0078] S14, executing the test cases corresponding to the head browser in parallel based on each virtual display to obtain a test result.

[0079] This embodiment solves the need to run a headless browser in a non-graphical user interface environment. It can also be integrated into automated testing frameworks such as Selenium or DrissionPage by using the PyVirtualDisplay library. Finally, the automated test is distributedly deployed based on a non-graphical interface container, and test cases that rely on real graphical interface interaction can be executed normally, effectively improving test efficiency.

[0080] In this embodiment, after obtaining the test results, the method further includes:

[0081] Feedback the test result to the trigger of the test instruction.

[0082] The test results may be encrypted or not according to security requirements.

[0083] Through the above embodiments, the test results can be fed back in a timely manner for reference by testers.

[0084] It can be seen from the above technical solutions that the present invention can create at least one virtual display in a Docker container without a graphical interface, so as to provide normal operating conditions for test cases that require a head browser; cyclically detect the occupancy of the environment variable lock, configure the environment variable lock corresponding to each virtual display according to the detection result corresponding to each virtual display and the display identifier of each virtual display, and bind each virtual display to the corresponding head browser according to the environment variable lock corresponding to each virtual display, thereby avoiding startup failure due to the preemption of environment variables between virtual display threads; based on each virtual display, the test case corresponding to the head browser is executed in parallel, which can effectively solve the problem of not being able to run a head browser on a non-graphical interface in a test scenario that needs to rely on real graphical interface interaction to efficiently perform automated testing.

[0085] like Figure 2 , which is a functional module diagram of a preferred embodiment of a testing device according to the present invention. The testing device 11 includes a creation unit 110, a detection unit 111, a configuration unit 112, a binding unit 113, and an execution unit 114. As used herein, a module / unit refers to a series of computer program segments that can be executed by a processor and perform a fixed function, stored in a memory. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.

[0086] The creation unit 110 is configured to create at least one virtual display in the Docker container without a graphical interface in response to a test instruction based on a non-graphical interface and a headless browser, and record a display identifier of each virtual display;

[0087] The detection unit 111 is used to cyclically detect the occupancy of the environment variable lock after creating each virtual display, and obtain a detection result corresponding to each virtual display;

[0088] The configuration unit 112 is configured to configure an environment variable lock corresponding to each virtual display according to the detection result corresponding to each virtual display and the display identifier of each virtual display;

[0089] The binding unit 113 is used to bind each virtual display to the corresponding head browser according to the environment variable corresponding to each virtual display;

[0090] The execution unit 114 is configured to execute the test cases corresponding to the head browser in parallel based on each virtual display to obtain a test result.

[0091] It can be seen from the above technical solutions that the present invention can create at least one virtual display in a Docker container without a graphical interface, so as to provide normal operating conditions for test cases that require a head browser; cyclically detect the occupancy of the environment variable lock, configure the environment variable lock corresponding to each virtual display according to the detection result corresponding to each virtual display and the display identifier of each virtual display, and bind each virtual display to the corresponding head browser according to the environment variable lock corresponding to each virtual display, thereby avoiding startup failure due to the preemption of environment variables between virtual display threads; based on each virtual display, the test case corresponding to the head browser is executed in parallel, which can effectively solve the problem of not being able to run a head browser on a non-graphical interface in a test scenario that needs to rely on real graphical interface interaction to efficiently perform automated testing.

[0092] like Figure 3 FIG. 1 is a schematic diagram of the structure of a computer device for implementing a preferred embodiment of the test method of the present invention.

[0093] The computer device 1 may include a memory 12 , a processor 13 and a bus (the arrow in the figure represents the bus), and may also include a computer program stored in the memory 12 and executable on the processor 13 , such as a test program.

[0094] Those skilled in the art will understand that the schematic diagram is merely an example of the computer device 1 and does not constitute a limitation on the computer device 1. The computer device 1 may have either a bus structure or a star structure. The computer device 1 may also include more or less other hardware or software than shown in the figure, or a different arrangement of components. For example, the computer device 1 may also include input and output devices, network access devices, etc.

[0095] It should be noted that the computer device 1 is only an example. Other existing or future electronic products that are suitable for the present invention should also be included in the scope of protection of the present invention and included here by reference.

[0096] The memory 12 includes at least one type of readable storage medium, including a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 12 may be an internal storage unit of the computer device 1, such as a mobile hard disk of the computer device 1. In other embodiments, the memory 12 may also be an external storage device of the computer device 1, such as a plug-in mobile hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, etc. equipped on the computer device 1. Furthermore, the memory 12 may include both an internal storage unit of the computer device 1 and an external storage device. The memory 12 can be used not only to store application software installed in the computer device 1 and various types of data, such as test program code, but also to temporarily store data that has been output or is about to be output.

[0097] In some embodiments, the processor 13 may be comprised of an integrated circuit, such as a single packaged integrated circuit or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 13 is the control core (Control Unit) of the computer device 1, connecting the various components of the entire computer device 1 using various interfaces and circuits. It executes or runs programs or modules stored in the memory 12 (e.g., executing test programs) and accesses data stored in the memory 12 to perform various functions and process data.

[0098] The processor 13 executes the operating system and various installed applications of the computer device 1. The processor 13 executes the applications to implement the steps in the above-mentioned various test method embodiments, for example Figure 1 Steps shown.

[0099] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to implement the present invention. The one or more modules / units may be a series of computer-readable instruction segments capable of performing specific functions, which describe the execution process of the computer program in the computer device 1. For example, the computer program may be divided into a creation unit 110, a detection unit 111, a configuration unit 112, a binding unit 113, and an execution unit 114.

[0100] The above-mentioned integrated unit implemented in the form of a software functional module can be stored in a computer-readable storage medium. The above-mentioned software functional module stored in a storage medium includes a number of instructions for causing a computer device (which can be a personal computer, computer device, or network device, etc.) or a processor to execute portions of the testing methods described in various embodiments of the present invention.

[0101] If the modules / units integrated in the computer device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the present invention can also implement all or part of the processes in the above-mentioned method embodiments by instructing relevant hardware devices through a computer program. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments.

[0102] The computer program includes computer program code, which may be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium may include any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory, etc.

[0103] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.

[0104] Blockchain, as used in this article, refers to a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each block contains information about a batch of online transactions, used to verify the validity of this information (to prevent counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.

[0105] The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 The figure shows that only one straight line is used, but it does not mean that there is only one bus or one type of bus. The bus is configured to realize the connection and communication between the memory 12 and at least one processor 13.

[0106] Although not shown, the computer device 1 may also include a power supply (such as a battery) to power various components. Preferably, the power supply can be logically connected to the at least one processor 13 via a power management device, thereby implementing functions such as charging management, discharging management, and power consumption management through the power management device. The power supply may also include one or more DC or AC power supplies, a recharging device, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components. The computer device 1 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be detailed here.

[0107] Furthermore, the computer device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used to establish a communication connection between the computer device 1 and other computer devices.

[0108] Optionally, the computer device 1 may further include a user interface, which may be a display or an input unit (such as a keyboard). Optionally, the user interface may also be a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display may also be appropriately referred to as a display screen or a display unit, and is used to display information processed in the computer device 1 and to display a visual user interface.

[0109] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0110] It will be understood by those skilled in the art that Figure 3 The structure shown does not constitute a limitation on the computer device 1 , and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.

[0111] Combine Figure 1 , the memory 12 in the computer device 1 stores a plurality of instructions to implement a testing method, and the processor 13 can execute the plurality of instructions to implement:

[0112] In response to a test instruction based on a non-graphical interface and a headless browser, create at least one virtual display in the non-graphical interface Docker container, and record a display identifier of each virtual display;

[0113] After creating each virtual display, cyclically detect the occupancy of the environment variable lock to obtain the detection result corresponding to each virtual display;

[0114] configuring an environment variable lock corresponding to each virtual display according to a detection result corresponding to each virtual display and a display identifier of each virtual display;

[0115] Bind each virtual display to the corresponding head browser according to the environment variables corresponding to each virtual display;

[0116] Based on each virtual display, the test cases of the corresponding head browser are executed in parallel to obtain the test results.

[0117] Specifically, the specific implementation method of the processor 13 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.

[0118] It should be noted that the data involved in this case were all obtained legally. The software tools or components not produced by our company that appear in the embodiments of this application are merely examples and do not represent actual use.

[0119] In the several embodiments provided herein, it should be understood that the disclosed systems, devices, and methods may be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the module division is merely a logical functional division, and actual implementation may employ other division methods.

[0120] The present invention can be used in a wide variety of general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.

[0121] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.

[0122] In addition, the functional modules in various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or hardware plus software functional modules.

[0123] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0124] Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the invention is defined by the appended claims rather than the foregoing description, and all changes that come within the meaning and range of equivalents of the claims are intended to be embraced therein. Any reference to a figure in a claim should not be construed as limiting the claim to which it relates.

[0125] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices described in the present invention may also be implemented by a single unit or device through software or hardware. Terms such as first and second are used to indicate names and do not imply any particular order.

[0126] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. A testing method, characterized in that: The test method includes: In response to a test instruction based on a non-graphical interface and a headless browser, create at least one virtual display in the non-graphical interface Docker container, and record a display identifier of each virtual display; After creating each virtual display, cyclically detect the occupancy of the environment variable lock to obtain the detection result corresponding to each virtual display; configuring an environment variable lock corresponding to each virtual display according to a detection result corresponding to each virtual display and a display identifier of each virtual display; Bind each virtual display to the corresponding head browser according to the environment variables corresponding to each virtual display; Based on each virtual display, the test cases of the corresponding head browser are executed in parallel to obtain the test results.

2. The testing method according to claim 1, wherein: The step of creating at least one virtual display in the Docker container without a graphical interface includes: Obtaining the number of the head browsers as a preset number; In the Docker container without a graphical interface, a virtual frame buffer server is controlled based on a PyVirtualDisplay library to start the preset number of virtual display screens.

3. The testing method according to claim 1, wherein: The cyclic detection of the occupancy of the environment variable lock includes: Loop to check whether the DISPLAY environment variable has a value.

4. The testing method according to claim 3, wherein: The configuring of an environment variable lock corresponding to each virtual display according to the detection result corresponding to each virtual display and the display identifier of each virtual display includes: When the detection result is that the DISPLAY environment variable has no value, the value of the DISPLAY environment variable is configured as a display identifier corresponding to the virtual display.

5. The testing method according to claim 3, wherein: Binding each virtual display to a corresponding head browser according to the environment variables corresponding to each virtual display includes: Launching the head browser based on an automated testing framework; Bind each virtual display with a corresponding headed browser via the DISPLAY environment variable.

6. The testing method according to claim 3, wherein: After binding each virtual display to a corresponding headed browser according to the environment variables corresponding to each virtual display, the method further includes: For each virtual display, delete the DISPLAY environment variable to release the environment variable lock.

7. The testing method according to claim 1, wherein: After obtaining the test results, the method further includes: Feedback the test result to the trigger of the test instruction.

8. A testing device, characterized in that: The testing device comprises: a creation unit, configured to create at least one virtual display in the Docker container without a graphical interface in response to a test instruction based on the non-graphical interface and the headless browser, and record a display identifier of each virtual display; A detection unit, configured to, after creating each virtual display, cyclically detect the occupancy of the environment variable lock and obtain a detection result corresponding to each virtual display; a configuration unit, configured to configure an environment variable lock corresponding to each virtual display according to a detection result corresponding to each virtual display and a display identifier of each virtual display; A binding unit, configured to bind each virtual display to a corresponding head browser according to an environment variable corresponding to each virtual display; The execution unit is used to execute the test cases of the corresponding head browser in parallel based on each virtual display to obtain the test results.

9. A computer device, characterized in that: The computer device comprises: a memory storing at least one instruction; and A processor is configured to execute instructions stored in the memory to implement the testing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the testing method according to any one of claims 1 to 7.