Action() { web_url("mercuryWebTours", "URL=http://127.0.0.1:1080/mercuryWebTours/", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", LAST); lr_think_time(4);
web_reg_find( "Text=welcome", "SaveCount=ddd", LAST);
web_submit_form("login.pl", "Snapshot=t2.inf", ITEMDATA, "Name=username", "Value={NewParam}", ENDITEM, "Name=password", "Value={NewParam_1}", ENDITEM, "Name=login.x", "Value=42", ENDITEM, "Name=login.y", "Value=9", ENDITEM, LAST); lr_think_time(14);
web_image("SignOff Button", "Alt=SignOff Button", "Snapshot=t3.inf", LAST);
if (atoi(lr_eval_string("{ddd}")) > 0){ lr_output_message("222222222222222222222222."); } // atoi():转换一个ASCII字符串为一个整型。lr_eval_string ():是取得参数值,lrs_send("socket0", lr_eval_string("buf2"), LrsLastArg);lr_eval_string很有用,它将字符串变量buf2中的参数替换为当前的参数值并将这个字符串返回。lr_output_message (const char *format, exp1, exp2,……expn.);中文解释:lr_output_message函数将带有脚本部分的行号的消息发送到输出窗口和日志文件。
else { lr_error_message("55555555555555555555555"); // lr_error_message (const char *format, exp1, exp2,……expn. );中文解释:lr_error_message函数将错误消息发送到输出窗口和Vuser日志文件。要发送不是特定错误消息的特殊通知,请使用lr_output_message } return 0; }
执行这个脚本,得到的结果是: Virtual User Script started Starting action vuser_init. Web Turbo Replay of LoadRunner 8.1.0 for WINXP; Web build 4788 [MsgId: MMSG-27143] Run-Time Settings file: "D:\lr\b\\default.cfg" [MsgId: MMSG-27141] Ending action vuser_init. Running Vuser... Starting iteration 1. Starting action Action. Action.c(5): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/header.html" in "http://127.0.0.1:1080/mercuryWebTours/" [MsgId: MMSG-26574] Action.c(5): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=true" in "http://127.0.0.1:1080/mercuryWebTours/" [MsgId: MMSG-26574] Action.c(5): Found resource "http://127.0.0.1:1080/mercuryWebTours/images/mercury_logo.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/header.html" [MsgId: MMSG-26659] Action.c(5): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/nav.pl?in=home" in "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=true" [MsgId: MMSG-26574] Action.c(5): Detected non-resource "http://127.0.0.1:1080/MercuryWebTours/home.html" in "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=true" [MsgId: MMSG-26574] Action.c(5): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/fma-gateway.jpg" in HTML "http://127.0.0.1:1080/MercuryWebTours/home.html" [MsgId: MMSG-26659] Action.c(5): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/mer_login.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/nav.pl?in=home" [MsgId: MMSG-26659] Action.c(5): web_url("mercuryWebTours") was successful, 52180 body bytes, 1566 header bytes [MsgId: MMSG-26386] Action.c(15): Registering web_reg_find was successful [MsgId: MMSG-26390] Action.c(18): Submitting form to "http://127.0.0.1:1080/mercuryWebTours/login.pl", Target Frame="body" [MsgId: MMSG-27978] Action.c(18): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/nav.pl?page=menu&in=home" in "http://127.0.0.1:1080/mercuryWebTours/login.pl" [MsgId: MMSG-26574] Action.c(18): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/login.pl?intro=true" in "http://127.0.0.1:1080/mercuryWebTours/login.pl" [MsgId: MMSG-26574] Action.c(18): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/flights.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/nav.pl?page=menu&in=home" [MsgId: MMSG-26659] Action.c(18): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/itinerary.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/nav.pl?page=menu&in=home" [MsgId: MMSG-26659] Action.c(18): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/in_home.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/nav.pl?page=menu&in=home" [MsgId: MMSG-26659] Action.c(18): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/signoff.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/nav.pl?page=menu&in=home" [MsgId: MMSG-26659] Action.c(18): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/fma-performance-center.jpg" in HTML "http://127.0.0.1:1080/mercuryWebTours/login.pl?intro=true" [MsgId: MMSG-26659] Action.c(18): Registered web_reg_find successful for "Text=welcome" (count=4) [MsgId: MMSG-26364] Action.c(18): web_submit_form("login.pl") was successful, 32666 body bytes, 1649 header bytes [MsgId: MMSG-26386] Action.c(29): Image-linking to "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=1", Target Frame="body" [MsgId: MMSG-27993] Action.c(29): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/nav.pl?in=home" in "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=1" [MsgId: MMSG-26574] Action.c(29): Detected non-resource "http://127.0.0.1:1080/MercuryWebTours/home.html" in "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=1" [MsgId: MMSG-26574] Action.c(29): Retrieving data from cache for "http://127.0.0.1:1080/MercuryWebTours/home.html" [MsgId: MMSG-26558] Action.c(29): Resource "http://127.0.0.1:1080/MercuryWebTours/images/fma-gateway.jpg" is in the cache already and will not be downloaded again [MsgId: MMSG-26655] Action.c(29): Resource "http://127.0.0.1:1080/MercuryWebTours/images/mer_login.gif" is in the cache already and will not be downloaded again [MsgId: MMSG-26655] Action.c(29): web_image("SignOff Button") was successful, 1985 body bytes, 577 header bytes [MsgId: MMSG-26386] Action.c(35): 222222222222222222222222. Ending action Action. Ending iteration 1. Starting iteration 2. Starting action Action. Action.c(5): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/header.html" in "http://127.0.0.1:1080/mercuryWebTours/" [MsgId: MMSG-26574] Action.c(5): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=true" in "http://127.0.0.1:1080/mercuryWebTours/" [MsgId: MMSG-26574] Action.c(5): Found resource "http://127.0.0.1:1080/mercuryWebTours/images/mercury_logo.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/header.html" [MsgId: MMSG-26659] Action.c(5): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/nav.pl?in=home" in "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=true" [MsgId: MMSG-26574] Action.c(5): Detected non-resource "http://127.0.0.1:1080/MercuryWebTours/home.html" in "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=true" [MsgId: MMSG-26574] Action.c(5): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/fma-gateway.jpg" in HTML "http://127.0.0.1:1080/MercuryWebTours/home.html" [MsgId: MMSG-26659] Action.c(5): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/mer_login.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/nav.pl?in=home" [MsgId: MMSG-26659] Action.c(5): web_url("mercuryWebTours") was successful, 52176 body bytes, 1566 header bytes [MsgId: MMSG-26386] Action.c(15): Registering web_reg_find was successful [MsgId: MMSG-26390] Action.c(18): Submitting form to "http://127.0.0.1:1080/mercuryWebTours/login.pl", Target Frame="body" [MsgId: MMSG-27978] Action.c(18): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/nav.pl?page=menu&in=home" in "http://127.0.0.1:1080/mercuryWebTours/login.pl" [MsgId: MMSG-26574] Action.c(18): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/login.pl?intro=true" in "http://127.0.0.1:1080/mercuryWebTours/login.pl" [MsgId: MMSG-26574] Action.c(18): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/flights.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/nav.pl?page=menu&in=home" [MsgId: MMSG-26659] Action.c(18): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/itinerary.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/nav.pl?page=menu&in=home" [MsgId: MMSG-26659] Action.c(18): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/in_home.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/nav.pl?page=menu&in=home" [MsgId: MMSG-26659] Action.c(18): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/signoff.gif" in HTML "http://127.0.0.1:1080/mercuryWebTours/nav.pl?page=menu&in=home" [MsgId: MMSG-26659] Action.c(18): Found resource "http://127.0.0.1:1080/MercuryWebTours/images/fma-performance-center.jpg" in HTML "http://127.0.0.1:1080/mercuryWebTours/login.pl?intro=true" [MsgId: MMSG-26659] Action.c(18): Registered web_reg_find successful for "Text=welcome" (count=4) [MsgId: MMSG-26364] Action.c(18): web_submit_form("login.pl") was successful, 32666 body bytes, 1649 header bytes [MsgId: MMSG-26386] Action.c(29): Image-linking to "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=1", Target Frame="body" [MsgId: MMSG-27993] Action.c(29): Detected non-resource "http://127.0.0.1:1080/mercuryWebTours/nav.pl?in=home" in "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=1" [MsgId: MMSG-26574] Action.c(29): Detected non-resource "http://127.0.0.1:1080/MercuryWebTours/home.html" in "http://127.0.0.1:1080/mercuryWebTours/welcome.pl?signOff=1" [MsgId: MMSG-26574] Action.c(29): Retrieving data from cache for "http://127.0.0.1:1080/MercuryWebTours/home.html" [MsgId: MMSG-26558] Action.c(29): Resource "http://127.0.0.1:1080/MercuryWebTours/images/fma-gateway.jpg" is in the cache already and will not be downloaded again [MsgId: MMSG-26655] Action.c(29): Resource "http://127.0.0.1:1080/MercuryWebTours/images/mer_login.gif" is in the cache already and will not be downloaded again [MsgId: MMSG-26655] Action.c(29): web_image("SignOff Button") was successful, 1991 body bytes, 577 header bytes [MsgId: MMSG-26386] Action.c(35): 222222222222222222222222. Ending action Action. Ending iteration 2. Ending Vuser... Starting action vuser_end. Ending action vuser_end. Vuser Terminated.
|