CN116756016A - Multi-browser testing method, device, equipment, medium and program product - Google Patents

Multi-browser testing method, device, equipment, medium and program product Download PDF

Info

Publication number
CN116756016A
CN116756016A CN202310714359.4A CN202310714359A CN116756016A CN 116756016 A CN116756016 A CN 116756016A CN 202310714359 A CN202310714359 A CN 202310714359A CN 116756016 A CN116756016 A CN 116756016A
Authority
CN
China
Prior art keywords
browser
test
script
tested
environment
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310714359.4A
Other languages
Chinese (zh)
Inventor
王勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
ICBC Technology Co Ltd
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
ICBC Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC, ICBC Technology Co Ltd filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202310714359.4A priority Critical patent/CN116756016A/en
Publication of CN116756016A publication Critical patent/CN116756016A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present disclosure provides a multi-browser testing method, apparatus, device, storage medium, and program product, which can be applied to the technical field of finance. The multi-browser testing method comprises the following steps: determining a master control browser and a browser to be tested from a plurality of browsers; responding to the operation behavior instruction input by the master control browser, and executing the recording of the script; determining a key code segment based on the script; starting a testing environment based on a configuration file of a browser to be tested; generating a test script according to the configuration file and the key code segment; and executing the test of the browser to be tested based on running the test script in the test environment.

Description

Multi-browser testing method, device, equipment, medium and program product
Technical Field
The present disclosure relates to the field of financial technology, and more particularly, to a multi-browser testing method, apparatus, device, medium, and program product.
Background
Existing browsers often exist in multiple types and versions, and different test environments and different test scripts are prepared for different browsers. The cost of testing multiple browsers is high, the testing environment is complex and is not beneficial to monitoring, the requirements of the test scripts written in different browsers on the professional ability of testers are high, and the labor cost is high. In addition, the current browser testing process is usually played back through machine language, so that a tester cannot observe the browser testing condition in real time, and the accuracy of the test is not guaranteed in time.
Disclosure of Invention
In view of the foregoing, the present disclosure provides a multi-browser testing method, apparatus, device, medium, and program product.
According to a first aspect of the present disclosure, there is provided a multi-browser testing method, including: determining a master control browser and a browser to be tested from a plurality of browsers; responding to the operation behavior instruction input by the master control browser, and executing the recording of the script; determining a key code segment based on the script; starting a testing environment based on a configuration file of a browser to be tested; generating a test script according to the configuration file and the key code segment; and executing the test of the browser to be tested based on running the test script in the test environment.
According to an embodiment of the present disclosure, determining a master browser from a plurality of browsers includes: acquiring historical data of each browser; determining a test frequency of each browser based on the historical data; and determining the browser corresponding to the highest test frequency as the master browser.
According to an embodiment of the present disclosure, in response to an operation behavior instruction input by a main control browser, recording of a script is performed, including: performing page monitoring on the master control browser; responding to the input operation behavior instruction, and executing the recording of the script; the script comprises all operation behavior instructions on the main control browser page; and storing the script to a specified directory based on a preset file storage path.
According to an embodiment of the present disclosure, the multi-browser testing method further includes: performing timing scanning on the appointed catalogue; based on the timing scan, the latest uploaded script is obtained.
According to an embodiment of the present disclosure, determining a key code segment based on a script includes: extracting test instructions in the script, and determining key code segments; wherein the key code segment is a set of test instructions.
According to an embodiment of the present disclosure, the test environment is a mirror container, and starting the test environment based on a configuration file of a browser to be tested includes: reading a configuration file of the browser to be tested to obtain the model and version of the browser to be tested; searching a testing environment based on the model and version of the browser to be tested; responding to successful searching of the test environment, and starting the test environment; in response to a test environment lookup failure, a test environment is created.
According to an embodiment of the present disclosure, creating a test environment includes: reading a configuration file of the browser to be tested to obtain the model and version of the browser to be tested; determining a driver of the browser to be tested based on the model and version of the browser to be tested; and manufacturing a mirror image container according to the model, version and driver of the browser to be tested.
According to an embodiment of the present disclosure, generating a test script from a configuration file and a key code segment includes: determining a test environment parameter based on a configuration file of a browser to be tested; the configuration file comprises a version and a model of each browser; reading the byte codes of the script, modifying the byte codes based on the test environment parameters to obtain test codes of the browser to be tested, and creating a plurality of classes in the test codes; and inserting the key code segment into a specified class in the test code to obtain the test script.
According to an embodiment of the present disclosure, running a test script in a test environment to perform a test of a browser to be tested includes: issuing the test script to a test environment; executing the test script in the test environment; and responding to the test script to start running, and visually displaying a test environment interface.
A second aspect of the present disclosure provides a multi-browser testing apparatus, comprising: the determining module is used for determining a master control browser and a browser to be tested from a plurality of browsers; the recording module is used for responding to the operation behavior instruction input by the main control browser and executing the recording of the script; an analysis module for determining key code segments based on the script; the environment starting module is used for starting the testing environment based on the configuration file of the browser to be tested; the generating module is used for generating a test script according to the configuration file and the key code segment; and the test module is used for running a test script in the test environment to execute the test of the browser to be tested.
A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the multi-browser testing method described above.
A fourth aspect of the present disclosure also provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the above-described multi-browser testing method.
A fifth aspect of the present disclosure also provides a computer program product comprising a computer program which, when executed by a processor, implements the multi-browser testing method described above.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be more apparent from the following description of embodiments of the disclosure with reference to the accompanying drawings, in which:
FIG. 1 schematically illustrates an application scenario diagram of a multi-browser testing method, apparatus, device, medium, and program product according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a flow chart of a multi-browser testing method according to an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow diagram for determining a master browser from a plurality of browsers according to an embodiment of the disclosure;
FIG. 4 schematically illustrates a flowchart of performing recording of a script in response to operational behavior instructions entered by a host browser, in accordance with an embodiment of the present disclosure;
FIG. 5 schematically illustrates a flow diagram of a launch test environment based on a configuration file of a browser to be tested, in accordance with an embodiment of the present disclosure;
FIG. 6 schematically illustrates a flow diagram for creating a test environment according to an embodiment of the disclosure;
FIG. 7 schematically illustrates a flow diagram for generating test scripts from configuration files and key code segments in accordance with an embodiment of the present disclosure;
FIG. 8 schematically illustrates a flow chart of running a test script in a test environment to perform a test of a browser to be tested, in accordance with an embodiment of the present disclosure;
FIG. 9 schematically illustrates a block diagram of a multi-browser testing apparatus, according to an embodiment of the present disclosure; and
fig. 10 schematically illustrates a block diagram of an electronic device suitable for implementing a multi-browser testing method, in accordance with an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is only exemplary and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the present disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. In addition, in the following description, descriptions of well-known structures and techniques are omitted so as not to unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and/or the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It should be noted that the terms used herein should be construed to have meanings consistent with the context of the present specification and should not be construed in an idealized or overly formal manner.
Where expressions like at least one of "A, B and C, etc. are used, the expressions should generally be interpreted in accordance with the meaning as commonly understood by those skilled in the art (e.g.," a system having at least one of A, B and C "shall include, but not be limited to, a system having a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
It should be noted that the method and apparatus for testing multiple browsers provided by the present disclosure may be used in the field of financial technology, and may also be used in any field other than the financial field, and the application field of the method and apparatus for testing multiple browsers provided by the present disclosure is not limited.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the related personal information of the user all conform to the regulations of related laws and regulations, necessary security measures are taken, and the public order harmony is not violated.
In the technical scheme of the disclosure, the authorization or consent of the user is obtained before the personal information of the user is obtained or acquired.
The embodiment of the disclosure provides a multi-browser testing method, which comprises the following steps: the method comprises the steps of determining a master browser and a browser to be tested from a plurality of browsers. And responding to the operation behavior instruction input by the master control browser, and executing the recording of the script. Based on the script, a key code segment is determined. And starting a testing environment based on the configuration file of the browser to be tested. And generating a test script according to the configuration file and the key code segment. Running a test script in a test environment to perform testing of the browser to be tested.
Fig. 1 schematically illustrates an application scenario diagram of a multi-browser testing method, apparatus, device, medium and program product according to an embodiment of the present disclosure.
As shown in fig. 1, an application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may interact with the server 105 via the network 104 using the terminal devices 101, 102, 103 to receive or send messages or the like. Various communication client applications, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only) may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 105 may be a server providing various services, such as a background management server (by way of example only) providing support for websites browsed by users using the terminal devices 101, 102, 103. The background management server may analyze and process the received data such as the user request, and feed back the processing result (e.g., the web page, information, or data obtained or generated according to the user request) to the terminal device.
It should be noted that the multi-browser testing method provided in the embodiments of the present disclosure may be generally executed by the server 105. Accordingly, the multi-browser testing apparatus provided by the embodiments of the present disclosure may be generally disposed in the server 105. The multi-browser testing method provided by the embodiments of the present disclosure may also be performed by a server or cluster of servers other than server 105 and capable of communicating with terminal devices 101, 102, 103 and/or server 105. Accordingly, the multi-browser testing apparatus provided by the embodiments of the present disclosure may also be provided in a server or server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The multi-browser testing method of the disclosed embodiment will be described in detail below with reference to fig. 2 to 8 based on the scenario described in fig. 1.
Fig. 2 schematically illustrates a flow chart of a multi-browser testing method according to an embodiment of the present disclosure.
As shown in fig. 2, the multi-browser test of this embodiment includes operations S210 to S260.
In operation S210, a master browser and a browser to be tested are determined from among a plurality of browsers.
In some embodiments, there are typically multiple browsers, and a lot of resources are consumed to monitor pages for each browser.
Therefore, the disclosure proposes to divide a plurality of browsers into a master browser and a browser to be tested, wherein the master browser is a browser with higher test frequency, and the other browsers are the browsers to be tested. And performing page behavior monitoring on the master control browser, determining a test behavior executed on the master control browser, and executing synchronous test on the browser to be tested in response to the existence of the test behavior of the master control browser.
By dividing the browser into a main control browser and a browser to be tested and performing page monitoring on the main control browser, system resources can be effectively saved.
In operation S220, recording of a script is performed in response to an operation behavior instruction input by the main control browser.
In some embodiments, the master browser is scripted by a script monitoring service. When the master control browser is started, the script monitoring service is correspondingly started, and the script monitoring service records the script of the master control browser under the condition that the script monitoring service detects that an operation behavior instruction is input to the master control browser.
In operation S230, a key code segment is determined based on the script.
In some embodiments, the recorded script is parsed and a set of test instructions in the test script are determined to be key code segments.
In a specific implementation, a recorded script is parsed into a plurality of operational steps. And extracting the testScript method in the operation step to obtain a key code segment, wherein the testScript method comprises a series of instructions for executing specific tests so as to realize the browser test.
In the complete browser testing process, the method at least comprises the steps of building a testing environment, building a testing case, writing a testing instruction and the like. The present disclosure parses a recorded script, reduces the script to a plurality of browser test steps, and further parses the operation of writing test instructions, determines key code segments from a testScript method, where the key code segments are a collection of a series of instructions for performing a particular test.
In operation S240, a test environment is started based on the configuration file of the browser to be tested.
In some embodiments, a configuration file of a browser to be tested is read by using a monitoring scheduling service, a test environment corresponding to the browser to be tested is determined based on the configuration file, and the test environment is started for subsequent testing. The test environment is based on a mirror image container built by a to-be-tested browser configuration file, the to-be-tested browser configuration file is in a JSON format, the configuration information of the browser and server address information of a Selenoid hub are contained, and the Selenoid hub is used for starting the browser in the mirror image container.
In operation S250, a test script is generated from the configuration file and the key code segments.
In some embodiments, the open source component library javaist dynamically generates a test script for executing a test on the browser to be tested based on the configuration file of the browser to be tested, where the test instruction in the test script is the key code segment.
In operation S260, a test of the browser to be tested is performed based on running a test script in the test environment.
In some embodiments, the test script is issued to the corresponding test environment, and the test of the browser to be tested is performed in the initiated test environment. The application utilizes the mirror image container to construct the testing environment, and because the mirror image container has the characteristic of resource isolation, a plurality of mirror image containers can be built in one hardware server, each mirror image container is equivalent to one hardware server which can be independently tested, and when the multi-browser test is carried out, the parallel test of a plurality of browsers to be tested is realized, the testing efficiency is improved, and the testing time is reduced.
According to the embodiment of the disclosure, through script recording of operation behaviors on the master control browser, key code segments in the recorded scripts are extracted, a test script for testing the browser to be tested is dynamically generated based on the configuration file and the key code segments of the browser to be tested, the test script is operated in the mirror image container, and testing of the browser to be tested is executed. According to the multi-browser testing method, whether the script recording of the master control browser or the generation of the testing script is automatically realized, the capability requirement on technicians is reduced, and the efficient testing of a plurality of browsers is realized.
On the basis of the above-described embodiments, fig. 3 schematically shows a flowchart for determining a master browser from a plurality of browsers according to an embodiment of the present disclosure.
As shown in fig. 3, determining a master browser from among a plurality of browsers of this embodiment includes operations S310 to S330.
In operation S310, history data of each browser is acquired.
In operation S320, a test frequency of each browser is determined based on the history data.
In operation S330, the browser corresponding to the highest test frequency is determined as the master browser.
In some embodiments, based on the test frequency in each browser history data, the browser with the highest test frequency is determined as the master control browser, and based on the operation behavior of the user on the master control browser, other browsers are tested, so that timeliness of browser testing is ensured, and the situation that some browsers are not tested for a long time is avoided.
On the basis of the above-described embodiments, fig. 4 schematically shows a flowchart of recording an execution script in response to an operation behavior instruction input by a main control browser according to an embodiment of the present disclosure.
As shown in fig. 4, the recording of the execution script in response to the operation behavior instruction input by the main control browser of this embodiment includes operations S410 to S430.
In operation S410, page monitoring is performed on the main control browser.
In some embodiments, a script monitoring service is set for the master browser, where the script monitoring service has at least a browser page monitoring function and a script recording function. The script monitoring service is started upon startup of the host browser. For example, when the master browser is a Chrome browser of 107.0.5304.121 version, a corresponding script monitoring service is selected based on the configuration (such as version, model, etc.) of the master browser, the service can be installed on the master browser, and when the master browser is started, the script monitoring service is also started, so that page monitoring is performed on the master browser.
In operation S420, recording of a script is performed in response to the input operation behavior instruction.
In some embodiments, when the script monitoring service detects that an operation behavior instruction is input on a main control browser page, a script recording function is started, script recording is performed on the main control browser page, and all operation behavior instructions on the page are contained in the recorded script.
In operation S430, the script is saved to the designated directory based on the preset file save path.
In some embodiments, the file save path of the script monitoring service is preset, and when the script recording of the main control browser page is completed, the file save path is automatically saved into the specified directory based on the preset file save path. And unifying the storage format of the script, wherein the storage format of the script can be AutoTestFile_XXXX-XX-XX HH: mm: ss, stored at the time of script recording completion, e.g., autoTestFile_2023-01-0117:35: script, representing that the script is 17 at 2023-01-01: 35: the 24-branch recording is completed, so that the script ordering is conveniently carried out according to the time sequence, and the recorded script finally forms a complete code string capable of realizing the browser test.
In some embodiments, the multi-browser testing method may further include: performing a timing scan on the specified directory; based on the timing scan, the latest uploaded script is obtained. The frequency of the timing scanning is 1s once, and the timing scanning process is continuously carried out in the testing process of the master control browser so as to ensure the integrity of the script.
On the basis of the above embodiment, fig. 5 schematically shows a flowchart of a test environment started based on a configuration file of a browser to be tested according to an embodiment of the present disclosure.
As shown in fig. 5, the configuration file initiation test environment based on the browser to be tested of this embodiment includes operations S510 to S540.
In operation S510, a configuration file of the browser to be tested is read, and a model and a version of the browser to be tested are obtained.
In operation S520, a test environment is found based on the model and version of the browser to be tested.
In operation S530, the test environment is started in response to the test environment search being successful.
In operation S540, a test environment is created in response to the test environment search failure.
In some embodiments, according to a configuration file of a browser to be tested, determining a test environment corresponding to the browser to be tested, and starting the test environment for testing the browser to be tested, wherein the test environment is a mirror container (dock). Each Docker is equivalent to a hardware server capable of independently testing, so that browser testing is performed by using Docker containers, hardware resources can be effectively saved, even different browsers can be realized by arranging a plurality of Docker containers on one hardware server, a large number of hardware servers are not required, and waste of hardware resources is avoided. Because the operation mechanism of the Docker container is a sandbox mechanism, no interface exists, and the test script can be limited in a specific operation range by being completely isolated from the outside, so that the mutual influence of different browsers is avoided, and the simultaneous test of multiple browsers is smoothly realized.
In the implementation, the model information and version information of the browser to be tested are obtained by reading the configuration file of the browser to be tested. The model information mainly refers to companies to which the browser belongs, such as a Chrome browser, a Firefox browser, an IE browser, a Microsoft Edg browser and the like. Version information refers to a specific version of each model browser, for example, the Chrome browser may be further divided into 107.0 version, 78.0 version, and the like. Based on the model information and version information of the browser to be tested, searching whether a Docker container corresponding to the browser to be tested exists in the built test environment. If the search is successful, namely the Docker container corresponding to the browser to be tested is searched, the Docker container is started for browser testing. If the search fails, namely the Docker container corresponding to the browser to be tested is not found, the test environment is created, namely the corresponding Docker container is created.
On the basis of the above-described embodiments, fig. 6 schematically shows a flowchart of creating a test environment according to an embodiment of the present disclosure.
As shown in fig. 6, the creation test environment of this embodiment includes operations S610 to S630.
In operation S610, a configuration file of the browser to be tested is read to obtain a model and a version of the browser to be tested.
In operation S620, a driver of the browser to be tested is determined based on the model and version of the browser to be tested.
In operation S630, a mirror container is fabricated according to the model number, version, and driver of the browser to be tested.
In some embodiments, it is common to collect as many different models and versions of browsers as possible, and make a plurality of Docker containers corresponding to each browser one-to-one based on the versions and models of the browsers. When the Docker container is created, an identifier of the Docker container corresponding to each browser can be set based on the display name of the browser, so that the Docker container can be conveniently searched and identified, and the starting efficiency of the Docker container is improved.
Where Docker is an open-source application container engine that allows developers to package their applications and rely on packages into a portable container and then release onto any popular Linux. The Docker image, similar to the image in a virtual machine, is a read-only template and a separate file system, including the data needed to run the container, can be used to create a new container. The Docker container is a running instance created by a Docker mirror. The Docker container is similar to a virtual machine.
In a particular embodiment, each browser to be tested matches one of the Docker containers for testing. The configuration file of the browser to be tested can also comprise server address information of the Selenoid hub besides the model information and version information of the browser. Selenoid hub is an open source tool for performing automated testing on a Web browser, has extremely high compatibility, and can be suitable for various types of browsers.
In some embodiments, the browser is run in the Docker container by invoking a Selenoid service in a Selenoid hub to implement browser testing in the Docker container. The Selenoid has the advantages of visual operation process, support of simultaneous operation of multiple versions of browsers, remote operation, video recording and the like, and is convenient for realizing simultaneous test of multiple browsers.
According to the method and the device, the Docker container is deployed on the hardware server in a cluster mode, and the browser is tested by running the browser in the Docker container, so that synchronous testing of multiple browsers is effectively achieved.
Based on the above embodiments, FIG. 7 schematically illustrates a flow chart for generating test scripts from configuration files and key code segments according to an embodiment of the present disclosure.
As shown in FIG. 7, generating test scripts from configuration files and key code segments of this embodiment includes operations S710-S730.
In operation S710, a test environment parameter is determined based on a configuration file of a browser to be tested.
In operation S720, the bytecode of the script is read, and the bytecode is modified based on the test environment parameter to obtain the test code of the browser to be tested, and multiple classes are created in the test code.
In operation S730, the key code segment is inserted into a specified class in the test code, resulting in a test script.
In some embodiments, the test environments of different browsers are different, so that it is necessary to determine the test environment parameters of the current browser to be tested based on the configuration file of the browser to be tested. And dynamically generating a test script of the browser to be tested based on the test environment parameters.
Moreover, in the present disclosure, since the test script is executed in the Docker container of the virtual environment, the specific expression form of the test script may be a bytecode directly applied to the virtual environment.
The dynamic generation of the test script can realize the code expansion without invasion, namely, the existing byte codes in the test environment are changed without modifying the source codes, and the test of the browser is realized quickly and simply.
In specific implementation, the test script should include a basic class method for implementing script operation and a class method for testing the browser. The test script is made up of dynamically generated code and key code segments. The dynamically generated code is used for maintaining smooth running of the script, comprises a plurality of classes, is dynamically generated by a java agent method in an open source component library java, and can be directly added in a designated test process for realizing smooth running of the test script in a Docker container. The key code segment is inserted into a designated class in the dynamically generated code, and the browser to be tested is tested by calling an execcript method of the designated class. The test script may also include a dynamically compiled executable jar file for inserting the test script into a specified virtual test environment (Docker container).
According to the test script generation method provided by the embodiment of the disclosure, script recording of the master control browser is automatically performed, and a script for the browser to be tested is automatically generated based on the recorded script. The method for automatically generating the test script in real time according to the test operation of the master control browser reduces the technical capability requirement on testers, and the testers can correspondingly realize synchronous test of a plurality of other browsers to be tested only through the test operation of the master control browser. The workload of writing a plurality of test scripts for different browsers by a tester is effectively reduced, the labor cost is reduced, and the test efficiency is improved. And the synchronous test of a plurality of browsers to be tested is realized by establishing a plurality of Docker containers which are not mutually interfered, and the management of a plurality of types of browsers and a plurality of versions of browsers is realized in an extremely small test environment.
On the basis of the above-described embodiments, fig. 8 schematically shows a flowchart of executing a test script in a test environment to perform a test of a browser to be tested according to an embodiment of the present disclosure.
As shown in fig. 8, the running of a test script in a test environment to perform a test of a browser to be tested of this embodiment includes operations S810 to S830.
In operation S810, a test script is issued into a test environment.
In operation S820, a test script is executed in a test environment.
In operation S830, a test environment interface is visually exposed in response to the test script beginning to run.
In some embodiments, a virtual network console (Virtual Network Console, VNC) accesses a Selenoid Master service to perform video display on browser test pages of all running Docker containers, so that a tester can view test pictures of multiple browsers at the same time, and is convenient for the tester to synchronously observe feedback information of the multiple browsers in a test process in real time, ensure the test accuracy of each browser, and facilitate timely adjustment of the tester in the test process.
Based on the multi-browser testing method, the disclosure also provides a multi-browser testing device. The device will be described in detail below in connection with fig. 9.
Fig. 9 schematically illustrates a block diagram of a multi-browser testing apparatus according to an embodiment of the present disclosure.
As shown in fig. 9, the multi-browser testing apparatus 900 of this embodiment includes a determining module 910, a recording module 920, an analyzing module 930, an environment starting module 940, a generating module 950, and a testing module 960.
The determining module 910 is configured to determine a master browser and a browser to be tested from a plurality of browsers. In an embodiment, the determining module 910 may be configured to perform the operation S210 described above, which is not described herein.
The recording module 920 is configured to perform recording of the script in response to an operation behavior instruction input by the main control browser. In an embodiment, the recording module 920 may be used to perform the operation S220 described above, which is not described herein.
The analysis module 930 is used to determine key code segments based on the script. In an embodiment, the analysis module 930 may be configured to perform the operation S230 described above, which is not described herein.
The environment starting module 940 is configured to start a test environment based on a configuration file of the browser to be tested. In an embodiment, the environment starting module 940 may be used to perform the operation S240 described above, which is not described herein.
The generating module 950 is configured to generate a test script according to the configuration file and the key code segment. In an embodiment, the generating module 950 may be configured to perform the operation S250 described above, which is not described herein.
The test module 960 is used to run test scripts in a test environment to perform testing of the browser under test. In an embodiment, the test module 960 may be used to perform the operation S260 described above, which is not described herein.
Any of the determining module 910, recording module 920, analyzing module 930, environment starting module 940, generating module 950, and testing module 960 may be combined in one module or any of the modules may be split into multiple modules according to embodiments of the present disclosure. Alternatively, at least some of the functionality of one or more of the modules may be combined with at least some of the functionality of other modules and implemented in one module. According to embodiments of the present disclosure, at least one of the determination module 910, the recording module 920, the analysis module 930, the environment starting module 940, the generation module 950, and the test module 960 may be implemented at least in part as hardware circuitry, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system-on-chip, a system-on-substrate, a system-on-package, an Application Specific Integrated Circuit (ASIC), or may be implemented in hardware or firmware in any other reasonable manner of integrating or packaging the circuitry, or in any one of or a suitable combination of any of the three. Alternatively, at least one of the determination module 910, the recording module 920, the analysis module 930, the environment starting module 940, the generation module 950, and the test module 960 may be at least partially implemented as a computer program module, which, when executed, may perform the corresponding functions.
Fig. 10 schematically illustrates a block diagram of an electronic device suitable for implementing a multi-browser testing method, in accordance with an embodiment of the present disclosure.
As shown in fig. 10, an electronic device 1000 according to an embodiment of the present disclosure includes a processor 1001 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. The processor 1001 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or an associated chipset and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), or the like. The processor 1001 may also include on-board memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of the method flows according to embodiments of the present disclosure.
In the RAM 1003, various programs and data necessary for the operation of the electronic apparatus 1000 are stored. The processor 1001, the ROM 1002, and the RAM 1003 are connected to each other by a bus 1004. The processor 1001 performs various operations of the method flow according to the embodiment of the present disclosure by executing programs in the ROM 1002 and/or the RAM 1003. Note that the program may be stored in one or more memories other than the ROM 1002 and the RAM 1003. The processor 1001 may also perform various operations of the method flow according to the embodiments of the present disclosure by executing programs stored in the one or more memories.
According to an embodiment of the disclosure, the electronic device 1000 may also include an input/output (I/O) interface 1005, the input/output (I/O) interface 1005 also being connected to the bus 1004. The electronic device 1000 may also include one or more of the following components connected to the I/O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output portion 1007 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), etc., and a speaker, etc.; a storage portion 1008 including a hard disk or the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The driver 1010 is also connected to the I/O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like, is installed as needed in the drive 1010, so that a computer program read out therefrom is installed as needed in the storage section 1008.
The present disclosure also provides a computer-readable storage medium that may be embodied in the apparatus/device/system described in the above embodiments; or may exist alone without being assembled into the apparatus/device/system. The computer-readable storage medium carries one or more programs which, when executed, implement methods in accordance with embodiments of the present disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example, but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, the computer-readable storage medium may include ROM 1002 and/or RAM 1003 and/or one or more memories other than ROM 1002 and RAM 1003 described above.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowcharts. The program code, when executed in a computer system, causes the computer system to implement the item recommendation method provided by embodiments of the present disclosure.
The above-described functions defined in the system/apparatus of the embodiments of the present disclosure are performed when the computer program is executed by the processor 1001. The systems, apparatus, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the disclosure.
In one embodiment, the computer program may be based on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted in the form of signals on a network medium, distributed, and downloaded and installed via the communication section 1009, and/or installed from the removable medium 1011. The computer program may include program code that may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 1009, and/or installed from the removable medium 1011. The above-described functions defined in the system of the embodiments of the present disclosure are performed when the computer program is executed by the processor 1001. The systems, devices, apparatus, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the disclosure.
According to embodiments of the present disclosure, program code for performing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, such computer programs may be implemented in high-level procedural and/or object-oriented programming languages, and/or assembly/machine languages. Programming languages include, but are not limited to, such as Java, c++, python, "C" or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that the features recited in the various embodiments of the disclosure and/or in the claims may be provided in a variety of combinations and/or combinations, even if such combinations or combinations are not explicitly recited in the disclosure. In particular, the features recited in the various embodiments of the present disclosure and/or the claims may be variously combined and/or combined without departing from the spirit and teachings of the present disclosure. All such combinations and/or combinations fall within the scope of the present disclosure.
The embodiments of the present disclosure are described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the embodiments cannot be used advantageously in combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be made by those skilled in the art without departing from the scope of the disclosure, and such alternatives and modifications are intended to fall within the scope of the disclosure.

Claims (13)

1. A multi-browser testing method, comprising:
determining a master control browser and a browser to be tested from a plurality of browsers;
Responding to the operation behavior instruction input by the master control browser, and executing the recording of the script;
determining a key code segment based on the script;
starting a testing environment based on the configuration file of the browser to be tested;
generating a test script according to the configuration file and the key code segment;
and executing the test of the browser to be tested based on running the test script in the test environment.
2. The multi-browser testing method of claim 1, wherein determining a master browser from a plurality of browsers comprises:
acquiring historical data of each browser;
determining the test frequency of each browser based on the historical data;
and determining the browser corresponding to the highest test frequency as the master browser.
3. The multi-browser testing method of claim 1, wherein the performing the recording of the script in response to the operation behavior instruction input by the main browser comprises:
performing page monitoring on the master control browser;
responding to the input operation behavior instruction, and executing the recording of the script; wherein, the script comprises all operation behavior instructions on a main control browser page;
and storing the script to a specified directory based on a preset file storage path.
4. The multi-browser testing method of claim 3, further comprising:
carrying out timing scanning on the appointed catalogue;
and obtaining the latest uploaded script based on the timing scanning.
5. The multi-browser testing method of claim 1, the determining key code segments based on the script, comprising:
extracting a test instruction in the script, and determining a key code segment; wherein a critical code segment is a set of the test instructions.
6. The multi-browser testing method according to claim 1, wherein the testing environment is a mirror container, and the starting the testing environment based on the configuration file of the browser to be tested includes:
reading the configuration file of the browser to be tested to obtain the model and version of the browser to be tested;
searching a test environment based on the model and version of the browser to be tested;
responding to successful searching of the test environment, and starting the test environment;
in response to a test environment lookup failure, a test environment is created.
7. The multi-browser testing method of claim 6, the creating a testing environment comprising:
reading the configuration file of the browser to be tested to obtain the model and version of the browser to be tested;
Determining a driver of the browser to be tested based on the model and version of the browser to be tested;
and manufacturing a mirror image container according to the model, version and driver of the browser to be tested.
8. The multi-browser testing method of claim 1, the generating a test script from the configuration file and the key code segment, comprising:
determining a test environment parameter based on a configuration file of a browser to be tested; the configuration file comprises a version and a model of each browser;
reading the byte codes of the script, and modifying the byte codes based on the test environment parameters to obtain test codes of the browser to be tested, wherein a plurality of classes are created in the test codes;
and inserting the key code segment into a specified class in the test code to obtain the test script.
9. The multi-browser testing method of claim 1, the running a test script in the testing environment to perform testing of the browser under test, comprising:
issuing the test script to a test environment;
executing the test script in the test environment;
and responding to the test script to start running, and visually displaying a test environment interface.
10. A multi-browser testing apparatus, comprising:
the determining module is used for determining a master control browser and a browser to be tested from a plurality of browsers;
the recording module is used for responding to the operation behavior instruction input by the main control browser and executing the recording of the script;
an analysis module for determining key code segments based on the script;
the environment starting module is used for starting a testing environment based on the configuration file of the browser to be tested;
the generating module is used for generating a test script according to the configuration file and the key code segment;
and the test module is used for running a test script in the test environment to execute the test of the browser to be tested.
11. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-9.
12. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method according to any of claims 1 to 9.
13. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 9.
CN202310714359.4A 2023-06-15 2023-06-15 Multi-browser testing method, device, equipment, medium and program product Pending CN116756016A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310714359.4A CN116756016A (en) 2023-06-15 2023-06-15 Multi-browser testing method, device, equipment, medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310714359.4A CN116756016A (en) 2023-06-15 2023-06-15 Multi-browser testing method, device, equipment, medium and program product

Publications (1)

Publication Number Publication Date
CN116756016A true CN116756016A (en) 2023-09-15

Family

ID=87958398

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310714359.4A Pending CN116756016A (en) 2023-06-15 2023-06-15 Multi-browser testing method, device, equipment, medium and program product

Country Status (1)

Country Link
CN (1) CN116756016A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117312713A (en) * 2023-10-10 2023-12-29 中国电力科学研究院有限公司 Method and system for processing information creation environment based on browser automatic flow

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117312713A (en) * 2023-10-10 2023-12-29 中国电力科学研究院有限公司 Method and system for processing information creation environment based on browser automatic flow

Similar Documents

Publication Publication Date Title
US10642721B2 (en) Generation of automated testing scripts by converting manual test cases
CN108964968B (en) Service access management method and system in container cloud environment
CN110858172A (en) Automatic test code generation method and device
CN111045653B (en) System generation method and device, computer readable medium and electronic equipment
CN110321178A (en) Starting processing method, device, equipment and the storage medium of attached application end
CN113535567B (en) Software testing method, device, equipment and medium
CN111666201A (en) Regression testing method, device, medium and electronic equipment
CN112395027A (en) Widget interface generation method and device, storage medium and electronic equipment
CN113836014A (en) Interface testing method and device, electronic equipment and storage medium
CN116756016A (en) Multi-browser testing method, device, equipment, medium and program product
CN113032256B (en) Automated testing method, apparatus, computer system, and readable storage medium
CN113362173A (en) Anti-duplication mechanism verification method, anti-duplication mechanism verification system, electronic equipment and storage medium
CN115827457A (en) Browser compatibility testing method and related equipment
CN113535568B (en) Verification method, device, equipment and medium for application deployment version
CN112765040B (en) Page test method, system, computer equipment and storage medium
CN108093004B (en) Method and device for pushing graphs in report
CN117950991A (en) Program testing method, device, electronic equipment and computer readable storage medium
CN115705272A (en) Page testing method, related device and equipment
CN113360417A (en) Test method, session modifier, electronic device, and medium
CN116881161A (en) Software testing method, system, device and electronic equipment
CN112860543A (en) Method and electronic equipment for detecting page operation
CN112817871A (en) Test case library construction method and device and electronic equipment
CN116561751A (en) Code analysis method, apparatus, device, medium, and program product
CN118519920A (en) Automatic test method, device, equipment and storage medium
CN113342633A (en) Performance test method and device

Legal Events

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