loadRunner函数之web_find
WebTours登录后页面展示的内容:
Action() { web_url("WebTours", "URL=http://127.0.0.1:1080/WebTours/", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t34.inf", "Mode=HTML", EXTRARES, "Url=../favicon.ico", "Referer=", ENDITEM, LAST); web_submit_form("login.pl", "Snapshot=t35.inf", ITEMDATA, "Name=username", "Value=jojo", ENDITEM, "Name=password", "Value=bean", ENDITEM, "Name=login.x", "Value=52", ENDITEM, "Name=login.y", "Value=11", ENDITEM, LAST); web_find("web_find", //期望返回成功的结果是找到字符串,因当前页面包含要查找的字符串,故返回结果是成功 "expect=found", //当前页面中查找字符串"jojo" "What=jojo", LAST); web_find("web_find", //期望返回成功的结果是未找到字符串,因当前页面包含要查找的字符串,故返回结果是失败 "expect=notfound", //当前页面中查找字符串"jojo" "What=jojo", LAST); return 0; }
代码执行结果:
Action.c(24): "web_find" successful. 1 occurrence(s) of "jojo" found (RightOf="", LeftOf="") [MsgId: MMSG-27196]
Action.c(24): web_find was successful [MsgId: MMSG-26392]
Action.c(31): Error -27195: "web_find" failed. 1 occurrence(s) of "jojo" found (RightOf="", LeftOf="") [MsgId: MERR-27195]
Action.c(31): web_find highest severity level was "ERROR" [MsgId: MMSG-26391]
Action() { web_url("WebTours", "URL=http://127.0.0.1:1080/WebTours/", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t34.inf", "Mode=HTML", EXTRARES, "Url=../favicon.ico", "Referer=", ENDITEM, LAST); web_submit_form("login.pl", "Snapshot=t35.inf", ITEMDATA, "Name=username", "Value=jojo", ENDITEM, "Name=password", "Value=bean", ENDITEM, "Name=login.x", "Value=52", ENDITEM, "Name=login.y", "Value=11", ENDITEM, LAST); web_find("web_find", //区分大小写,因当前页面不包含JOJO,故返回结果是失败 "Matchcase=yes", //当前页面中查找字符串"JOJO" "What=JOJO", LAST); web_find("web_find", //不区分大小写,因当前页面包含jojo,故返回结果是成功 "Matchcase=no", //当前页面中查找字符串"JOJO" "What=JOJO", LAST); return 0; }
Action() { web_url("WebTours", "URL=http://127.0.0.1:1080/WebTours/", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t34.inf", "Mode=HTML", EXTRARES, "Url=../favicon.ico", "Referer=", ENDITEM, LAST); web_submit_form("login.pl", "Snapshot=t35.inf", ITEMDATA, "Name=username", "Value=jojo", ENDITEM, "Name=password", "Value=bean", ENDITEM, "Name=login.x", "Value=52", ENDITEM, "Name=login.y", "Value=11", ENDITEM, LAST); web_find("web_find", //如果函数返回结果失败,则终止脚本运行,根据运行结果可以发现,第二个web_find没有运行 //注意:Continue on Error 设置了才能看到效果,否则的话,不管是否有该属性都会终止运行 "onfailure=abort", //当前页面中查找字符串"JOJO" "What=jojo1", LAST); web_find("web_find", //当前页面中查找字符串"JOJO" "What=jojo", LAST); return 0; }
Action() { web_url("WebTours", "URL=http://127.0.0.1:1080/WebTours/", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t34.inf", "Mode=HTML", EXTRARES, "Url=../favicon.ico", "Referer=", ENDITEM, LAST); web_submit_form("login.pl", "Snapshot=t35.inf", ITEMDATA, "Name=username", "Value=jojo", ENDITEM, "Name=password", "Value=bean", ENDITEM, "Name=login.x", "Value=52", ENDITEM, "Name=login.y", "Value=11", ENDITEM, LAST); web_find("web_find", //从, to the Web左边查找jojo "LeftOf=, to the Web", //从Welcome右边查找jojo "RightOf=Welcome, ", "What=jojo", LAST); return 0; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。