Example: web_get_int_property
The following example uses the web_get_int_property function to check if the script successfully accessed the my_home home page.
{ int HttpRetCode; web_url("my_home", "URL=http://my_home", "TargetFrame=_TOP", LAST );
HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE); if (HttpRetCode == 200) lr_log_message("The script successfully accessed the My_home home page"); else lr_log_message("The script failed to access the My_home home page "); }
The script successfully accessed the My_home home page
The following example uses the web_get_int_property function to return the size (in bytes) of a URL and a PDF download.
Action() { int i; int j; lr_start_transaction("DownloadUrL"); web_url("club_registration.html", "URL=https://secure.funclubreg.com/funclub.com/registration_form.html", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", EXTRARES, "Url=images/inside/all_about_club.gif", ENDITEM, "Url=images/inside/whats_new.gif", ENDITEM, "Url=images/inside/club_news.gif", ENDITEM, "Url=images/inside/club_events_roll.gif", ENDITEM, "Url=findclubs.swf", ENDITEM, LAST );
/* Code the web_get_int_property function after the request (such as web_url or web_link) which starts the download. */
i = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
lr_output_message("The download size of the URL was: %d",i);
if(i > 10000)
{
lr_end_transaction("DownloadUrL", LR_PASS);
}
else
{
lr_end_transaction("DownloadUrL", LR_FAIL);
}
lr_start_transaction("DownloadPDF");
web_link("PDF version",
"Text=PDF version",
"Snapshot=t2.inf",
LAST );
j = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
lr_output_message("The download size of the PDF file was: %d",j);
if(j > 10000) { lr_end_transaction("DownloadPDF", LR_PASS); } else { lr_end_transaction("DownloadPDF", LR_FAIL); } return 0; }
Example: Sample Output:
Action.c(41): The download size of the URL was: 148480
Action.c(45): Notify: Transaction "DownloadUrL" ended with "Pass" status (Duration: 13.2097).
...
...
...
Action.c(64): The download size of the PDF file was: 257381
Action.c(68): Notify: Transaction "DownloadPDF" ended with "Pass" status (Duration: 17.9892).
The following example uses the web_get_int_property function to calculate the traffic in an action, and for a single step.
Action() { int initial_byte_request_ct, before_submit_request_ct, after_submit_request_ct, submit_byte_request_ct, final_request_ct; int initial_byte_response_ct, before_submit_response_ct, after_submit_response_ct, submit_byte_response_ct, final_response_ct; initial_byte_request_ct = web_get_int_property(HTTP_INFO_TOTAL_REQUEST_STAT); initial_byte_response_ct = web_get_int_property(HTTP_INFO_TOTAL_RESPONSE_STAT); web_submit_data("com.webtours.servlet.ReservationServlet", "Action=http://newtours.abc.com/servlets/com.webtours.servlet.ReservationServlet?procSub=1&pg=1", "Method=POST", "RecContentType=text/html", "Referer=http://newtours.abc.com/servlets/com.webtours.servlet.ReservationServlet", "Snapshot=t7.inf", "Mode=HTML", ITEMDATA, "Name=tripType", "Value=roundtrip", ENDITEM, "Name=passCount", "Value=2", ENDITEM, "Name=fromPort", "Value=San Francisco", ENDITEM, "Name=fromMonth", "Value=12", ENDITEM, "Name=fromDay", "Value=10", ENDITEM, "Name=toPort", "Value=Acapulco", ENDITEM, "Name=toMonth", "Value=12", ENDITEM, "Name=toDay", "Value=14", ENDITEM, "Name=servClass", "Value=Business", ENDITEM, "Name=airline", "Value=Pangea Airlines", ENDITEM, "Name=findFlights.x", "Value=63", ENDITEM, "Name=findFlights.y", "Value=10", ENDITEM, LAST ); before_submit_request_ct = web_get_int_property(HTTP_INFO_TOTAL_REQUEST_STAT); before_submit_response_ct = web_get_int_property(HTTP_INFO_TOTAL_RESPONSE_STAT); lr_message("Before Submit:Request = %d, Response = %d", before_submit_request_ct,before_submit_response_ct);
/* Before Submit:Request = 1182, Response = 14177 */
web_submit_data("com.webtours.servlet.PurchaseServlet", "Action=http://newtours.abc.com/servlets/com.webtours.servlet.PurchaseServlet", "Method=POST", "RecContentType=text/html", "Referer=http://newtours.abc.com/servlets/com.webtours.servlet.ReservationServlet?procSub=1&pg=1", "Snapshot=t9.inf", "Mode=HTML", ITEMDATA, "Name=outFlight", "Value=Pangea Airlines$612$356$9:23$", ENDITEM, "Name=inFlight", "Value=Pangea Airlines$162$364$16:43$", ENDITEM, "Name=reserveFlights.x", "Value=61", ENDITEM, "Name=reserveFlights.y", "Value=9", ENDITEM, LAST );
after_submit_request_ct = web_get_int_property(HTTP_INFO_TOTAL_REQUEST_STAT); submit_byte_request_ct = after_submit_request_ct - before_submit_request_ct ; after_submit_response_ct = web_get_int_property(HTTP_INFO_TOTAL_RESPONSE_STAT); submit_byte_response_ct = after_submit_response_ct - before_submit_response_ct ; lr_message("After Submit:Request = %d, Response = %d", after_submit_request_ct,after_submit_response_ct); /* After Submit:Request = 2695, Response = 58681*/ lr_message("Submit Net traffic:Request = %d, Response = %d", submit_byte_request_ct,submit_byte_response_ct);
/*Submit Net traffic:Request = 1513, Response = 44504 */
web_url("search_5", "URL=http://toolbarqueries.google.com/search?client=navclient-auto&googleip=O;66.102.11.99;240&ie=UTF-8&oe=UTF-8&features=Rank:&q=info:http%3A%2F%2Fnewtours%2Eabc%2Ecom%2Fservlets%2Fcom%2Ewebtours%2Eservlet%2EPurchaseServlet&ch=762475275111", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t10.inf", "Mode=HTML", LAST ); web_submit_data("com.webtours.servlet.PurchaseServlet_2", "Action=http://newtours.abc.com/servlets/com.webtours.servlet.PurchaseServlet?procSub=1&pg=1", "Method=POST", "RecContentType=text/html", "Referer=http://newtours.abc.com/servlets/com.webtours.servlet.PurchaseServlet", "Snapshot=t22.inf", "Mode=HTML", ITEMDATA, "Name=passFirst0", "Value=Fitzwilliam", ENDITEM, "Name=passLast0", "Value=Darcy", ENDITEM, "Name=pass.1.meal", "Value=VGML", ENDITEM, "Name=passFirst1", "Value=Elizabeth", ENDITEM, "Name=passLast1", "Value=Darcy", ENDITEM, "Name=pass.1.meal", "Value=LCML", ENDITEM, "Name=creditCard", "Value=CB", ENDITEM, "Name=creditnumber", "Value=123456789", ENDITEM, "Name=cc_exp_dt_mn", "Value=01", ENDITEM, "Name=cc_exp_dt_yr", "Value=2008", ENDITEM, "Name=cc_frst_name", "Value=Catherine", ENDITEM, "Name=cc_mid_name", "Value=", ENDITEM, "Name=cc_last_name", "Value=DeBourgh", ENDITEM, "Name=ticketLess", "Value=checkbox", ENDITEM, "Name=billAddress1", "Value=Rosings Park", ENDITEM, "Name=billAddress2", "Value=", ENDITEM, "Name=billCity", "Value=Lambton", ENDITEM, "Name=billState", "Value=Derbyshire", ENDITEM, "Name=billZip", "Value=94089", ENDITEM, "Name=billCountry", "Value=214", ENDITEM, "Name=ticketLess", "Value=checkbox", ENDITEM, "Name=delAddress1", "Value=1325 Borregas Ave.", ENDITEM, "Name=delAddress2", "Value=", ENDITEM, "Name=delCity", "Value=Sunnyvale", ENDITEM, "Name=delState", "Value=CA", ENDITEM, "Name=delZip", "Value=94089", ENDITEM, "Name=delCountry", "Value=215", ENDITEM, "Name=buyFlights.x", "Value=51", ENDITEM, "Name=buyFlights.y", "Value=15", ENDITEM, LAST );
web_url("com.webtours.servlet.SignonServlet_2", "URL=http://newtours.abc.com/servlets/com.webtours.servlet.SignonServlet", "Resource=0", "RecContentType=text/html", "Referer=http://newtours.abc.com/servlets/com.webtours.servlet.PurchaseServlet?procSub=1&pg=1", "Snapshot=t24.inf", "Mode=HTML", LAST );
web_url("search_6", "URL=http://toolbarqueries.google.com/search?client=navclient-auto&googleip=O;216.239.59.99;701&ie=UTF-8&oe=UTF-8&features=Rank:&q=info:http%3A%2F%2Fnewtours%2Eabc%2Ecom%2Fservlets%2Fcom%2Ewebtours%2Eservlet%2ESignonServlet&ch=722304523644", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t25.inf", "Mode=HTML", LAST );
final_request_ct = web_get_int_property(HTTP_INFO_TOTAL_REQUEST_STAT); lr_message("REQUEST: Initial = %d, before submit = %d, after_submit = %d, submit size = %d, total = %d", initial_byte_request_ct, before_submit_request_ct, after_submit_request_ct, submit_byte_request_ct, final_request_ct); /*REQUEST: Initial = 0, before submit = 1182, after_submit = 2695, submit size = 1513, total = 7911 */
final_response_ct = web_get_int_property(HTTP_INFO_TOTAL_RESPONSE_STAT); lr_message("RESPONSE: Initial = %d, before submit = %d, after_submit = %d, submit size = %d, total = %d", initial_byte_response_ct, before_submit_response_ct, after_submit_response_ct, submit_byte_response_ct, final_response_ct);
/* RESPONSE: Initial = 0, before submit = 14177, after_submit = 58681, submit size = 44504, total = 86444 */
return 0;
}
Sample Output:Before Submit:Request = 1846, Response = 5488
...
...
...
After Submit:Request = 3559, Response = 9273
Submit Net traffic:Request = 1713, Response = 3785
...
...
...
REQUEST: Initial = 0, before submit = 1846, after_submit = 3559, submit size = 1713, total = 8503
RESPONSE: Initial = 0, before submit = 5488, after_submit = 9273, submit size = 3785, total = 68086