Jmeter recording script principle
When the script is recorded, Jmeter acts as a proxy gateway to capture the message information of the listening port by listening to a certain port, and convert the captured request information and response information into corresponding behavior functions. Here we take setting the chrome proxy as an example, and then use jmeter for script recording. The configuration settings of the chrome proxy are as follows:
Add HTTP Proxy Server and Recording Controller
Open Jmeter (version 5.4.1), right click on the test plan > non-test components > HTTP proxy server
Thread Group Right Click > Logic Controller > Recording Controller
As shown below:
We perform related work on recording browser behavior in the HTTP proxy server, as shown in the figure below:
Click the start button in the above figure, and the following dialog box will pop up, telling us that we need to import the CA certificate of Jmeter (the reason is that the CA certificate is required to record the request of the https website), and Jmeter will automatically generate a temporary CA certificate for us in the bin directory. But this certificate is only valid for seven days!
Remarks: If the following three files expire, they can be deleted in the bin directory, and will be automatically generated after re-recording.
ApacheJMeterTemporaryRootCA.crt
ApacheJMeterTemporaryRootCA.usr
proxyserver.jks
After clicking, you can start recording, enter Baidu in the browser, but unfortunately, students will most likely appear the following error page!
How to solve it? We need to import jmeter's ca certificate in chrome
Import the temporary CA certificate generated by Jmeter in chrome
In the settings in chrome, select Privacy & Security > Security > Manage Device Certificates
Be sure to select the trusted root certification authority in the figure below
Be sure to select the trusted root certification authority in the figure below
Be sure to select the trusted root certification authority in the figure below
There are three important words. The default is the first "personal" tab. Importing the certificate in this tab will not succeed in post-recording. I wasted a lot of time here!
Click Import and select \bin \ApacheJMeterTemporaryRootCA.crt, as shown below
Next, the default operation is to import the crt file to complete the operation of chrome importing jmeter temporary CA certificate
Jmeter recording operation
Go back to Jmeter, use the recording function in the HTTP proxy server again, and it will work normally. We can set the recorded Transaction name, as shown in the figure below. Similarly, clicking the stop button in the figure below will stop the recording.
Next, simply operate Baidu in the browser and you will see that the recorded script is saved in the recording controller, as shown in the following figure:
Well, you're done, the recording is successful! Every article of mine hopes to help readers solve problems encountered in actual work! If the article helped you, please like, bookmark, forward! Your encouragement is my biggest motivation to keep updating articles!