Recording script of jmeter performance test

To record scripts with jmeter, in addition to recording with the badboy tool, you can also use the http proxy server that comes with jmeter to record scripts, which is relatively simple.

1. First, we can create a template for recording scripts in jmeter, which adds the things we need to use, so we don't need to add them one by one, which is very convenient. Open jmeter, click File -> Template, on the template page, click the drop-down box to select Recording, and click Create.

 The created template includes user-defined variables, where you can assign values ​​to the variables, and the interface parameters containing the variables will be automatically replaced during execution. This is globally valid and applies to all interfaces.

 In the http request default value, enter the ip and port number of the http request, which is also globally valid and is for all interfaces.

  The recording controller, which contains all the requests after each recording.

 http proxy server , you can use this recording script, select "use recording controller" in "target controller", select "put each group into a new thing controller" in "grouping", select this grouping After each recording, it will be placed in the controller separately, and select "Prefix" in "naming scheme".

  2. Now it is time to set the certificate and proxy server of the browser. Here we take firefox as an example. Open the firefox browser, click Tools->Settings, and enter "certificate" in the search box on the page.

 

Click View Certificate to pop up the Certificate Manager page, click "Certificate Authority", and click Import.

 Select the jmeter installation directory apache-jmeter-5.5/bin, find the ApacheJMeterTemporaryRootCA.crt certificate, click OK, and the certificate is imported successfully.

 ps: If there is no such certificate in the apache-jmeter-5.5/bin directory, first click Start in the http proxy server in jmeter, and the certificate will be automatically generated in this directory, and you can see it by refreshing the directory.

 Then enter proxy in the search box on the firefox browser page.

 

Click Set Proxy Server, set to manually configure the proxy, enter "localhost" for ip, and "8888" for the port number, and the port number must be consistent with the port number of jmeter's http proxy service.

 

ps: Generally, the proxy set by firefox is only valid for this browser, and the proxy server of the system is not modified. After setting the proxy, use firefox to open the address that needs performance testing, and you will find that the server refuses to connect. This is normal, and then start jmeter When using the http proxy server, open this address again to open it normally. After the recording script is completed, don’t forget to turn off the proxy server, otherwise you will not be able to access the website normally with the firefox browser.

3. Finally, you can start the http proxy server in jmeter, click "Start".

  This prompt box will pop up, click OK, and then another box will pop up, don't worry about it.

 Then you can open the firefox browser, open the address that needs performance testing, perform operations, and click this "stop" after the operation.

After the recording is over, a red box in the picture below will be generated under the recording controller. Clicking on it is the request generated by this recording. 

 

ps: If you want to exclude .js ending types and other types of requests, you can click "requests filtering" in the http proxy server, and add the following lines in the exclusion mode:

.*\js

(?i).*.(bmp|css|js|gif|ico|jpe?g|png|swf|eot|otf|ttf|mp4|woff|woff2|do|query) 

(?i).*.(bmp|css|js|gif|ico|jpe?g|png|swf|eot|otf|ttf|mp4|woff|woff2|do|query)[?;].*

Guess you like

Origin blog.csdn.net/lzz718719/article/details/131738724