录制脚本,对用户名和密码进行参数化:
Action() { web_url("WebTours", "URL=http://127.0.0.1:1080/WebTours/", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", LAST); web_submit_form("login.pl", "Snapshot=t2.inf", ITEMDATA, "Name=username", "Value=jojo", ENDITEM, "Name=password", "Value=bean", ENDITEM, "Name=login.x", "Value=60", ENDITEM, "Name=login.y", "Value=4", ENDITEM, LAST); return 0; }
1、右击脚本中的用户,选择"Replace with a Parameter"

2、Parameter name输入参数名"username",Parameter type选择"File",点击"Properties"按钮,弹出参数属性对话框

3、点击"Create Table",新建参数化列表,修改第一个参数值为"jojo"

4、点击"Add Row"按钮,添加新行,输入参数化的数据

5、点击"Add Column"按钮,添加新列,列名为"password"

6、password列输入要参数化的数据(jojo/bean为系统默认用户),第一列username用于参数化用户名,第二列password用于参数化密码

7、Select column(选择哪一列数据用于参数化)标签页如果当前选项是By number(根据列序号),则选择"1",如果是By name(根据列名称),则选择"username"


8、右击脚本中的密码,选择"Replace with a Parameter"

9、Parameter name输入参数名"password",Parameter type选择"File",点击"Properties"按钮,弹出参数属性对话框

10、File选择刚才新建的dat文件

11、Select column标签页如果当前选项是By number,则选择"2",如果是By name,则选择"password"
12、选择"Vuser—>Run-Time Settings"

13、在Run Logic中设置Action的循环次数为5次

14、为了看到效果,在代码后加上 lr_output_message("username:%s,password:%s",lr_eval_string("{username}"),lr_eval_string("{password}")); 以输出参数化值

15、运行脚本,通过日志观察参数化后的效果




