Jmeter acquires the code of the WeChat applet login interface

The company has newly developed small program functions, and some interfaces need to be pressure tested and concurrent. The first time I came into contact with the small program, I was stuck from the very beginning of the login. The reason is that the code in the login interface changes in real time. After Baidu for a long time, I finally refer to this Big Brother’s article ( [Case] ​​Use Jmeter to do interface testing of WeChat applet project_Xiaoqiang test blog-CSDN blog_jmeter testing WeChat applet ) has been solved, recorded in detail and added details on the basis, and provided it to later partners some ideas

From the interface itself, its testing should be the same as other projects. So it is not difficult to understand, what we need to prepare for the interface test of the applet

Materials are:

1. A complete interface document (what is a complete interface document has been written in the previous article, so it will not be repeated here)

2. Selection of test tools (Jmeter/postman/or directly code?), here I will explain jmeter

3. Packet capture tool for better analysis of data reversal

OK, the preparatory work is complete, now we capture the small program

1. Open the applet, and grab the login interface as shown in the figure below:

Figure (1) is the interface calling server and calling address

Figure (2) shows the interface request parameters and interface return value

2. Configure the interface in jmeter according to the captured parameters , as shown in the figure below:

2.1, jmeter request configuration, as shown below

Description: After the configuration is OK, I am ecstatic and happy, thinking that everything is fine

2.2. Execute the script to view the returned results, as shown in the figure below:

MMP, isn’t the general login interface able to log in successfully after putting in the request parameters? Here, open the applet multiple times by capturing packets to find the request parameters in the login interface

The value ("code": "061xam5b2hJCfP0BNn5b2fL15b2xam5e") will change, of course, there is nothing wrong with it.

3. Analyze and obtain the code value

3.1. According to the error message in 2.2, we can know that the login interface of the applet actually calls the login status of WeChat

3.2. Who gave us the code value? (Analyze specific issues)

Analysis: Because the applet is directly entered through WeChat, the login status of the applet is actually to directly obtain the login status of WeChat, so the code is WeChat

Send to our applet

3.3 How to get the code value?

3.3.1. From a development perspective, directly call the API interface provided by WeChat (not explained here)

3.3.2. Through the WeChat developer tool (download address: stable version Stable Build | WeChat open document , download the corresponding version of the stable version according to your own computer and install it), capture the code and fill it in the login interface, capture method of code value (can communicate with development),

Before generating the return, there is an important step, that is, you need to change the appid in the details to the appid number of the applet you want to test, so that the generated code can be used

 

The method is shown in the figure below:

4. Put the obtained code value into the login request, and initiate a new request, as shown in the following figure:

ps: The login interface test of the applet has failed, and you can happily perform some subsequent operations

Refer to the original text [Case] ​​Use Jmeter to do interface testing of WeChat applet project

Guess you like

Origin blog.csdn.net/m0_65856970/article/details/125372557