loadrunner Web_类函数之web_get_int_property()
来源:互联网 发布:一七网络批发广州 编辑:程序博客网 时间:2024/06/10 23:35
web_get_int_property()--常用函数
该函数用于帮助我们返回有关先前HTTP请求的特定信息。
intweb_get_int_property(const int HttpInfoType);
参数说明:
object:评估到类型为WebApi的对象的表达式。通常是webfor Java和Visual Basic。另请参见函数和常量前缀。
HttpInfoType:下面列出的选项之一。
一般信息 :
web_get_int_property函数返回有关先前HTTP请求的特定信息。
返回值的含义取决于HttpInfoType参数。HttpInfoType可以是以下任何选项。每对中的第一个常量(HTTP_ *)用于C,第二个(对象.HTTP_ *)用于面向对象的语言。
HTTP_INFO_RETURN_CODE或object.HTTP_INFO_RETURN_CODE
HTTP响应标头中的返回代码。
HTTP_INFO_DOWNLOAD_SIZE或object.HTTP_INFO_DOWNLOAD_SIZE
最后一次下载的大小(以字节为单位),包括头,主体和通信开销(例如,NTLM协商)。
HTTP_INFO_DOWNLOAD_TIME或object.HTTP_INFO_DOWNLOAD_TIME
上次下载的时间(毫秒)。
HTTP_INFO_TOTAL_REQUEST_STAT或object.HTTP_INFO_TOTAL_REQUEST_STAT
返回自从首次使用HTTP_INFO_TOTAL_REQUEST_STAT发出web_get_int_property时所有标题和正文的累积大小。
HTTP_INFO_TOTAL_RESPONSE_STAT或对象.HTTP_INFO_TOTAL_RESPONSE_STAT
返回自从首次使用HTTP_INFO_TOTAL_RESPONSE_STAT发出web_get_int_property时所有响应的累积大小(包括标题和正文)
所有Web脚本和仅以HTTP模式运行的WAP脚本支持此功能。不支持以无线会话协议(WSP)重放模式运行的WAP脚本。
示例:web_get_int_property
以下示例使用web_get_int_property函数检查脚本是否成功访问了my_home主页。
但是返回状态200不一定页面的是成功,而是需要添加检查函数去判断更为合理。
{
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 scriptsuccessfully accessed the My_home home page");
else
lr_log_message("The script failed toaccess the My_home home page ");
}
Sample Output:
The scriptsuccessfully accessed the My_home home page
以下示例使用web_get_int_property函数返回URL和PDF下载的大小(以字节为单位)。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 theweb_get_int_property function after the request
(such as web_urlor web_link) which starts the download.
*/
i =web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
lr_output_message("Thedownload 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("Thedownload 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;
}
Sample Output
Action.c(41): Thedownload 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).
以下示例使用web_get_int_property函数计算操作中以及单个步骤的流量。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.mercurytours.servlet.ReservationServlet",
"Action=http://newtours.mercuryinteractive.com/servlets/com.mercurytours.servlet.ReservationServlet?procSub=1&pg=1",
"Method=POST",
"RecContentType=text/html",
"Referer=http://newtours.mercuryinteractive.com/servlets/com.mercurytours.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.mercurytours.servlet.PurchaseServlet",
"Action=http://newtours.mercuryinteractive.com/servlets/com.mercurytours.servlet.PurchaseServlet",
"Method=POST",
"RecContentType=text/html",
"Referer=http://newtours.mercuryinteractive.com/servlets/com.mercurytours.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%2Emercuryinteractive%2Ecom%2Fservlets%2Fcom%2Emercurytours%2Eservlet%2EPurchaseServlet&ch=762475275111",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t10.inf",
"Mode=HTML",
LAST );
web_submit_data("com.mercurytours.servlet.PurchaseServlet_2",
"Action=http://newtours.mercuryinteractive.com/servlets/com.mercurytours.servlet.PurchaseServlet?procSub=1&pg=1",
"Method=POST",
"RecContentType=text/html",
"Referer=http://newtours.mercuryinteractive.com/servlets/com.mercurytours.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.mercurytours.servlet.SignonServlet_2",
"URL=http://newtours.mercuryinteractive.com/servlets/com.mercurytours.servlet.SignonServlet",
"Resource=0",
"RecContentType=text/html",
"Referer=http://newtours.mercuryinteractive.com/servlets/com.mercurytours.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%2Emercuryinteractive%2Ecom%2Fservlets%2Fcom%2Emercurytours%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, beforesubmit = %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
- loadrunner Web_类函数之web_get_int_property()
- loadrunner Web_类函数之web_add_auto_filter()
- loadrunner Web_类函数之web_add_auto_header()
- loadrunner Web_类函数之web_add_cookie()
- loadrunner Web_类函数之web_add_cookie_ex()
- loadrunner Web_类函数之web_add_filter()
- loadrunner Web_类函数之web_add_header()
- loadrunner Web_类函数之web_browser()
- loadrunner Web_类函数之web_button()
- loadrunner Web_类函数之web_cache_cleanup()
- loadrunner Web_类函数之web_check_box()
- loadrunner Web_类函数之web_convert_param()
- loadrunner Web_类函数之web_convert_date_param()
- loadrunner Web_类函数之web_convert_from_formatted()
- loadrunner Web_类函数之web_convert_to_formatted()
- loadrunner Web_类函数之web_create_html_param()
- loadrunner Web_类函数之web_create_html_param_ex()
- loadrunner Web_类函数之web_custom_request()
- c#接口类
- 使用 bintray 网站发布 library 到 jcenter
- 对于多线程类 实现Runnable接口和继承Thread类有什么区别
- js常用的正则
- Leetcode | Median of Two Sorted Arrays
- loadrunner Web_类函数之web_get_int_property()
- POJ4089电话号码--Trie树的应用
- [部署]VM11下CentOS7mini安装及配置
- 为什么单片机中既有FLASH又有EEPROM?
- Guava使用之Preconditions
- [log]logstash重要参数
- R中的几种统计分布及常用模型 (整理)
- ubuntu apache2 多域名
- 《海边的曼彻斯特》