Automated testing method and device

By introducing the test server between the test client and the application server to automatically process cookie data, the problems of low automation and low test efficiency in automated testing are solved, achieving efficient automated login and reducing script redundancy.

CN113704080BActive Publication Date: 2024-09-24BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010440985.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-22
Publication Date
2024-09-24
Estimated Expiration
2040-05-22

AI Technical Summary

Technical Problem

In the existing technology, automated testing has a low degree of automation, low testing efficiency, or causes script redundancy. In particular, manual login or redundant script execution is required in automated testing of Web UI and http interfaces.

Method used

By introducing the test server between the test client and the application server, it receives the request to obtain cookie data, determines whether there is cookie data in the cache, and returns it if it exists. Otherwise, it generates and returns cookie data, and writes it into the test script. In the request header, automated login is implemented.

Benefits of technology

It improves the automation and efficiency of testing and reduces the redundancy of test scripts. Testers do not need to pay attention to login operations and focus on business testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113704080B
    Figure CN113704080B
Patent Text Reader

Abstract

The present invention discloses an automated testing method and device, and relates to the field of computer technology. A specific implementation of the method includes: receiving a request for obtaining cookie data sent by a test client, the request for obtaining cookie data carrying a user name and a user password; judging whether there is cookie data corresponding to the user name in the cache; if so, returning the cookie data in the cache to the test client; if not, generating corresponding cookie data according to the user name and the user password, and returning the generated cookie data to the test client. This implementation can solve the technical problems of low automation, low test efficiency or script redundancy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an automated testing method and device. Background Art

[0002] When performing Web UI (network product interface design) automation or http interface automation testing, you usually need to log in to the user account before you can perform subsequent automated testing operations. Currently, there are several common practices:

[0003] 1) Before executing automated testing, the tester manually logs in to the user account in the browser in advance;

[0004] 2) Obtain a valid cookie by manually intercepting the http request, and then put the cookie into the test script;

[0005] 3) Before each automated script runs, a login process is executed through the script.

[0006] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0007] Solutions 1) and 2) are not true automated tests, and the scripts cannot be automatically executed during the continuous integration process; Solution 3) will reduce execution efficiency and cause a lot of script redundancy. Summary of the invention

[0008] In view of this, an embodiment of the present invention provides an automated testing method and device to solve the technical problems of low automation, low testing efficiency or script redundancy.

[0009] To achieve the above object, according to one aspect of an embodiment of the present invention, there is provided an automated testing method, which is applied to a testing server, and includes:

[0010] Receive a request from a test client to obtain Cookie data, where the request carries a user name and a user password;

[0011] Determine whether there is cookie data corresponding to the user name in the cache;

[0012] If yes, the Cookie data in the cache is returned to the test client;

[0013] If not, corresponding Cookie data is generated according to the user name and the user password, and the generated Cookie data is returned to the test client.

[0014] Optionally, generating corresponding Cookie data according to the user name and the user password includes:

[0015] Based on the headless browser mode, a page login request is sent to the application server, wherein the page login request carries the user name and the user password;

[0016] Receive the Cookie data returned by the application server, and store the Cookie data in the cache.

[0017] Optionally, the Cookie data includes a session identifier and an expiration time of the Cookie data.

[0018] Optionally, returning the Cookie data in the cache to the test client includes:

[0019] Determine whether the current time is earlier than the expiration time of the Cookie data in the cache;

[0020] If yes, the Cookie data in the cache is returned to the test client;

[0021] If not, the expired Cookie data in the cache is deleted, corresponding Cookie data is generated according to the user name and the user password, and the generated Cookie data is returned to the test client.

[0022] In addition, according to another aspect of an embodiment of the present invention, there is provided an automated testing method, which is arranged in a test client and includes:

[0023] Send a request to the test server to obtain Cookie data, where the request carries a user name and a user password;

[0024] Receive Cookie data returned by the test server;

[0025] The Cookie data is written into the request header of the test script, and the test script is executed, so that the user name performs business testing in a logged-in state.

[0026] Optionally, the test script is a network product interface design test script or an interface test script.

[0027] In addition, according to another aspect of the embodiment of the present invention, there is provided an automated testing device, which is arranged at a testing server, and includes:

[0028] A first receiving module is used to receive a request sent by a test client to obtain Cookie data, wherein the request to obtain Cookie data carries a user name and a user password;

[0029] The acquisition module is used to determine whether there is Cookie data corresponding to the user name in the cache; if so, the Cookie data in the cache is returned to the test client; if not, the corresponding Cookie data is generated according to the user name and the user password, and the generated Cookie data is returned to the test client.

[0030] Optionally, the acquisition module is further used for:

[0031] Based on the headless browser mode, a page login request is sent to the application server, wherein the page login request carries the user name and the user password;

[0032] Receive the Cookie data returned by the application server, and store the Cookie data in the cache.

[0033] Optionally, the Cookie data includes a session identifier and an expiration time of the Cookie data.

[0034] Optionally, the acquisition module is further used for:

[0035] Determine whether the current time is earlier than the expiration time of the Cookie data in the cache;

[0036] If yes, the Cookie data in the cache is returned to the test client;

[0037] If not, the expired Cookie data in the cache is deleted, corresponding Cookie data is generated according to the user name and the user password, and the generated Cookie data is returned to the test client.

[0038] In addition, according to another aspect of an embodiment of the present invention, there is provided an automated testing device, which is arranged on a test client and includes:

[0039] A request module is used to send a request to the test server to obtain Cookie data, where the request carries a user name and a user password;

[0040] The second receiving module receives the Cookie data returned by the test server;

[0041] The test module is used to write the Cookie data into the request header of the test script and execute the test script so that the user name performs business testing in the logged-in state.

[0042] Optionally, the test script is a network product interface design test script or an interface test script.

[0043] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, including:

[0044] one or more processors;

[0045] a storage device for storing one or more programs,

[0046] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above embodiments.

[0047] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in any one of the above embodiments is implemented.

[0048] One embodiment of the above invention has the following advantages or beneficial effects: because it adopts a technical means of judging whether there is Cookie data in the cache of the test server, if so, returning the Cookie data in the cache to the test client, if not, generating Cookie data and returning the generated Cookie data to the test client, it overcomes the technical problems of low automation, low test efficiency or script redundancy in the prior art. The embodiment of the present invention realizes automatic login of the test client by adding a test server between the test client and the application server, so that the tester does not need to pay attention to and process the login operation, but only needs to focus on the business testing, thereby improving the test efficiency; and after the client receives the Cookie data, it automatically writes the Cookie data into the request header of the test script, thereby improving the automation of the test; because the test client no longer executes the login authentication script, it can avoid causing test script redundancy.

[0049] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0051] Figure 1 is a schematic diagram of the main process of an automated testing method according to an embodiment of the present invention;

[0052] Figure 2 is a schematic diagram of an http request initiated by a test client to a test server according to an embodiment of the present invention;

[0053] Figure 3 is a schematic diagram of Cookie data returned by a test server to a test client according to an embodiment of the present invention;

[0054] Figure 4 is a schematic diagram of a login authentication mechanism according to an embodiment of the present invention;

[0055] Figure 5 is a schematic diagram of the main process of an automated testing method according to a reference embodiment of the present invention;

[0056] Figure 6 is a schematic diagram of the main process of an automated testing method according to another embodiment of the present invention;

[0057] Figure 7 is a schematic diagram of main modules of an automated testing device according to an embodiment of the present invention;

[0058] Figure 8 is a schematic diagram of main modules of an automated testing device according to another embodiment of the present invention;

[0059] Fig. 9 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0060] Fig.10 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0061] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention 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 invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0062] Figure 1 Schematic diagram of the main process of the automated testing method according to an embodiment of the present invention. Figure 1 As shown, the automated testing method is applied to the testing server and may include:

[0063] Step 101: Receive a request for obtaining Cookie data sent by a test client, where the request for obtaining Cookie data carries a user name and a user password.

[0064] Before executing Web UI automation or http interface automation testing, the test client first initiates an http request to the test server, i.e., a request to obtain cookie data. The request to obtain cookie data carries the user name and password of the test account. Optionally, the test client initiates the following to the test server: Figure 2 The following figure shows an http request with the test account username and password as parameters.

[0065] The test server receives the request for obtaining Cookie data sent by the test client, and parses it to obtain the user name and password of the test account.

[0066] Step 102, determine whether there is Cookie data corresponding to the user name in the cache; if so, execute step 103; if not, execute step 104.

[0067] After the test server parses the user name and user password from the request, it first checks whether there is cookie data corresponding to the user name in the cache.

[0068] Step 103: Return the Cookie data in the cache to the test client.

[0069] If the cookie data corresponding to the user name already exists in the cache, there is no need to generate cookie data, and the cookie data in the cache is directly returned to the test client. Figure 3 As shown, the Cookie data returned by the test server to the test client contains the SessionID.

[0070] Cookie: Sometimes also called Cookies in its plural form. It is a "small text file" that is stored on the user's local terminal (usually encrypted) by some websites in order to identify the user and track the session. It is information temporarily or permanently stored by the user's client computer.

[0071] Session: In computers, especially in network applications, it is called "session control". The Session object stores the properties and configuration information required for a specific user session. In this way, when the user jumps between web pages of the application, the variables stored in the Session object will not be lost, but will exist throughout the user session.

[0072] like Figure 4As shown in the figure, when you access an application in a browser, you need to log in for the first request. After filling in the user name and password, you initiate a login request to the application server to complete the login authentication. After completing the login authentication, the application server marks the login status as yes (logged in) in the user's Session, and writes a cookie (including SessionID) in the browser. This cookie is the unique identifier of this user. The next time the browser accesses this application, the request will carry this cookie. The application server will find the corresponding session based on this cookie and determine whether the user is logged in through the session.

[0073] In an embodiment of the present invention, if the cookie data corresponding to the user name already exists in the cache, it indicates that the user's login status in the Session of the application server is yes (logged in), that is, the user has completed the login authentication. After receiving the cookie data, the client writes the cookie data into the request header of the test script, indicating that the user has completed the login authentication, and then various business tests can be performed under the identity of the test account, thereby improving the automation of the test.

[0074] Step 104: Generate corresponding Cookie data according to the user name and the user password, and return the generated Cookie data to the test client.

[0075] If the cookie data corresponding to the user name does not exist in the cache, the corresponding cookie data is generated according to the user name and the user password, and then the generated cookie data is returned to the test client. After receiving the cookie data, the client writes the cookie data into the request header of the test script, indicating that the user has completed the login authentication, and then various business tests can be performed under the identity of the test account.

[0076] Optionally, the corresponding Cookie data is generated according to the user name and the user password, including: based on the headless browser mode (Headless mode), sending a page login request to the application server, the page login request carries the user name and the user password; receiving the Cookie data returned by the application server, and storing the Cookie data in the cache. If the Cookie data corresponding to the user name does not exist in the cache, the automated script for account login is executed in Headless on the test server. After successful login, the test server writes the Cookie data returned by the application server into the cache, so that other test clients can directly obtain the Cookie data from the cache when requesting again.

[0077] Headless mode: Chrome-headless mode is a new mode added by Google for Chrome browser version 59. It allows you to use the Chrome browser without opening the UI interface, and the operation effect is consistent with Chrome. This mode is suitable for executing UI automation scripts on the server.

[0078] Optionally, the Cookie data also includes an expiration time. Therefore, in step 102, if the Cookie data corresponding to the user name does not exist in the cache, continue to determine whether the current time is earlier than the expiration time of the Cookie data in the cache; if so, execute step 103; if not, delete the expired Cookie data in the cache, and then execute step 104.

[0079] According to the various embodiments described above, it can be seen that the embodiment of the present invention solves the technical problems of low automation, low test efficiency or script redundancy in the prior art by determining whether there is cookie data in the cache of the test server. If so, the cookie data in the cache is returned to the test client. If not, cookie data is generated and the generated cookie data is returned to the test client. The embodiment of the present invention realizes the automatic login of the test client by adding a test server between the test client and the application server, so that the tester does not need to pay attention to and process the login operation, but only needs to focus on the business testing, thereby improving the test efficiency; and after the client receives the cookie data, the cookie data is automatically written into the request header of the test script, thereby improving the automation of the test; because the test client no longer executes the login authentication script, the redundancy of the test script can be avoided.

[0080] Figure 5 Schematic diagram of the main process of an automated testing method according to a reference embodiment of the present invention. As another embodiment of the present invention, Figure 5 As shown, the automated testing method is applied to the testing server and may include:

[0081] Step 501: Receive a request for obtaining Cookie data sent by a test client, where the request for obtaining Cookie data carries a user name and a user password.

[0082] Step 502, determine whether there is Cookie data corresponding to the user name in the cache; if so, execute step 503; if not, execute step 506.

[0083] Step 503, determine whether the current time is earlier than the expiration time of the Cookie data in the cache; if so, execute step 504; if not, execute step 505.

[0084] Step 504: Return the Cookie data in the cache to the test client.

[0085] Step 505: Delete the expired Cookie data in the cache.

[0086] Step 506: Based on the headless browser mode, a page login request is sent to the application server, where the page login request carries the user name and the user password.

[0087] Step 507: Receive Cookie data returned by the application server, and store the Cookie data in the cache.

[0088] Step 508: Return the Cookie data returned by the application server to the test client.

[0089] During the automated testing process, the test client of the embodiment of the present invention can obtain valid Cookie data at any time without executing the login step, so that the test script can be executed efficiently and automatically.

[0090] In addition, the specific implementation content of the automated testing method in a reference embodiment of the present invention has been described in detail in the automated testing method described above, so the repeated content will not be described here.

[0091] Figure 6 Schematic diagram of the main process of the automated testing method according to another embodiment of the present invention. Figure 6 As shown, the automated testing method is applied to test the client end and may include:

[0092] Step 601: Send a request to the test server to obtain Cookie data, where the request carries a user name and a user password.

[0093] Before executing Web UI automation or http interface automation testing, the test client first initiates an http request to the test server, i.e., a request to obtain cookie data. The request to obtain cookie data carries the user name and password of the test account. Optionally, the test client initiates the following to the test server: Figure 2 The following figure shows an http request with the test account username and password as parameters.

[0094] Step 602, receiving Cookie data returned by the test server.

[0095] After receiving the request, the test server parses the username and password from the request, and first checks whether there is cookie data corresponding to the username in the cache. If the cookie data corresponding to the username already exists in the cache, there is no need to generate cookie data, and the cookie data in the cache is directly returned to the test client. If the cookie data corresponding to the username does not exist in the cache, the corresponding cookie data is generated according to the username and the user password, and then the generated cookie data is returned to the test client.

[0096] Step 603, write the Cookie data into the request header of the test script, execute the test script, and make the user name perform business testing in the logged-in state.

[0097] After receiving the cookie data returned by the test server, the test client automatically writes the cookie data into the request header of the test script, indicating that the user has completed the login authentication; then the test script is executed to perform various business tests under the identity of the test account. Optionally, the test script is a network product interface design test script or an interface test script.

[0098] It should be pointed out that after completing the login authentication, the application server marks the login status as yes (logged in) in the user's Session, so the test client can initiate a service request to the application server in the logged in state, thereby completing various service tests.

[0099] The embodiment of the present invention realizes automatic login of the test client, so that the tester does not need to pay attention to and process the login operation, but only needs to focus on the business testing, thereby improving the test efficiency; and after the client receives the cookie data, the cookie data is automatically written into the request header of the test script, thereby improving the automation level of the test; because the test client no longer executes the login authentication script, the redundancy of the test script can be avoided.

[0100] Figure 7 is a schematic diagram of the main modules of an automated testing device according to an embodiment of the present invention. Figure 7As shown, the automated testing device 700 is arranged at the test server end, and includes a first receiving module 701 and an obtaining module 702; wherein the first receiving module 701 is used to receive a request for obtaining Cookie data sent by the test client, and the request for obtaining Cookie data carries a user name and a user password; the obtaining module 702 is used to determine whether there is Cookie data corresponding to the user name in the cache; if so, the Cookie data in the cache is returned to the test client; if not, the corresponding Cookie data is generated according to the user name and the user password, and the generated Cookie data is returned to the test client.

[0101] Optionally, the acquisition module 702 is further used to:

[0102] Based on the headless browser mode, a page login request is sent to the application server, wherein the page login request carries the user name and the user password;

[0103] Receive the Cookie data returned by the application server, and store the Cookie data in the cache.

[0104] Optionally, the Cookie data includes a session identifier and an expiration time of the Cookie data.

[0105] Optionally, the acquisition module 702 is further used to:

[0106] Determine whether the current time is earlier than the expiration time of the Cookie data in the cache;

[0107] If yes, the Cookie data in the cache is returned to the test client;

[0108] If not, the expired Cookie data in the cache is deleted, corresponding Cookie data is generated according to the user name and the user password, and the generated Cookie data is returned to the test client.

[0109] It should be noted that the specific implementation content of the automated testing device of the present invention has been described in detail in the automated testing method described above, so the repeated content will not be described again here.

[0110] Figure 8 is a schematic diagram of main modules of an automated testing device according to another embodiment of the present invention. Figure 8As shown, the automated testing device 800 is arranged on the test client, and includes a request module 801, a second receiving module 802 and a test module 803; wherein the request module 801 is used to send a request for obtaining Cookie data to the test server, and the request for obtaining Cookie data carries a user name and a user password; the second receiving module 802 receives the Cookie data returned by the test server; the test module 803 is used to write the Cookie data into the request header of the test script, and execute the test script, so that the user name performs business testing in a logged-in state.

[0111] Optionally, the test script is a network product interface design test script or an interface test script.

[0112] It should be noted that the specific implementation content of the automated testing device of the present invention has been described in detail in the automated testing method described above, so the repeated content will not be described again here.

[0113] Fig. 9 An exemplary system architecture 900 is shown to which an automated testing method or an automated testing device according to an embodiment of the present invention can be applied.

[0114] like Fig. 9 As shown, system architecture 900 may include terminal devices 901, 902, 903, network 904 and server 905. Network 904 is used to provide a medium for communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0115] Users can use terminal devices 901, 902, 903 to interact with server 905 through network 904 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 901, 902, 903, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).

[0116] The terminal devices 901 , 902 , and 903 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0117] The server 905 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 901, 902, and 903. The backend management server may analyze and process the received data such as the item information query request, and feed back the processing results (such as target push information, item information - only an example) to the terminal device.

[0118] It should be noted that the automated testing method provided in the embodiment of the present invention is generally executed by the server 905, and accordingly, the automated testing device is generally set in the server 905. The automated testing method provided in the embodiment of the present invention can also be executed by the terminal devices 901, 902, and 903, and accordingly, the automated testing device can be set in the terminal devices 901, 902, and 903.

[0119] It should be understood that Fig. 9 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 the implementation requirements.

[0120] Reference below Fig.10 , which shows a schematic diagram of the structure of a computer system 1000 of a terminal device suitable for implementing an embodiment of the present invention. Fig.10 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0121] like Fig.10 As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which 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 part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the system 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0122] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 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, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.

[0123] In particular, according to the embodiments disclosed in the present invention, 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 invention include a computer program, 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 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the present invention are executed.

[0124] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, 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 invention, 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 invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. 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.

[0125] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program according to various embodiments of the present invention. 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.

[0126] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as follows: a processor includes a first receiving module and an acquisition module, wherein the names of these modules do not constitute a limitation on the modules themselves in some cases.

[0127] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as follows: a processor includes a request module, a second receiving module and a test module, wherein the names of these modules do not constitute a limitation on the modules themselves in some cases.

[0128] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device implements the following method: receiving a request for obtaining cookie data sent by a test client, the request for obtaining cookie data carries a user name and a user password; determining whether there is cookie data corresponding to the user name in the cache; if so, returning the cookie data in the cache to the test client; if not, generating corresponding cookie data according to the user name and the user password, and returning the generated cookie data to the test client.

[0129] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device implements the following method: sending a request to obtain Cookie data to a test server, wherein the request to obtain Cookie data carries a user name and a user password; receiving Cookie data returned by the test server; writing the Cookie data into the request header of the test script, and executing the test script so that the user name performs a business test in a logged-in state.

[0130] According to the technical solution of the embodiment of the present invention, because it adopts a technical means of judging whether there is Cookie data in the cache of the test server, if so, returning the Cookie data in the cache to the test client, if not, generating Cookie data and returning the generated Cookie data to the test client, it overcomes the technical problems of low automation, low test efficiency or script redundancy in the prior art. The embodiment of the present invention realizes automatic login of the test client by adding a test server between the test client and the application server, so that the tester does not need to pay attention to and process the login operation, but only needs to focus on the testing of the business, thereby improving the testing efficiency; and after the client receives the Cookie data, it automatically writes the Cookie data into the request header of the test script, thereby improving the automation of the test; because the test client no longer executes the login authentication script, it can avoid causing redundant test scripts.

[0131] The above specific implementations do not constitute a limitation on the protection scope of the present invention. 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 modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. An automated testing method, characterized in that: Applied to the test server, including: Receive a request from a test client to obtain Cookie data, where the request carries a user name and a user password; Determine whether there is cookie data corresponding to the user name in the cache; If yes, the Cookie data in the cache is returned to the test client; If not, generate corresponding Cookie data according to the user name and the user password, and return the generated Cookie data to the test client; The cookie data includes a session identifier and an expiration time of the cookie data; Returning the Cookie data in the cache to the test client includes: Determine whether the current time is earlier than the expiration time of the Cookie data in the cache; If yes, the Cookie data in the cache is returned to the test client; If not, the expired Cookie data in the cache is deleted, corresponding Cookie data is generated according to the user name and the user password, and the generated Cookie data is returned to the test client.

2. The method according to claim 1, characterized in that Generate corresponding Cookie data according to the user name and the user password, including: Based on the headless browser mode, a page login request is sent to the application server, wherein the page login request carries the user name and the user password; Receive the Cookie data returned by the application server, and store the Cookie data in the cache.

3. An automated testing device, characterized in that: Set on the test server, including: A first receiving module is used to receive a request sent by a test client to obtain Cookie data, wherein the request to obtain Cookie data carries a user name and a user password; An acquisition module is used to determine whether there is Cookie data corresponding to the user name in the cache; if so, return the Cookie data in the cache to the test client; if not, generate corresponding Cookie data according to the user name and the user password, and return the generated Cookie data to the test client; The cookie data includes a session identifier and an expiration time of the cookie data; The acquisition module is also used for: Determine whether the current time is earlier than the expiration time of the Cookie data in the cache; If yes, the Cookie data in the cache is returned to the test client; If not, the expired Cookie data in the cache is deleted, corresponding Cookie data is generated according to the user name and the user password, and the generated Cookie data is returned to the test client.

4. An 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 claim 1 or 2.

5. 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 claim 1 or 2 is implemented.