Jmeter (thirty) - From entry to proficiency - Jmeter Http protocol recording script tool - Badboy3 (detailed tutorial)

1 Introduction

In order to facilitate the flexibility of automated data, reuse scripts and reduce workload, Badboy provides the function of script parameterization. In this article, Hong Ge uses the keyword "Beijing-Hong Ge" searched by Du Niang to parameterize it as For example, Brother Hong will lead you to practice how to use Badboy’s parameterization function.

2.Script recording

After studying the previous article, you must be familiar with Badboy's script recording. You can record the script yourself. Brother Hong will demonstrate it again here. The specific steps are as follows:

1. Enter: https://www.baidu.com/ into the address input bar of Badboy’s URL (browser bar), as shown below:

 If you want to learn automated testing, I recommend a set of videos to you. This video can be said to be the number one automated testing tutorial on the entire network played by Bilibili. The number of people online at the same time has reached 1,000, and there are also notes that can be collected and communicated with various channels. Master technical communication: 798478386   

[Updated] A complete collection of the most detailed practical tutorials on Python interface automation testing taught by Bilibili (the latest practical version)_bilibili_bilibili [Updated] A complete collection of the most detailed practical tutorials on Python interface automated testing taught by Bilibili (practical version) The latest version) has a total of 200 videos, including: 1. Why interface automation should be done for interface automation, 2. Overall view of request for interface automation, 3. Interface practice for interface automation, etc. For more exciting videos from UP master, please follow the UP account . icon-default.png?t=N7T8https://www.bilibili.com/video/BV17p4y1B77x/?spm_id_from=333.337.search-card.all.click 

2. Click the Start Recording button to start recording, and then click the Forward icon to access DuNiang, as shown in the figure below:

 

3. Enter "Beijing-Hongge" in Du Niang's search input box and click Baidu, as shown in the figure below:

4. After the search results are expanded, the page is as shown below:

 

5. Click Back in the browser bar to return to https://www.baidu.com/, as shown in the figure below:

6. Stop recording, expand the script tree, and click the Variable tab (to display the Tab step: click View—>Summary View)

 

From the picture above, you can observe that Hong Ge’s input “ wd=鍖椾Han-瀹忓掼” has been recorded. Although it is Chinese garbled characters, it has indeed been recorded. The problem we encountered in actual work is: there is no need to record again or redesign new scripts to test and search for other content.

Badboy's script parameterization provides us with a solution. Brother Hong will introduce how to parameterize it below.

 

3.Badboy parameterization

3.1 Add parameters

1. Switch to the Variable button, right-click on the blank space, and the following window will pop up, as shown in the figure below:

2. Click "Add Varialbe" and the following window will pop up. Enter the variable name "Searchcontent", as shown in the figure below:

 3. Since this use case is to test a valid class, we add valid test data, such as Beijing Hongge, Hongge, Beijing-Hongge...etc., as shown in the following figure:

4. Click Ok, the parameter Searchcontent has been saved successfully and is displayed in the Variable list.

3.2 Parameterize the values ​​in the script

1. Right-click wd in the script tree and select Properties, as shown in the following figure:

2. Bind Value to parameter Searchcontent in the format of "${variable name}".

Note: When we want to fix a parameter value, we can also use the index usage of Variable list. If we want the script to check every time: Value=${Searchcontent[2]}, the index of the list starts from 0.

3. Click the "OK" button and observe the changes in the script tree. The value of sw has been parameterized, as shown in the following figure:

3.3 Set the running mode

1. Double-click Step "Variable search", or right-click to select Properties, set the operation to use Searchcontent as the loop mode, and click "OK", as shown in the figure below:

 2. Select Variable Search, click " ", and run the script, as shown in the figure below:

3. Carefully observe the running status of the script, and search according to the three entered parameter values, proving that the parameterization has been successfully implemented.

 

Guess you like

Origin blog.csdn.net/Faith_Lzt/article/details/132606458