根据使用手册内容可见,LR支持的关于Information Functions包括:
1、lr_start_timer & lr_end_timer
lr_start_end_timer_Func()
{
double wasteTime,trans_time;
double time_elapsed;
merc_timer_handle_t timer;
int status;
timer = lr_start_timer();
/*Correlation comment - Do not change! Original value='131159.414823815zHtzfVcpttAtHQpAHtt' Name ='userSession' Type ='ResponseBased'*/
web_reg_save_param_ex(
"ParamName=userSession",
"LB=name="userSession" value="",
"RB="/>
<table border",
SEARCH_FILTERS,
"Scope=Body",
"IgnoreRedirections=No",
"RequestUrl=*/nav.pl*",
LAST);
/* result is in seconds */
time_elapsed = lr_end_timer(timer);
lr_output_message("Duration of web_reg_save_param_ex = %lf", time_elapsed);
/* Subtract time spent on call web_reg_save_param from all open transactions.
Wasted time is measured in milliseconds */
lr_wasted_time(1000 * time_elapsed);
web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t8.inf",
"Mode=HTML",
LAST);
//登录
web_submit_data("login.pl",
"Action=http://127.0.0.1:1080/cgi-bin/login.pl",
"Method=POST",
"RecContentType=text/html",
"Referer=http://127.0.0.1:1080/cgi-bin/nav.pl?in=home",
"Snapshot=t9.inf",
"Mode=HTML",
ITEMDATA,
"Name=userSession", "Value={userSession}", ENDITEM,
"Name=username", "Value=jojo", ENDITEM,
"Name=password", "Value=bean", ENDITEM,
"Name=JSFormSubmit", "Value=on", ENDITEM,
"Name=login.x", "Value=0", ENDITEM,
"Name=login.y", "Value=0", ENDITEM,
LAST);
web_image("Search Flights Button",
"Alt=Search Flights Button",
"Snapshot=t10.inf",
LAST);
lr_start_transaction("Flight");
//步骤1:选择航班出发地和目的地及座位属性
web_submit_form("reservations.pl",
"Snapshot=t11.inf",
ITEMDATA,
"Name=depart", "Value=Denver", ENDITEM,
"Name=departDate", "Value=04/24/2021", ENDITEM,
"Name=arrive", "Value=London", ENDITEM,
"Name=returnDate", "Value=04/25/2021", ENDITEM,
"Name=numPassengers", "Value=1", ENDITEM,
"Name=roundtrip", "Value=<OFF>", ENDITEM,
"Name=seatPref", "Value=None", ENDITEM,
"Name=seatType", "Value=Coach", ENDITEM,
"Name=findFlights.x", "Value=52", ENDITEM,
"Name=findFlights.y", "Value=6", ENDITEM,
LAST);
//步骤2:选择乘坐航班
web_submit_form("reservations.pl_2",
"Snapshot=t12.inf",
ITEMDATA,
"Name=outboundFlight", "Value=020;338;04/24/2021", ENDITEM,
"Name=reserveFlights.x", "Value=36", ENDITEM,
"Name=reserveFlights.y", "Value=5", ENDITEM,
LAST);
//步骤3:完成支付
status=web_submit_form("reservations.pl_3",
"Snapshot=t13.inf",
ITEMDATA,
"Name=firstName", "Value=Jojo", ENDITEM,
"Name=lastName", "Value=Bean", ENDITEM,
"Name=address1", "Value=", ENDITEM,
"Name=address2", "Value=", ENDITEM,
"Name=pass1", "Value=Jojo Bean", ENDITEM,
"Name=creditCard", "Value=", ENDITEM,
"Name=expDate", "Value=", ENDITEM,
"Name=saveCC", "Value=<OFF>", ENDITEM,
"Name=buyFlights.x", "Value=47", ENDITEM,
"Name=buyFlights.y", "Value=9", ENDITEM,
LAST);
/* End transaction with operation result - pass or fail */
if (status == 0)
lr_end_transaction("Flight", LR_PASS);
else
lr_end_transaction("Flight", LR_FAIL);
web_image("SignOff Button",
"Alt=SignOff Button",
"Ordinal=1",
"Snapshot=t14.inf",
LAST);
return 0;
}
2、lr_whoami
lr_whoami_Func()
{
int id, scid;
char *vuser_group; //Memory for vuser_group is allocated automatically. Do not alter the string.
lr_whoami(&id, &vuser_group, &scid);
lr_message( "Group: %s, vuser id: %d, scenario id %d", vuser_group, id, scid);
return 0;
}
Vugen日志输出:
Controller日志输出:
3、lr_get_host_name
lr_get_host_name_Func()
{
char * my_host;
my_host = lr_get_host_name( );
lr_output_message("my_host :%s", my_host);
return 0;
}
Vugen日志输出:
Controller日志输出:
4、lr_get_master_host_name
lr_get_master_host_name_Func()
{
char * controller_host;
controller_host = lr_get_master_host_name( );
lr_output_message("controller_host :%s", controller_host);
return 0;
}
Vugen日志输出:可以看到打印的主机名称为None
Controller日志输出:可以看到成功打印主机名称
5、lr_get_vuser_ip
lr_get_vuser_ip_Func()
{
char *ip;
ip = lr_get_vuser_ip();
if (ip)
lr_output_message("The IP address is %s", ip);
else
lr_output_message("IP spoofing disabled");
return 0;
}
待续......