A testing method, device, electronic device and computer readable medium
By detecting the network environment type and generating test environment packages, and performing image recognition and recording automation scripts, the problem of low efficiency and quality of user interface automation testing in intranet environments is solved, and an efficient testing process is achieved.
Patent Information
- Application Number
- CN202210831621.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-14
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2042-07-14
AI Technical Summary
User interface automation testing is low in efficiency and quality in intranet environments. It is mainly due to the inability to connect script recording software, which leads to the inability to enable developer mode, the inability to view document object model tree and XML path language positioning, which hinders the application of automated script tools.
By detecting the network environment type, calling the preset test toolkit to generate the test environment package, switching to the intranet environment, performing image recognition to record automated scripts, and adjusting the scripts according to the preset test cases, generating target scripts, and executing scripts to obtain Exception data, realize automated testing.
It reduces the workload of test data preparation, improves test efficiency and quality, and solves the problems of low efficiency and quality of automated testing in intranet environments.
Smart Images

Figure CN115098394B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a testing method, device, electronic device and computer-readable medium. Background Art
[0002] User Interface (UI) automated testing uses tools or scripts to obtain the data displayed on the front-end page for verification, in order to verify the functions of the front-end page of the software to be tested. When performing UI automated testing on the client side, the script recording software cannot be connected because the intranet environment is not interoperable with the Internet. The IE kernel browser encapsulated on the client side blocks the browser's address bar and menu bar, resulting in the inability to open the developer mode, and the inability to view the document object model tree and the XML Path Language (XPath) location corresponding to the element, which greatly hinders the application of recording automated script tools, and the test efficiency and test quality are low.
[0003] In the process of implementing this application, the inventors found that there are at least the following problems in the prior art:
[0004] User interface automation testing efficiency and testing quality are low. Summary of the invention
[0005] In view of this, the embodiments of the present application provide a testing method, an apparatus, an electronic device, and a computer-readable medium, which can solve the problems of low efficiency and low test quality of existing user interface automation testing.
[0006] To achieve the above object, according to one aspect of an embodiment of the present application, a testing method is provided, comprising:
[0007] Receive the test request, detect the current network environment and then determine the corresponding network environment type;
[0008] In response to the network environment type corresponding to a network environment that is not interoperable with the intranet environment, calling a preset test toolkit to be installed in the network environment, thereby generating a test environment package;
[0009] Switch to the intranet environment, load the test environment package, determine the test points, perform image recognition on the test points and record the automated script;
[0010] Adjust the automation script according to the preset test cases to generate the target script;
[0011] Execute the target script, obtain execution exception data and output it.
[0012] Optionally, image recognition is performed on the test points to record an automated script, including:
[0013] When there are multiple test points, determine the test order of each test point;
[0014] Intercept the images corresponding to the target elements at each test point, and then sort the images based on the test order;
[0015] Based on the sorted images, an automation script is generated.
[0016] Optionally, according to a preset test case, adjust the automation script to generate a target script, including:
[0017] Determine the target test point corresponding to the preset test case and the assignment corresponding to the target test point;
[0018] The target test point is matched with the image in the automation script. In response to the existence of an image in the automation script that matches the target test point, the value is filled into the input box corresponding to the image matching the target test point in the automation script, thereby generating the target script.
[0019] Optionally, match target test points to images in an automated script, including:
[0020] Get the position of the target test point and the corresponding position of each image in the automation script;
[0021] Determine the location of the image in the automation script that is the same as or close to the location of the target test point;
[0022] An image corresponding to a position of an image that is the same as or close to a position of a target test point in the automation script is determined as an image that matches the target test point.
[0023] Optionally, the assignment is entered into an input box corresponding to the image matching the target test point in the automation script, including:
[0024] In response to detecting a click operation on an image matching a target test point, the process jumps to an input box corresponding to the image matching the target test point, and then calls an assignment to automatically fill in the input box.
[0025] Optionally, after executing the target script, the method further includes:
[0026] In response to successful execution of the script, the successfully executed script is placed in an editable script library for further editing.
[0027] Optionally, before performing image recognition on the test point to record an automated script, the method further includes:
[0028] In response to the current test being unsuitable for network automation, an image recognition-based automation script recording process is performed.
[0029] In addition, the present application also provides a testing device, comprising:
[0030] A detection unit is configured to receive a test request, detect a current network environment and determine a corresponding network environment type;
[0031] A test environment package generating unit is configured to call a preset test tool package to be installed in the network environment in response to the network environment type corresponding to a network environment that is not interoperable with the intranet environment, thereby generating a test environment package;
[0032] The script recording unit is configured to switch to the intranet environment, load the test environment package, determine the test points, and perform image recognition on the test points to record the automation script;
[0033] The target script generation unit is configured to adjust the automation script according to the preset test case to generate the target script;
[0034] The execution unit is configured to execute the target script, obtain the execution exception data and output it.
[0035] Optionally, the script recording unit is further configured to:
[0036] When there are multiple test points, determine the test order of each test point;
[0037] Intercept the images corresponding to the target elements at each test point, and then sort the images based on the test order;
[0038] Based on the sorted images, an automation script is generated.
[0039] Optionally, the target script generation unit is further configured to:
[0040] Determine the target test point corresponding to the preset test case and the assignment corresponding to the target test point;
[0041] The target test point is matched with the image in the automation script. In response to the existence of an image in the automation script that matches the target test point, the value is filled into the input box corresponding to the image matching the target test point in the automation script, thereby generating the target script.
[0042] Optionally, the target script generation unit is further configured to:
[0043] Get the position of the target test point and the corresponding position of each image in the automation script;
[0044] Determine the location of the image in the automation script that is the same as or close to the location of the target test point;
[0045] An image corresponding to a position of an image that is the same as or close to a position of a target test point in the automation script is determined as an image that matches the target test point.
[0046] Optionally, the target script generation unit is further configured to:
[0047] In response to detecting a click operation on an image matching a target test point, the process jumps to an input box corresponding to the image matching the target test point, and then calls an assignment to automatically fill in the input box.
[0048] Optionally, the execution unit is further configured to:
[0049] In response to successful execution of the script, the successfully executed script is placed in an editable script library for further editing.
[0050] Optionally, the script recording unit is further configured to:
[0051] In response to the current test being unsuitable for network automation, an image recognition-based automation script recording process is performed.
[0052] In addition, the present application also provides a testing electronic device, including: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the one or more processors implement the testing method as described above.
[0053] In addition, the present application also provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned testing method is implemented.
[0054] To achieve the above objective, according to another aspect of the embodiments of the present application, a computer program product is provided.
[0055] A computer program product according to an embodiment of the present application includes a computer program, and when the program is executed by a processor, the test method provided in the embodiment of the present application is implemented.
[0056] One embodiment of the above invention has the following advantages or beneficial effects: the present application receives a test request, detects the current network environment and determines the corresponding network environment type; in response to the network environment type corresponding to a network environment that is not interoperable with the intranet environment, calls a preset test toolkit to be installed in the network environment, and generates a test environment package; switches to the intranet environment, loads the test environment package, determines the test point, performs image recognition on the test point to record an automated script; adjusts the automated script according to the preset test case to generate a target script; executes the target script, obtains execution exception data and outputs it. This can reduce the workload of test data preparation and improve test efficiency and test quality.
[0057] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The accompanying drawings are used to better understand the present application and do not constitute an improper limitation on the present application.
[0059] Figure 1 is a schematic diagram of the main process of a testing method according to an embodiment of the present application;
[0060] Figure 2 is a schematic diagram of the main process of a testing method according to an embodiment of the present application;
[0061] Figure 3 It is a schematic diagram of the main process of a testing method according to an embodiment of the present application;
[0062] Figure 4 is a schematic diagram of the main units of the testing device according to an embodiment of the present application;
[0063] Figure 5 is an exemplary system architecture diagram to which the embodiments of the present application can be applied;
[0064] Figure 6 It is a structural diagram of a computer system of a terminal device or server suitable for implementing an embodiment of the present application. DETAILED DESCRIPTION
[0065] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. The acquisition, storage, use, and processing of data in the technical solution of the present application are in compliance with the relevant provisions of national laws and regulations.
[0066] Figure 1 is a schematic diagram of the main process of the testing method according to an embodiment of the present application, such as Figure 1 As shown, the test methods include:
[0067] Step S101, receiving a test request, detecting the current network environment and then determining the corresponding network environment type.
[0068] In this embodiment, the execution subject of the test method (for example, a server) can receive a test request through a wired connection or a wireless connection. The test request can be a UI automation test request, which can specifically be a request to use a tool or script to obtain the data results displayed on the front-end page for verification to verify the function of the software front-end page to be tested.
[0069] When the execution subject receives the test request, it can detect the network environment type of the current network environment, where the network environment type can include an intranet environment and a network environment that is not interoperable with the intranet environment (such as an Internet environment). That is, when the execution subject receives the test request, it can detect whether the current network environment is an intranet environment or an Internet environment that is not interoperable with the intranet environment.
[0070] Step S102, in response to the network environment type corresponding to a network environment that is not interoperable with the intranet environment, calling a preset test toolkit to be installed in the network environment, thereby generating a test environment package.
[0071] When the executing entity determines that the current network environment detected when receiving the test request is a network environment that is not interoperable with the intranet environment (for example, it can be an Internet environment, that is, an extranet environment), the Python software and third-party libraries required for the test can be installed in the network environment that is not interoperable with the intranet environment, and then the Internet environment with the Python software and third-party libraries installed can be packaged into a test environment package for intranet calls.
[0072] Step S103, switching to the intranet environment, and then loading the test environment package, determining the test points, and performing image recognition on the test points to record and obtain an automation script.
[0073] After installing the python software and third-party libraries required for the test in a network environment that is not interoperable with the intranet environment, the execution subject can switch to the intranet environment, and then load the test environment package required for the test generated in the network environment that is not interoperable with the intranet environment to provide the environment required for this test. In the environment required for this test, start the automatic script recording tool, take screenshots of the content on the application to be tested, and record the script through the screenshot recording method to obtain an automatically recorded script.
[0074] Specifically, before performing image recognition on the test point to record and obtain the automation script, the method further includes:
[0075] In response to the current test being unsuitable for network automation, ie, unsuitable for web automation, an automated script recording process based on image recognition is executed, ie, a cross-platform UI automated testing framework based on the image recognition principle is called to perform script recording in the form of image screenshots.
[0076] Step S104, adjusting the automation script according to the preset test case to generate a target script.
[0077] Specifically, according to the preset test case, the automation script is adjusted to generate a target script, including: determining the target test point corresponding to the preset test case and the assignment corresponding to the target test point; matching the target test point with the image in the automation script, and in response to the existence of an image in the automation script that matches the target test point, filling the assignment into the input box corresponding to the image matching the target test point in the automation script, thereby generating the target script.
[0078] The target test point may be, for example, a user name element, a verification code element, etc. in an automation script, and may be text or a picture. The embodiment of the present application does not limit the specific content and form of the target test point.
[0079] The execution entity can locate the input box corresponding to the image (such as image a) by detecting the image in the automatic recording script clicked by the user (such as image a, for example, image a can be a screenshot), and change the value corresponding to the image (such as image a) in the automatic recording script by entering the assignment of the target test point corresponding to the preset test case into the input box.
[0080] Specifically, matching the target test point with the image in the automation script includes: obtaining the position of the target test point and the corresponding positions of each image in the automation script; wherein the position of the target test point refers to the position of the target test point configured in the preset test case in the automation script.
[0081] Determine the position of the image in the automation script that is the same as or close to the position of the target test point; that is, find out from the automation script whether there is a position (such as position T) that is the same as the position of the target test point. If so, obtain the image at the same position (such as position T). If not, obtain the image at a position close to the position of the target test point from the automation script.
[0082] The image corresponding to the position of the image that is the same as or close to the position of the target test point in the automation script is determined as the image that matches the target test point, so that the image that matches the target test point is more accurate.
[0083] Specifically, the assignment is entered into the input box corresponding to the image matching the target test point in the automation script, including:
[0084] In response to detecting a click operation on an image matching a target test point, the process jumps to an input box corresponding to the image matching the target test point, and then calls an assignment to automatically fill in the input box.
[0085] For example, when a user clicks an image in an automated script that matches a target test point, the execution subject responds to the click operation, and then calls an input box associated with the matching image so that the user can modify the content corresponding to the input box based on a preset test case, thereby obtaining a modified target script.
[0086] Step S105, execute the target script, obtain execution exception data and output it.
[0087] After modifying the automation script based on the preset test case to obtain the target script, the execution subject can execute the target script in the environment required for testing in the intranet environment, monitor the exceptions during the script execution process, obtain the execution exception data and output it.
[0088] This embodiment receives a test request, detects the current network environment and determines the corresponding network environment type; in response to the network environment type corresponding to a network environment that is not interoperable with the intranet environment, calls a preset test toolkit to install it in the network environment, and then generates a test environment package; switches to the intranet environment, loads the test environment package, determines the test point, performs image recognition on the test point to record an automated script; adjusts the automated script according to the preset test case to generate a target script; executes the target script, obtains execution exception data and outputs it. This can reduce the workload of test data preparation and improve test efficiency and test quality.
[0089] Figure 2 is a schematic diagram of the main flow of a testing method according to an embodiment of the present application, such as Figure 2 As shown, the test methods include:
[0090] Step S201, receiving a test request, detecting the current network environment and then determining the corresponding network environment type.
[0091] Step S202, in response to the network environment type corresponding to a network environment that is not interoperable with the intranet environment, calling a preset test toolkit to be installed in the network environment, thereby generating a test environment package.
[0092] Step S203, switching to the intranet environment, and then loading the test environment package to determine the test point.
[0093] After switching to the intranet environment and loading the test environment package, the execution subject can obtain the test configuration file and determine the elements to be tested, that is, the test points, corresponding to the contents on the application to be tested from the test configuration file.
[0094] Step S204: when there are multiple test points, determine the test order of each test point.
[0095] When there are multiple test points corresponding to the content on the application to be tested, the test order of the multiple test points is sorted based on the configuration file, so that the corresponding test points are tested according to the sorting. The test point can correspond to an execution process, such as a login process, or a node in the execution process, such as a login name input step in the login process, or a verification code input step.
[0096] Step S205 , intercepting the image corresponding to the target element of each test point, and then sorting the images based on the test sequence.
[0097] AirTest, a cross-platform UI automation testing framework based on image recognition principles, is used to capture images corresponding to the target elements of each test point, such as images containing "login" and "verification code", etc. The captured images are sorted according to the test order of each test point and filled into the script in sequence.
[0098] Step S206: Generate an automation script based on the sorted images.
[0099] The captured images are sorted according to the test order of each test point and filled into the script in sequence to generate an automated script. If the image in the automated script is clicked by the user, a corresponding input box will pop up. By editing the pop-up input box, the value corresponding to the corresponding image in the automated script can be quickly and accurately modified. This saves the workload of testers in writing scripts and improves test efficiency and test quality.
[0100] Step S207, adjusting the automation script according to the preset test case to generate a target script.
[0101] Step S208, execute the target script, obtain execution exception data and output it.
[0102] Specifically, after executing the target script, the test method further includes: in response to successful script execution, placing the successfully executed script in an editable script library for further editing. Specifically, placing the script that can be replayed under a pycharm (integrated development environment) project, and performing secondary editing of the script to achieve project batch script playback function and data parameterization.
[0103] Figure 3 Schematic diagram of the main process of the testing method according to an embodiment of the present application. The testing method of the embodiment of the present application is applied to the scenario of testing the functions of the application. Figure 3As shown, when the automated test starts, the execution subject first determines whether the current network environment is in the intranet environment. If not, Python and related third-party libraries are installed in the Internet environment, and then the Python system environment is configured, that is, it is uploaded to the computer in the intranet environment for configuration and use. If it is in the intranet environment, in the configured Python system environment, for the Java client developed based on the IE kernel, it is determined whether web automation is applicable, that is, whether the developer mode can be turned on. If so, the client UI automated testing is implemented with the tool selenium + end-to-end automation platform katalon for web application testing. If not, that is, the cloud desktop remote call client cannot set the developer mode and cannot locate elements on the page, then the AirTestIDE image recognition is used to record the automated script, and then the script is written based on the recorded automated script according to the function to be tested to obtain the target script, Pycharm is introduced into the target script, and a batch run script is written to implement client automated testing based on the batch run script.
[0104] For example, the embodiment of the present application performs application function testing in an intranet environment, that is, an environment disconnected from the Internet. The content of the test may include: testing compatibility with browsers - testing the application to see if it can work well on different browsers and operating systems. Testing system functions - creating regression tests to verify software functions and user needs. Supporting automatic recording of actions and automatic generation of test scripts in different languages.
[0105] The test method of the embodiment of the present application first needs to complete the installation of python software and third-party libraries in the Internet environment, and then upload them to the computer in the intranet environment for configuration and use. For the client to be tested, because the client is a browser with a built-in IE kernel after running, and because the client is remotely connected, it is impossible to directly call the installation path, so it is impossible to manually modify the code to solve the positioning and script recording. In order to solve the problem of UI automation positioning, image recognition is used to realize element positioning. First, python and the corresponding AirTest library and tool are installed in a private network environment (for example, an Internet environment that is not interoperable with the intranet). After logging in to the client, start the tool and take a screenshot of the content on the client to realize the recording of the script. Element positioning is realized by touch (screenshot image), content input is realized by text (text), and operations such as enter and delete are realized by keyboard (key name). The sleep (seconds) program sleeps for a few seconds to wait for the page to load, and asserts the expected results of the test through assert_exists / assert_not_exists (picture). The specific test steps are: install python and AirTest library, and configure python environment variables; run AirTestIDE, select and connect to the desktop in the windows window; select the touch method in the AirTest auxiliary window, take a screenshot of the element, and then you can record the script; the client runs according to the script; and use Log Viewer to view the execution log. Place the script that can be played back under the pycharm (integrated development environment) project, and perform secondary editing of the script to realize the project batch script playback function and data parameterization.
[0106] The test scenario of the embodiment of the present application is to realize UI automation by remotely connecting to the client in a dedicated network environment, and to perform positioning operations by comparing screenshots of the content on the client interface to achieve the effect of recording the script; and to perform simple logic editing processing on the recorded script to realize running script verification cases and reduce manual repeated testing. Using screenshot comparison as element positioning and writing automated test scripts can reduce the workload of test data preparation and greatly improve test efficiency and test quality.
[0107] The testing method of the embodiment of the present application utilizes python, AirTest library and AirTestIDE (automated test editor) to locate the xpath that cannot be recognized by the client, breaking the previous method of using xpath for positioning. Instead, it uses image recognition to edit it into a corresponding executable automation case script, saving the tester the workload of locating elements and writing scripts, helping the tester to conveniently record UI automation scripts, and improving the overall testing efficiency and quality.
[0108] Figure 4 Schematic diagram of the main units of the testing device according to the embodiment of the present application. Figure 4 As shown, the testing device 400 includes a detection unit 401 , a prediction environment package generation unit 402 , a script recording unit 403 , a target script generation unit 404 and an execution unit 405 .
[0109] The detection unit 401 is configured to receive a test request, detect the current network environment and then determine the corresponding network environment type.
[0110] The test environment package generating unit 402 is configured to call a preset test toolkit to be installed in the network environment in response to the network environment type corresponding to a network environment that is not interoperable with the intranet environment, thereby generating a test environment package.
[0111] The script recording unit 403 is configured to switch to the intranet environment, load the test environment package, determine the test points, perform image recognition on the test points to record and obtain the automation script.
[0112] The target script generating unit 404 is configured to adjust the automation script according to the preset test case to generate the target script.
[0113] The execution unit 405 is configured to execute the target script, obtain execution exception data and output it.
[0114] In some embodiments, the script recording unit 403 is further configured to: when there are multiple test points, determine the test order of each test point; capture the image corresponding to the target element of each test point, and then sort the images based on the test order; and generate an automated script based on the sorted images.
[0115] In some embodiments, the target script generation unit 404 is further configured to: determine the target test point corresponding to a preset test case and the assignment corresponding to the target test point; match the target test point with the image in the automation script, and in response to the existence of an image in the automation script that matches the target test point, fill the assignment into the input box corresponding to the image matching the target test point in the automation script, thereby generating a target script.
[0116] In some embodiments, the target script generation unit 404 is further configured to: obtain the position of the target test point and the corresponding position of each image in the automation script; determine the position of the image in the automation script that is the same as or close to the position of the target test point; and determine the image corresponding to the position of the image in the automation script that is the same as or close to the position of the target test point as the image that matches the target test point.
[0117] In some embodiments, the target script generation unit 404 is further configured to: in response to detecting a click operation on an image matching a target test point, jump to an input box corresponding to the image matching the target test point, and then call an assignment to automatically fill in the input box.
[0118] In some embodiments, the execution unit 405 is further configured to: in response to successful execution of the script, place the successfully executed script in an editable script library for further editing.
[0119] In some embodiments, the script recording unit 403 is further configured to: in response to the current test being unsuitable for network automation, execute an automated script recording process based on image recognition.
[0120] It should be noted that the test method and the test device of the present application have a corresponding relationship in terms of specific implementation content, so the repeated content will not be described again.
[0121] Figure 5 An exemplary system architecture 500 to which the test method or test device according to the embodiment of the present application can be applied is shown.
[0122] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0123] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0124] The terminal devices 501 , 502 , and 503 may be various electronic devices having a test processing screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0125] Server 505 can be a server that provides various services, such as a background management server that provides support for test requests submitted by users using terminal devices 501, 502, and 503 (only as an example). The background management server can receive the test request, detect the current network environment and determine the corresponding network environment type; in response to the network environment type corresponding to a network environment that is not interoperable with the intranet environment, call the preset test toolkit to install it in the network environment, and then generate a test environment package; switch to the intranet environment, and then load the test environment package, determine the test point, perform image recognition on the test point to record an automated script; adjust the automated script according to the preset test case to generate a target script; execute the target script, obtain execution exception data and output it. This can reduce the workload of test data preparation and improve test efficiency and test quality.
[0126] It should be noted that the testing method provided in the embodiment of the present application is generally executed by the server 505 , and accordingly, the testing device is generally set in the server 505 .
[0127] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0128] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present application. Figure 6 The terminal device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0129] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the computer system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0130] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0131] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present application are executed.
[0132] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. Computer-readable storage media may include, for example, but are not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0133] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0134] The units involved in the embodiments described in the present application may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes a detection unit, a test environment package generation unit, a script recording unit, a target script generation unit and an execution unit. The names of these units do not constitute limitations on the units themselves in some cases.
[0135] As another aspect, the present application also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device receives a test request, detects the current network environment and determines the corresponding network environment type; in response to the network environment type corresponding to a network environment that is not interoperable with the intranet environment, calls a preset test toolkit to be installed in the network environment, and then generates a test environment package; switches to the intranet environment, and then loads the test environment package, determines the test point, and performs image recognition on the test point to record an automated script; according to the preset test case, adjusts the automated script to generate a target script; executes the target script, obtains execution exception data and outputs it.
[0136] The computer program product of the present application includes a computer program, and the computer program implements the testing method in the embodiment of the present application when executed by a processor.
[0137] According to the technical solution of the embodiment of the present application, it is possible to reduce the workload of test data preparation and improve test efficiency and test quality.
[0138] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A testing method, characterized in that: include: Receive the test request, detect the current network environment and then determine the corresponding network environment type; In response to the network environment type corresponding to a network environment that is not interoperable with an intranet environment, calling a preset test toolkit to be installed in the network environment, thereby generating a test environment package; Switch to the intranet environment, load the test environment package, determine the test points, perform image recognition on the test points to record and obtain an automated script; The performing image recognition on the test points to record an automation script includes: when there are multiple test points, determining a test order for each of the test points; intercepting images corresponding to target elements of each of the test points, and then sorting the images based on the test order; and generating an automation script based on the sorted images; According to a preset test case, the automation script is adjusted to generate a target script; the adjusting of the automation script according to the preset test case to generate a target script includes: determining a target test point corresponding to the preset test case and an assignment corresponding to the target test point; matching the target test point with an image in the automation script, and in response to the existence of an image in the automation script that matches the target test point, filling the assignment into an input box corresponding to the image in the automation script that matches the target test point, thereby generating a target script; matching the target test point with the image in the automation script includes: obtaining a position of the target test point and a position corresponding to each image in the automation script; determining a position of an image in the automation script that is the same as or close to the position of the target test point; and determining an image corresponding to a position of an image in the automation script that is the same as or close to the position of the target test point as an image that matches the target test point; Execute the target script, obtain execution exception data and output it.
2. The method according to claim 1, characterized in that: Inputting the assignment into an input box corresponding to the image matching the target test point in the automation script includes: In response to detecting a click operation on the image matching the target test point, jumping to the input box corresponding to the image matching the target test point, and then calling the assignment to automatically fill in the input box.
3. The method according to claim 1, characterized in that After executing the target script, the method further includes: In response to successful execution of the script, the successfully executed script is placed in an editable script library for further editing.
4. The method according to claim 1, characterized in that: Before performing image recognition on the test point to record an automated script, the method further includes: In response to the current test being unsuitable for network automation, an image recognition-based automation script recording process is performed.
5. A testing device, characterized in that: include: A detection unit is configured to receive a test request, detect a current network environment and determine a corresponding network environment type; A test environment package generating unit is configured to call a preset test toolkit to be installed in the network environment in response to the network environment type corresponding to a network environment that is not interoperable with the intranet environment, thereby generating a test environment package; A script recording unit is configured to switch to an intranet environment, load the test environment package, determine a test point, and perform image recognition on the test point to record an automated script; The script recording unit is further configured to: when there are multiple test points, determine a test order for each of the test points; intercepting images corresponding to target elements of each of the test points, and then sorting the images based on the test sequence; Generate an automation script based on the sorted images; A target script generating unit is configured to adjust the automation script according to a preset test case to generate a target script; The target script generating unit is further configured to: determine a target test point corresponding to a preset test case and an assignment corresponding to the target test point; Matching the target test point with an image in the automation script, and in response to the existence of an image in the automation script that matches the target test point, filling the assignment into an input box corresponding to the image in the automation script that matches the target test point, thereby generating a target script; The target script generation unit is further configured to: obtain the position of the target test point and the position corresponding to each image in the automation script; determine the position of the image in the automation script that is the same as or close to the position of the target test point; determine the image corresponding to the position of the image in the automation script that is the same as or close to the position of the target test point as the image matching the target test point; The execution unit is configured to execute the target script, obtain execution exception data and output it.
6. The device according to claim 5, characterized in that The target script generation unit is further configured to: In response to detecting a click operation on the image matching the target test point, jumping to the input box corresponding to the image matching the target test point, and then calling the assignment to automatically fill in the input box.
7. The device according to claim 5, characterized in that The execution unit is further configured to: In response to successful execution of the script, the successfully executed script is placed in an editable script library for further editing.
8. A test electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
