CN113704080B - Automatic test method and device - Google Patents
Automatic test method and device Download PDFInfo
- Publication number
- CN113704080B CN113704080B CN202010440985.5A CN202010440985A CN113704080B CN 113704080 B CN113704080 B CN 113704080B CN 202010440985 A CN202010440985 A CN 202010440985A CN 113704080 B CN113704080 B CN 113704080B
- Authority
- CN
- China
- Prior art keywords
- cookie data
- test
- cache
- user name
- request
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000010998 test method Methods 0.000 title abstract description 16
- 238000012360 testing method Methods 0.000 claims abstract description 217
- 235000014510 cooky Nutrition 0.000 claims abstract description 191
- 238000000034 method Methods 0.000 claims abstract description 21
- 238000004590 computer program Methods 0.000 claims description 9
- 238000013515 script Methods 0.000 abstract description 51
- 238000010586 diagram Methods 0.000 description 20
- 230000008569 process Effects 0.000 description 11
- 238000004891 communication Methods 0.000 description 7
- 238000013461 design Methods 0.000 description 6
- 230000006870 function Effects 0.000 description 6
- 230000003287 optical effect Effects 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- VYZAMTAEIAYCRO-UHFFFAOYSA-N Chromium Chemical compound [Cr] VYZAMTAEIAYCRO-UHFFFAOYSA-N 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000008901 benefit Effects 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 239000000835 fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 238000010276 construction Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/08—Network architectures or network communication protocols for network security for authentication of entities
- H04L63/083—Network architectures or network communication protocols for network security for authentication of entities using passwords
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- General Engineering & Computer Science (AREA)
- Quality & Reliability (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Signal Processing (AREA)
- Computer Networks & Wireless Communication (AREA)
- Computer Security & Cryptography (AREA)
- Debugging And Monitoring (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The invention discloses an automatic test method and device, and relates to the technical field of computers. One embodiment of the method comprises the following steps: receiving a request for acquiring Cookie data sent by a test client, wherein the request for acquiring Cookie data carries a user name and a user password; judging whether Cookie data corresponding to the user name exists in a cache; if yes, 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. The implementation mode can solve the technical problems of low automation degree, low test efficiency or script redundancy.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an automatic testing method and apparatus.
Background
When executing the automation test of Web UI (Web product interface design) or http interface, it is generally necessary to log in the user account first to perform the subsequent automation test operation. The current common practice is as follows:
1) Before automatic testing is executed, a tester manually logs in a user account in a browser in advance;
2) An effective Cookie is obtained by manually intercepting an http request, and then the Cookie is put into a test script;
3) The process of logging in once is executed through the script before each automated script is run.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
Scheme 1) and scheme 2) are not truly automated tests, and the script cannot be automatically executed in the continuous integration process; scheme 3) reduces execution efficiency and creates a lot of script redundancy.
Disclosure of Invention
In view of the above, the embodiment of the invention provides an automatic testing method and an automatic testing device, so as to solve the technical problems of low automation degree, low testing efficiency or script redundancy.
To achieve the above object, according to an aspect of the embodiments of the present invention, there is provided an automated testing method, applied to a testing server, including:
Receiving a request for acquiring Cookie data sent by a test client, wherein the request for acquiring Cookie data carries a user name and a user password;
judging whether Cookie data corresponding to the user name exists in a cache;
if yes, 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.
Optionally, generating corresponding Cookie data according to the user name and the user password includes:
Based on a headless browser mode, sending a page login request to an application server, wherein the page login request carries the user name and the user password;
And receiving the Cookie data returned by the application server, and storing the Cookie data into the cache.
Optionally, the Cookie data includes a session identifier and an expiration time of the Cookie data.
Optionally, returning the Cookie data in the cache to the test client includes:
judging whether the current time is earlier than the expiration time of the Cookie data in the cache;
if yes, returning the Cookie data in the cache to the test client;
If not, deleting the outdated Cookie data in the cache, generating corresponding Cookie data according to the user name and the user password, and returning the generated Cookie data to the test client.
In addition, according to another aspect of the embodiment of the present invention, there is provided an automated testing method, provided at a testing client, including:
sending a request for acquiring Cookie data to a test server, wherein the request for acquiring Cookie data carries a user name and a user password;
Receiving Cookie data returned by the test server;
And writing the Cookie data into a request head of a test script, and executing the test script to enable the user name to carry out service test in a login state.
Optionally, the test script designs a test script or an interface test script for the network product interface.
In addition, according to another aspect of the embodiment of the present invention, there is provided an automated testing apparatus, provided at a testing server, including:
The first receiving module is used for receiving a request for acquiring the Cookie data sent by the test client, wherein the request for acquiring the Cookie data carries a user name and a user password;
The acquisition module is used for judging whether Cookie data corresponding to the user name exists in the cache; if yes, 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.
Optionally, the acquiring module is further configured to:
Based on a headless browser mode, sending a page login request to an application server, wherein the page login request carries the user name and the user password;
And receiving the Cookie data returned by the application server, and storing the Cookie data into the cache.
Optionally, the Cookie data includes a session identifier and an expiration time of the Cookie data.
Optionally, the acquiring module is further configured to:
judging whether the current time is earlier than the expiration time of the Cookie data in the cache;
if yes, returning the Cookie data in the cache to the test client;
If not, deleting the outdated Cookie data in the cache, generating corresponding Cookie data according to the user name and the user password, and returning the generated Cookie data to the test client.
In addition, according to another aspect of the embodiment of the present invention, there is provided an automated testing apparatus, provided at a testing client, including:
the request module is used for sending a request for acquiring the Cookie data to the test server, wherein the request for acquiring the Cookie data carries a user name and a user password;
The second receiving module is used for receiving the Cookie data returned by the test server;
And the test module is used for writing the Cookie data into a request head of a test script, and executing the test script so that the user name carries out service test in a login state.
Optionally, the test script designs a test script or an interface test script for the network product interface.
According to another aspect of an embodiment of the present invention, there is also provided an electronic device including:
One or more processors;
storage means for storing one or more programs,
The one or more processors implement the method of any of the embodiments described above when the one or more programs are executed by the one or more processors.
According to another aspect of an embodiment of the present invention, there is also provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements the method according to any of the embodiments described above.
One embodiment of the above invention has the following advantages or benefits: because the technical means of judging whether the Cookie data exist in the cache of the test server or not is adopted, if yes, the Cookie data in the cache are returned to the test client, if not, the Cookie data are generated, and the generated Cookie data are returned to the test client, the technical problems of low automation degree, low test efficiency or script redundancy in the prior art are solved. According to the embodiment of the invention, the test server is added between the test client and the application server, so that the automatic login of the test client is realized, a tester does not need to pay attention to and process login operation and only needs to pay attention to the test of the service, and the test efficiency is improved; after receiving the Cookie data, the client automatically writes the Cookie data into a request head of the test script, so that the degree of automation of the test is improved; because the test client side does not execute the login authentication script any more, the test script redundancy can be avoided.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main flow of an automated test method according to one embodiment of the invention;
FIG. 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;
FIG. 3 is a schematic diagram of Cookie data returned to a test client by a test server according to an embodiment of the invention;
FIG. 4 is a schematic diagram of a login authentication mechanism according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of the main flow of an automated test method according to one referenceable embodiment of the invention;
FIG. 6 is a schematic diagram of the main flow of an automated test method according to another embodiment of the invention;
FIG. 7 is a schematic diagram of the major modules of an automated test equipment according to one embodiment of the present invention;
FIG. 8 is a schematic diagram of the major modules of an automated test equipment according to another embodiment of the present invention;
FIG. 9 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
Fig. 10 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
FIG. 1 is a schematic diagram of the main flow of an automated test method according to one embodiment of the invention. As an embodiment of the present invention, as shown in fig. 1, the automatic test method is applied to a test server, and may include:
Step 101, a request for acquiring Cookie data sent by a test client is received, wherein the request for acquiring the Cookie data carries a user name and a user password.
Before executing Web UI automation or http interface automation test, the test client initiates an http request to the test server, namely a request for acquiring Cookie data. The request for obtaining the Cookie data carries a user name and a user password of the test account. Optionally, the test client initiates an http request shown in fig. 2 to the test server, where parameters are a user name and a user password of the test account.
And the test server receives a request for acquiring Cookie data sent by the test client, and analyzes the request to obtain the user name and the user password of the test account.
102, Judging whether Cookie data corresponding to the user name exists in a cache; if yes, go to step 103; if not, go to step 104.
After the test server analyzes the user name and the user password from the request, firstly checking whether Cookie data corresponding to the user name exists in the cache.
And step 103, returning the Cookie data in the cache to the test client.
If the Cookie data corresponding to the user name exists in the cache, the Cookie data in the cache is directly returned to the test client without generating the Cookie data. As shown in fig. 3, cookie data returned by the test server to the test client includes a SessionID.
Cookie: sometimes also with its complex form of Cookies. The type "small text file" is information stored (typically encrypted) on the user's local terminal by some website for Session tracking in order to identify the user's identity, temporarily or permanently saved by the user's client computer.
Session: in computers, and in particular in network applications, are referred to as "session control". The Session object stores attributes and configuration information required for a particular user Session. Thus, when a user jumps between Web pages of an application, the variables stored in the Session object will not be lost, but will remain throughout the user Session.
As shown in fig. 4, an application is accessed in the browser, the first time of request needs to log in, after the user name and the user password are filled in, a login request is initiated to the application server, and login authentication is completed. After the login authentication is completed, the application server marks the login state as yes (logged in) in the Session of the user, and simultaneously writes a Cookie (containing a Session id) in the browser, wherein the Cookie is the unique identifier of the user. When the browser revisits the application next time, the Cookie is carried in the request, and the application server side can find a corresponding session according to the Cookie and judge whether the user logs in or not through the session.
In the embodiment of the invention, if Cookie data corresponding to the user name already exists in the cache, the login state of the user in the Session of the application server is yes (logged in), that is, the user has completed login authentication. After the client receives the Cookie data, the Cookie data is written into a request header of the test script, so that the user can complete login authentication, then various service tests can be performed according to the identity of the test account, and the degree of automation of the test is improved.
And 104, generating corresponding Cookie data according to the user name and the user password, and returning the generated Cookie data to the test client.
If the Cookie data corresponding to the user name does not exist in the cache, corresponding Cookie data are generated according to the user name and the user password, and then the generated Cookie data are returned to the test client. After the client receives the Cookie data, the Cookie data is written into a request header of the test script, so that the user can complete login authentication, and then various service tests can be performed according to the identity of the test account.
Optionally, generating corresponding Cookie data according to the user name and the user password includes: based on a headless browser mode (Headless mode), sending a page login request to an application server, wherein the page login request carries the user name and the user password; and receiving the Cookie data returned by the application server, and storing the Cookie data into the cache. If the Cookie data corresponding to the user name does not exist in the cache, executing an automatic script for account login at the test server by Headless. 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 acquire the Cookie data from the cache when requesting again.
Headless mode: the Chrome-head mode, a mode which is newly added by Google aiming at the 59 th edition of the Chrome browser, can use the Chrome browser without opening a UI interface, and has the same running effect as the Chrome. This mode is suitable for executing UI automation scripts on the server.
Optionally, the Cookie data further includes an expiration time, so in step 102, if the Cookie data corresponding to the user name does not exist in the cache, whether the current time is earlier than the expiration time of the Cookie data in the cache is continuously determined; if yes, go to step 103; if not, deleting the outdated Cookie data in the cache, and then executing step 104.
According to the various embodiments described above, it can be seen that the technical means of judging whether Cookie data exists in the cache of the test server, if so, returning the Cookie data in the cache to the test client, if not, generating the Cookie data, and returning the generated Cookie data to the test client are provided, so that the technical problems of low automation degree, low test efficiency or script redundancy in the prior art are solved. According to the embodiment of the invention, the test server is added between the test client and the application server, so that the automatic login of the test client is realized, a tester does not need to pay attention to and process login operation and only needs to pay attention to the test of the service, and the test efficiency is improved; after receiving the Cookie data, the client automatically writes the Cookie data into a request head of the test script, so that the degree of automation of the test is improved; because the test client side does not execute the login authentication script any more, the test script redundancy can be avoided.
FIG. 5 is a schematic diagram of the main flow of an automated test method according to one referenceable embodiment of the invention. As yet another embodiment of the present invention, as shown in fig. 5, the automated testing method is applied to a testing server, and may include:
Step 501, a request for acquiring Cookie data sent by a test client is received, wherein the request for acquiring Cookie data carries a user name and a user password.
Step 502, judging whether Cookie data corresponding to the user name exists in a cache; if yes, go to step 503; if not, go to step 506.
Step 503, judging whether the current time is earlier than the expiration time of the Cookie data in the cache; if yes, go to step 504; if not, step 505 is performed.
And step 504, returning the Cookie data in the cache to the test client.
And step 505, deleting the outdated Cookie data in the cache.
Step 506, based on the headless browser mode, sending a page login request to the application server, wherein the page login request carries the user name and the user password.
Step 507, receiving the Cookie data returned by the application server, and storing the Cookie data in the cache.
And step 508, returning the Cookie data returned by the application server to the test client.
In the process of automatic testing, the test client of the embodiment of the invention can acquire effective Cookie data at any time without executing a login step, so that the test script is efficiently and automatically executed.
In addition, the implementation of the automated test method according to one embodiment of the present invention is described in detail in the automated test method described above, and thus the description thereof will not be repeated here.
FIG. 6 is a schematic diagram of the main flow of an automated test method according to another embodiment of the invention. As another embodiment of the present invention, as shown in fig. 6, the automatic testing method is applied to a testing client, and may include:
step 601, a request for acquiring Cookie data is sent to a test server, wherein the request for acquiring Cookie data carries a user name and a user password.
Before executing Web UI automation or http interface automation test, the test client initiates an http request to the test server, namely a request for acquiring Cookie data. The request for obtaining the Cookie data carries a user name and a user password of the test account. Optionally, the test client initiates an http request shown in fig. 2 to the test server, where parameters are a user name and a user password of the test account.
And step 602, receiving Cookie data returned by the test server.
After receiving the request, the test server analyzes the user name and the user password from the request, and firstly checks whether Cookie data corresponding to the user name exists in the cache. If the Cookie data corresponding to the user name exists in the cache, the Cookie data in the cache is directly returned to the test client without generating the Cookie data. If the Cookie data corresponding to the user name does not exist in the cache, corresponding Cookie data are generated according to the user name and the user password, and then the generated Cookie data are returned to the test client.
And step 603, writing the Cookie data into a request head of a test script, and executing the test script to enable the user name to perform service test in a login state.
After receiving the Cookie data returned by the test server, the test client automatically writes the Cookie data into a request head of the test script, and the user is demonstrated to finish login authentication; and then executing the test script to test various services according to the identity of the test account. Optionally, the test script designs a test script or an interface test script for the network product interface.
It should be noted that, after the login authentication is completed, the application server marks the login state as yes (logged in) in the Session of the user, so that the test client can initiate a service request to the application server in the logged-in state, thereby completing various service tests.
The embodiment of the invention realizes the automatic login of the test client, so that a tester does not need to pay attention to and process login operation and only needs to pay attention to the test of the service, thereby improving the test efficiency; after receiving the Cookie data, the client automatically writes the Cookie data into a request head of the test script, so that the degree of automation of the test is improved; because the test client side does not execute the login authentication script any more, the test script redundancy can be avoided.
FIG. 7 is a schematic diagram of main modules of an automated testing apparatus according to one embodiment of the present invention, as shown in FIG. 7, the automated testing apparatus 700 is disposed at a testing server, and includes a first receiving module 701 and an obtaining module 702; the first receiving module 701 is configured to 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; the obtaining module 702 is configured to determine whether Cookie data corresponding to the user name exists in the cache; if yes, 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.
Optionally, the obtaining module 702 is further configured to:
Based on a headless browser mode, sending a page login request to an application server, wherein the page login request carries the user name and the user password;
And receiving the Cookie data returned by the application server, and storing the Cookie data into the cache.
Optionally, the Cookie data includes a session identifier and an expiration time of the Cookie data.
Optionally, the obtaining module 702 is further configured to:
judging whether the current time is earlier than the expiration time of the Cookie data in the cache;
if yes, returning the Cookie data in the cache to the test client;
If not, deleting the outdated Cookie data in the cache, generating corresponding Cookie data according to the user name and the user password, and returning the generated Cookie data to the test client.
The specific implementation of the automated test equipment according to the present invention is described in detail in the automated test method described above, and thus the description thereof will not be repeated here.
FIG. 8 is a schematic diagram of main modules of an automated testing apparatus according to another embodiment of the present invention, and as shown in FIG. 8, the automated testing apparatus 800 is disposed at a testing client, and includes a request module 801, a second receiving module 802, and a testing module 803; the request module 801 is configured to send a request for acquiring Cookie data to the test server, where the request for acquiring Cookie data carries a user name and a user password; the second receiving module 802 receives Cookie data returned by the test server; the test module 803 is configured to write the Cookie data into a request header of a test script, and execute the test script, so that the user name performs a service test in a login state.
Optionally, the test script designs a test script or an interface test script for the network product interface.
The specific implementation of the automated test equipment according to the present invention is described in detail in the automated test method described above, and thus the description thereof will not be repeated here.
FIG. 9 illustrates an exemplary system architecture 900 in which an automated test method or automated test equipment of embodiments of the invention may be employed.
As shown in fig. 9, system architecture 900 may include terminal devices 901, 902, 903, a network 904, and a server 905. The network 904 is the medium used to provide communications links between the terminal devices 901, 902, 903 and the server 905. The network 904 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 905 over the network 904 using the terminal devices 901, 902, 903 to receive or send messages, etc. Various communication client applications may be installed on the terminal devices 901, 902, 903, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, and the like (by way of example only).
Terminal devices 901, 902, 903 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 905 may be a server that provides various services, such as a background management server (by way of example only) that provides support for shopping-type websites browsed by users using terminal devices 901, 902, 903. The background management server may analyze and process the received data such as the article information query request, and feedback the processing result (e.g., the target push information, the article information—only an example) to the terminal device.
It should be noted that, the automated testing method provided by the embodiment of the present invention is generally executed by the server 905, and accordingly, the automated testing device is generally disposed in the server 905. The automated test methods provided by the embodiments of the present invention may also be performed by the terminal devices 901, 902, 903, and accordingly, the automated test apparatus may be provided in the terminal devices 901, 902, 903.
It should be understood that the number of terminal devices, networks and servers in fig. 9 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 10, there is illustrated a schematic diagram of a computer system 1000 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 10 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 10, the computer system 1000 includes a Central Processing Unit (CPU) 1001, which can execute various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. In the RAM1003, various programs and data required for the operation of the system 1000 are also stored. The CPU 1001, ROM 1002, and RAM1003 are connected to each other by a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
The following components are connected to the I/O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output portion 1007 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), etc., and a speaker, etc.; a storage portion 1008 including a hard disk or the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The 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, or the like, is installed as needed in the drive 1010, so that a computer program read out therefrom is installed as needed in the storage section 1008.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 1009, and/or installed from the removable medium 1011. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 1001.
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 two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer programs according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor comprises a first receiving module and an acquisition module, wherein the names of the modules do not constitute a limitation of the module itself in some cases.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor comprises a request module, a second receiving module and a test module, wherein the names of these modules do not constitute a limitation of the module itself in some cases.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, implement the method of: receiving a request for acquiring Cookie data sent by a test client, wherein the request for acquiring Cookie data carries a user name and a user password; judging whether Cookie data corresponding to the user name exists in a cache; if yes, 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.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, implement the method of: sending a request for acquiring Cookie data to a test server, wherein the request for acquiring Cookie data carries a user name and a user password; receiving Cookie data returned by the test server; and writing the Cookie data into a request head of a test script, and executing the test script to enable the user name to carry out service test in a login state.
According to the technical scheme of the embodiment of the invention, the technical means of judging whether the Cookie data exist in the cache of the test server or not, if yes, returning the Cookie data in the cache to the test client, if not, generating the Cookie data and returning the generated Cookie data to the test client are adopted, so that the technical problems of low automation degree, low test efficiency or script redundancy in the prior art are solved. According to the embodiment of the invention, the test server is added between the test client and the application server, so that the automatic login of the test client is realized, a tester does not need to pay attention to and process login operation and only needs to pay attention to the test of the service, and the test efficiency is improved; after receiving the Cookie data, the client automatically writes the Cookie data into a request head of the test script, so that the degree of automation of the test is improved; because the test client side does not execute the login authentication script any more, the test script redundancy can be avoided.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.
Claims (5)
1. An automated testing method, which is applied to a testing server, comprises the following steps:
Receiving a request for acquiring Cookie data sent by a test client, wherein the request for acquiring Cookie data carries a user name and a user password;
judging whether Cookie data corresponding to the user name exists in a cache;
if yes, 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;
the Cookie data comprises a session identifier and expiration time of the Cookie data;
Returning the Cookie data in the cache to the test client, including:
judging whether the current time is earlier than the expiration time of the Cookie data in the cache;
if yes, returning the Cookie data in the cache to the test client;
If not, deleting the outdated Cookie data in the cache, generating corresponding Cookie data according to the user name and the user password, and returning the generated Cookie data to the test client.
2. The method of claim 1, wherein generating corresponding Cookie data from the user name and the user password comprises:
Based on a headless browser mode, sending a page login request to an application server, wherein the page login request carries the user name and the user password;
And receiving the Cookie data returned by the application server, and storing the Cookie data into the cache.
3. An automated testing device, characterized in that it is disposed at a testing server, and includes:
The first receiving module is used for receiving a request for acquiring the Cookie data sent by the test client, wherein the request for acquiring the Cookie data carries a user name and a user password;
The acquisition module is used for judging whether Cookie data corresponding to the user name exists in the cache; if yes, 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;
the Cookie data comprises a session identifier and expiration time of the Cookie data;
The acquisition module is further configured to:
judging whether the current time is earlier than the expiration time of the Cookie data in the cache;
if yes, returning the Cookie data in the cache to the test client;
If not, deleting the outdated Cookie data in the cache, generating corresponding Cookie data according to the user name and the user password, and returning the generated Cookie data to the test client.
4. An electronic device, comprising:
One or more processors;
storage means for storing one or more programs,
The one or more processors implement the method of claim 1 or 2 when the one or more programs are executed by the one or more processors.
5. A computer readable medium on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to claim 1 or 2.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010440985.5A CN113704080B (en) | 2020-05-22 | 2020-05-22 | Automatic test method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010440985.5A CN113704080B (en) | 2020-05-22 | 2020-05-22 | Automatic test method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113704080A CN113704080A (en) | 2021-11-26 |
CN113704080B true CN113704080B (en) | 2024-09-24 |
Family
ID=78646245
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010440985.5A Active CN113704080B (en) | 2020-05-22 | 2020-05-22 | Automatic test method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113704080B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109344052A (en) * | 2018-08-30 | 2019-02-15 | 北京金山安全软件有限公司 | Automatic interface testing method and device and electronic equipment |
CN110442524A (en) * | 2019-08-09 | 2019-11-12 | 中国建设银行股份有限公司 | It is a kind of for have Certificate Authority web service interface test method and device |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102790772B (en) * | 2012-07-25 | 2015-09-16 | 亿赞普(北京)科技有限公司 | The processing method of Cookie data, server and client side |
CN103179134A (en) * | 2013-04-19 | 2013-06-26 | 中国建设银行股份有限公司 | Single sign on method and system based on Cookie and application server thereof |
CN107341160B (en) * | 2016-05-03 | 2020-09-01 | 北京京东尚科信息技术有限公司 | Crawler intercepting method and device |
CN107797911A (en) * | 2016-09-02 | 2018-03-13 | 北京京东尚科信息技术有限公司 | Method and apparatus for testing HTTP interface |
CN108306877B (en) * | 2018-01-30 | 2020-11-10 | 泰康保险集团股份有限公司 | NODE JS-based user identity information verification method and device and storage medium |
CN109815656A (en) * | 2018-12-11 | 2019-05-28 | 平安科技(深圳)有限公司 | Login authentication method, apparatus, device, and computer-readable storage medium |
CN109933367A (en) * | 2019-02-03 | 2019-06-25 | 广州视源电子科技股份有限公司 | Cookie implementation method and device of small program and computer equipment |
CN110928771A (en) * | 2019-10-30 | 2020-03-27 | 苏州浪潮智能科技有限公司 | Method and system for timed automatic batch test of Rest interfaces |
-
2020
- 2020-05-22 CN CN202010440985.5A patent/CN113704080B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109344052A (en) * | 2018-08-30 | 2019-02-15 | 北京金山安全软件有限公司 | Automatic interface testing method and device and electronic equipment |
CN110442524A (en) * | 2019-08-09 | 2019-11-12 | 中国建设银行股份有限公司 | It is a kind of for have Certificate Authority web service interface test method and device |
Also Published As
Publication number | Publication date |
---|---|
CN113704080A (en) | 2021-11-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110442524B (en) | Method and device for testing web service interface with authentication authorization | |
CN110958237A (en) | Authority verification method and device | |
US11368447B2 (en) | Oauth2 SAML token service | |
CN111104675A (en) | Method and device for detecting system security vulnerability | |
CN112948138B (en) | A method and device for processing messages | |
CN109819033A (en) | A kind of resource file loading method and system | |
CN113722007B (en) | Configuration method, device and system of VPN branch equipment | |
CN109218041B (en) | Request processing method and device for server system | |
CN113271300B (en) | Authentication system and method | |
CN113452733A (en) | File downloading method and device | |
CN110324384B (en) | Data pushing method and device | |
CN112131095A (en) | Pressure testing method and device | |
CN113127335B (en) | System testing method and device | |
CN112491940B (en) | Request forwarding method and device of proxy server, storage medium and electronic equipment | |
CN112015383A (en) | A login method and device | |
CN107634942B (en) | Method and device for identifying malicious request | |
CN112579428B (en) | Interface testing method, device, electronic equipment and storage medium | |
CN111953718B (en) | Page debugging method and device | |
CN113704080B (en) | Automatic test method and device | |
CN109698832B (en) | Method for rapidly providing Portal authentication and rapidly popping Portal authentication page and related equipment | |
CN111338928A (en) | Chrome-based browser testing method and device | |
CN116662430A (en) | Data query method, device, equipment, medium and product applied to multi-system interaction | |
CN112532734B (en) | Method and device for detecting message sensitive information | |
CN112527802B (en) | Soft link method and device based on key value database | |
CN110765445B (en) | Method and device for processing request |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |