LoadRunner开发http协议接口之form表单脚本
loadrunner传form表单,用web_submit_data函数。
Action() { // lr_start_transaction("hp_homepage"); // web_url("hp_homepage","url=http://127.0.0.1:1080/WebTours/",LAST); // lr_end_transaction("hp_homepage", LR_AUTO); //web_reg_save_param("userSession","LB=name=userSession value=","RB=>","Search=body",LAST); web_reg_save_param_ex("ParamName=userSession","LB=name=userSession value=","RB=>",SEARCH_FILTERS,"Scope=body",LAST); lr_start_transaction("hp_webtours"); web_url("hp_webtours","url=http://127.0.0.1:1080/WebTours/nav.pl?in=home",LAST); lr_end_transaction("hp_webtours", LR_AUTO); lr_error_message("userSession=%s",lr_eval_string("{userSession}")); web_reg_save_param("result","LB=<frame src=","RB=?intro=true","Search=body",LAST); //web_reg_save_param("result","LB=login.pl?intro=","RB= ","Search=body",LAST); //判断事物的时候和true比较,if(strcmp(lr_eval_string("{result}"),"true")==0) lr_start_transaction("login"); web_submit_data("login", "Action=http://127.0.0.1:1080/WebTours/login.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=", "Snapshot=t7.inf", "Mode=HTML", ITEMDATA, "Name=userSession","Value={userSession}",ENDITEM, "Name=username","Value=jojo",ENDITEM, "Name=password","Value=bean",ENDITEM, "Name=login.x","Value=41",ENDITEM, "Name=login.y","Value=8",ENDITEM, "Name=login","Value=Login",ENDITEM, "Name=JSFormSubmit","Value=off",ENDITEM, LAST ); //系统自动判断写为:lr_end_transaction("login", LR_AUTO); if(strcmp(lr_eval_string("{result}"),"login.pl")==0)//一般情况下,get请求不需要检查是否成功。 { lr_end_transaction("login", LR_PASS); lr_error_message("log succes"); } else{ lr_error_message("log fail"); lr_end_transaction("login", LR_FAIL); lr_error_message("log fail"); } return 0; }
__EOF__
本文作者:持之以恒(韧)
关于博主:擅长性能、全链路、自动化、企业级自动化持续集成(DevTestOps)、测开等
面试必备:项目实战(性能、自动化)、简历笔试,https://www.cnblogs.com/uncleyong/p/15777706.html
测试提升:从测试小白到高级测试修炼之路,https://www.cnblogs.com/uncleyong/p/10530261.html
欢迎分享:如果您觉得文章对您有帮助,欢迎转载、分享,也可以点击文章右下角【推荐】一下!
关于博主:擅长性能、全链路、自动化、企业级自动化持续集成(DevTestOps)、测开等
面试必备:项目实战(性能、自动化)、简历笔试,https://www.cnblogs.com/uncleyong/p/15777706.html
测试提升:从测试小白到高级测试修炼之路,https://www.cnblogs.com/uncleyong/p/10530261.html
欢迎分享:如果您觉得文章对您有帮助,欢迎转载、分享,也可以点击文章右下角【推荐】一下!