WebTours测试脚本分享(半成品练习)
2017-08-11 15:29
387 查看
>>>>>
- 启动Web Tours服务。 。双击启动。
- 输入网址:http://127.0.0.1:1080/WebTours/
脚本源码:
vuser_init脚本:
vuser_init() { web_reg_save_param("session", "LB=name=\"userSession\" value=\"", "RB=\"/>", LAST); web_url("WebTours", "URL=http://localhost:1080/WebTours/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t77.inf", "Mode=HTML", LAST); lr_think_time(18); lr_start_transaction("1_denglu"); web_submit_data("login.pl", "Action=http://localhost:1080/cgi-bin/login.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://localhost:1080/cgi-bin/nav.pl?in=home", "Snapshot=t78.inf", "Mode=HTML", ITEMDATA, "Name=userSession", "Value={session}", ENDITEM, "Name=username", "Value=xhx", ENDITEM, "Name=password", "Value=123", ENDITEM, "Name=JSFormSubmit", "Value=on", ENDITEM, "Name=login.x", "Value=72", ENDITEM, "Name=login.y", "Value=15", ENDITEM, LAST); lr_end_transaction("1_denglu",LR_AUTO); lr_output_message("这里是init"); return 0; }
action脚本:
Action() { lr_think_time(14); lr_start_transaction("2_maipiao"); web_url("Search Flights Button", "URL=http://localhost:1080/cgi-bin/welcome.pl?page=search", "TargetFrame=body", "Resource=0", "RecContentType=text/html", "Referer=http://localhost:1080/cgi-bin/nav.pl?page=menu&in=home", "Snapshot=t79.inf", "Mode=HTML", LAST); lr_think_time(7); //name="outboundFlight" value="010;723;07/16/2017" web_reg_save_param("outboundFlight", "LB=name=\"outboundFlight\" value=\"", "RB=\">", "Ord=3", LAST); web_submit_data("reservations.pl", "Action=http://localhost:1080/cgi-bin/reservations.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://localhost:1080/cgi-bin/reservations.pl?page=welcome", "Snapshot=t80.inf", "Mode=HTML", ITEMDATA, "Name=advanceDiscount", "Value=0", ENDITEM, "Name=depart", "Value={departCity}", ENDITEM, "Name=departDate", "Value=07/16/2017", ENDITEM, "Name=arrive", "Value={arriveCity}", ENDITEM, "Name=returnDate", "Value=07/17/2017", ENDITEM, "Name=numPassengers", "Value=1", ENDITEM, "Name=seatPref", "Value=Window", ENDITEM, "Name=seatType", "Value=First", ENDITEM, "Name=.cgifields", "Value=roundtrip", ENDITEM, "Name=.cgifields", "Value=seatType", ENDITEM, "Name=.cgifields", "Value=seatPref", ENDITEM, "Name=findFlights.x", "Value=68", ENDITEM, "Name=findFlights.y", "Value=3", ENDITEM, LAST); web_submit_data("reservations.pl_2", "Action=http://localhost:1080/cgi-bin/reservations.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://localhost:1080/cgi-bin/reservations.pl", "Snapshot=t81.inf", "Mode=HTML", ITEMDATA, "Name=outboundFlight", "Value={outboundFlight}", ENDITEM, "Name=numPassengers", "Value=1", ENDITEM, "Name=advanceDiscount", "Value=0", ENDITEM, "Name=seatType", "Value=First", ENDITEM, "Name=seatPref", "Value=Window", ENDITEM, "Name=reserveFlights.x", "Value=18", ENDITEM, "Name=reserveFlights.y", "Value=12", ENDITEM, LAST); //<small><B>Thank you for booking through Web Tours.</B></small> web_reg_save_param("msg", "LB=<small><B>", "RB=</B></small>", LAST); web_submit_data("reservations.pl_3", "Action=http://localhost:1080/cgi-bin/reservations.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://localhost:1080/cgi-bin/reservations.pl", "Snapshot=t82.inf", "Mode=HTML", ITEMDATA, "Name=firstName", "Value=xxxxxxxxxxx", ENDITEM, "Name=lastName", "Value=xx", ENDITEM, "Name=address1", "Value=", ENDITEM, "Name=address2", "Value=", ENDITEM, "Name=pass1", "Value= ", ENDITEM, "Name=creditCard", "Value=", ENDITEM, "Name=expDate", "Value=", ENDITEM, "Name=oldCCOption", "Value=", ENDITEM, "Name=numPassengers", "Value=1", ENDITEM, "Name=seatType", "Value=First", ENDITEM, "Name=seatPref", "Value=Window", ENDITEM, "Name=outboundFlight", "Value={outboundFlight}", ENDITEM, "Name=advanceDiscount", "Value=0", ENDITEM, "Name=returnFlight", "Value=", ENDITEM, "Name=JSFormSubmit", "Value=off", ENDITEM, "Name=.cgifields", "Value=saveCC", ENDITEM, "Name=buyFlights.x", "Value=59", ENDITEM, "Name=buyFlights.y", "Value=9", ENDITEM, LAST); if(strstr(lr_eval_string("{msg}"),"Thank you for booking through Web Tours")!=NULL) { lr_end_transaction("2_maipiao",LR_PASS); lr_output_message("订票成功,departCity:%s,arriveCity:%s", lr_eval_string("{departCity}"), lr_eval_string("{arriveCity}")); } else { lr_end_transaction("2_maipiao",LR_FAIL); lr_output_message("订票失败!"); } //lr_end_transaction("2_maipiao",LR_AUTO); //AUTO:自动结尾,不判断正确和错误 //PASS:以成功状态结束 //FAIL:以失败状态结束 return 0; }
vuser_end脚本:
vuser_end() { lr_think_time(17); lr_start_transaction("3_tuichu"); web_url("SignOff Button", "URL=http://localhost:1080/cgi-bin/welcome.pl?signOff=1", "TargetFrame=body", "Resource=0", "RecContentType=text/html", "Referer=http://localhost:1080/cgi-bin/nav.pl?page=menu&in=flights", "Snapshot=t83.inf", "Mode=HTML", LAST); lr_end_transaction("3_tuichu",LR_AUTO); lr_output_message("这里是end"); return 0; }
>>>>>
相关文章推荐
- javascript页面渲染速度测试脚本分享
- dota2服务器ping测试脚本分享
- Selenium执行测试脚本稳定性的一些经验分享交流
- 实现android自动化测试部署与运行Shell脚本分享
- Selenium执行测试脚本稳定性的一些经验分享交流
- Android自动化测试 - MonkeyRunner(三) 随手练习测试脚本
- 获取服务器信息的Shell脚本分享(ubuntu、centos测试通过)
- 获取服务器信息的Shell脚本分享(ubuntu、centos测试通过)
- 老李分享:Eclipse中开发性能测试loadrunner脚本
- 实现android自动化测试部署与运行Shell脚本分享
- 利用Python实现网络测试的脚本分享
- 分享一个Android内存泄漏相关的自动测试脚本
- 测试脚本经验分享
- 老李分享:Python开发性能测试脚本
- javascript页面渲染速度测试脚本分享
- Shell脚本基础6-if语句练习-文件测试操作
- PowerShell实现测试端口可用性脚本分享
- 老李分享:Eclipse中开发性能测试loadrunner脚本