Loadrunner之精简代码
录制的脚本中web_url()、web_submit_data()两个函数会有很多行,有时候多的让人发指。这是可以精简的。
一.web_url()函数的精简:
1.原代码
web_url("192.168.1.33:80",
"URL=http://192.168.1.33:80/",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=/fonts/glyphicons-halflings-regular.woff", "Referer=http://192.168.1.33:80/css/bootstrap-cerulean.min.css", ENDITEM,
LAST);
2.精简后的代码
只有三行,看着是不是很爽:
web_url("192.168.1.33:80",
"URL=http://192.168.1.33:80/",
LAST);
二.web_submit_data()函数的精简:
1.原代码
web_submit_data("login.html",
"Action=http://192.168.1.33:3000/login.html",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://192.168.1.33:3000/",
"Snapshot=t2.inf",
"Mode=HTML",
ITEMDATA,
"Name=username", "Value=autoUser", ENDITEM,
"Name=password", "Value=111111", ENDITEM,
EXTRARES,
"Url=/img/logo20.png", "Referer=http://192.168.1.33:3000/css/bootstrap-cerulean.min.css", ENDITEM,
LAST);
2.精简后的代码
ITEMDATA是需要的参数,根据实际情况而不一样
web_submit_data("login.html",
"Action=http://192.168.1.33:3000/login.html",
ITEMDATA,
"Name=username", "Value=autoUser", ENDITEM,
"Name=password", "Value=111111", ENDITEM,
LAST);
------------------------------------------------------------------------------------------------------------------------------
更多请关注:FlyTester,关注技术的测试者
QQ群:456850134
web站:www.flytester.org
微信扫描二维码关注: