参数化对话框中与参数取值方式有关的区域如下:
改变参数化的取值方式,关键在于Select next row和Update value on这两个选项。
Select next row包括以下选项:
- Sequential:顺序方式
- Random:随机方式
- Unique:唯一方式
Update value on包括如下选项:
- Each iteration:每次迭代更新取值
- Each occurrence:每次取值更新
- Once:只更新一次
以下代码以登录接口和参数化进行演示,参数化文件中有2个值
lr_output_message("login_username:%s",lr_eval_string("{login_username}"));
web_custom_request("login",
"URL=http://192.168.44.130:8080/mobile/api/user/login",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"Mode=HTTP",
"EncType=application/json;charset=utf-8",
"Body={\"mobile\":\"{login_username}\",\"password\":\"123456\"}",
LAST);
参数化文件中的数据为:
13141140050 13141140058
第一种取值方式:Sequential+Each iteration,设置迭代次数为3次,参数取值结果为:
Starting iteration 1.
Maximum number of concurrent connections per server: 6 [MsgId: MMSG-26989]
Starting action Action.
Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"
Action.c(18): login_username:13141140050
Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]
Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"
Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]
Ending action Action.
Ending iteration 1.
Starting iteration 2.
Notify: Next row for parameter login_username = 2 [table = login_username].
Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'.
Starting action Action.
Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140058"
Action.c(18): login_username:13141140058
Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]
Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058"
Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]
Ending action Action.
Ending iteration 2.
Starting iteration 3.
Notify: Next row for parameter login_username = 1 [table = login_username].
Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'.
Starting action Action.
Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050"
Action.c(18): login_username:13141140050
Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355]
Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140050"
Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]
Ending action Action.
Ending iteration 3.
第二种取值方式:Sequential+Each occurrence,设置迭代次数为3次,参数取值结果为:
Starting iteration 1. Maximum number of concurrent connections per server: 6 [MsgId: MMSG-26989] Starting action Action. Action.c(18): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'. Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050" Action.c(18): login_username:13141140050 Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355] Action.c(20): Notify: Next row for parameter login_username = 2 [table = login_username]. Action.c(20): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'. Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058" Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385] Ending action Action. Ending iteration 1. Starting iteration 2. Starting action Action. Action.c(18): Notify: Next row for parameter login_username = 1 [table = login_username]. Action.c(18): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '1'. Action.c(18): Notify: Parameter Substitution: parameter "login_username" = "13141140050" Action.c(18): login_username:13141140050 Action.c(20): web_custom_request("login") started [MsgId: MMSG-26355] Action.c(20): Notify: Next row for parameter login_username = 2 [table = login_username]. Action.c(20): Notify: Getting new value for parameter 'login_username': table = 'login_username.dat' column = '0' row = '2'. Action.c(20): Notify: Parameter Substitution: parameter "login_username" = "13141140058" Action.c(20): web_custom_request("login") was successful, 361 body bytes, 157 header bytes, 12 chunking ov