LR常用函数总结
事务函数:51Testing软件测试网[m:[8m_1jo
lr_start_transaction();//标记事务的开始
q![y&E x#EL)l410011lr_start_transaction();/*标记事务的结束,一般情况下,事务开始与结束联合使用*/51Testing软件测试网~t8W J!u@ f
lr_get_trans_instance_status();//得到事务的状态51Testing软件测试网^/v j{c5c5z
lr_get_transaction_think_time();//得到事务的指定思考时间,事务时间=整体事务时间-事务的51Testing软件测试网3a.F&B7Z;o5T0?
lr_stop_transaction();//停止事务
HEvH wK ?410011UrPbm2nI3d)]V eh410011lr_debug_message();//发送调试信息到日志文件
x0T'Yg `4Ww410011lr_error_message();//发送错误信息到LR输入窗口或日志文件里51Testing软件测试网 zvc0q6R Qh
lr_get_debug_message();//返回当前调试的信息51Testing软件测试网k"W*D[ \ pK
lr_log_message();//发送信息到用户日志文件51Testing软件测试网[2JR+VcM%ZzG7Pn
lr_output_message();//发送信息到输出窗口或日志文件51Testing软件测试网1Y*m l0P8A ~]0r
lr_vuser_status_message();//发送虚拟用户的状态到LR的Controller51Testing软件测试网4c G`E%sPp;c1C
运行时函数:51Testing软件测试网J2h#z(a]X1JE M
lr_abort();//终止执行的脚本51Testing软件测试网uP#Bs[
lr_continue_on_error();//当发生错误后运行的事件51Testing软件测试网qjqn5cj/F
lr_exit();//从scirpt.ation.iteration中退出
g)Y)i5F)|w_ _%g410011lr_rendezvous_ex();//设置集合点
f*HH5K%w;|410011lr_think_time();//设置思考时间,在性能测试中为了更好模拟以后操作,可以根据实际生产环境设置思考时间。
n$Q]G g410011lr_rendezous();//集合点,可以设置虚拟用户相同操作之前进行集合,通过集合点可以增加被测试应用的压力,从而达到压力测试的目的。
2J l N_eA5F4I-ZV410011lr_load_dll();//调用DLL文件
%}:a8C7o.hBC;`410011例子:51Testing软件测试网0f6u t%zN9kI*izf-B
lr_load_dll("user32.dll");
R({fD ILOAcf410011MessageBoxA(NULL,"This isTestingMessage","message_caption",0);51Testing软件测试网3ew4M,dh~4S#u+L
return 0;
b+JL3Tbo*O410011系统信息函数:51Testing软件测试网gD,li)R8U@(X8w
lr_get_master_host_name();//返回运行Controller主机的名称51Testing软件测试网%Cx$D1p;@)?'e1kI
lr_get_user_ip();//返回虚拟用户的IP地址51Testing软件测试网i#P6a)\n}9["o$_
lr_user_data_point();//录制用户自定义的数据样例
7T,|%SuX4\$u410011lr_user_data_point();// 记录自己的数据来进行分析,每次要记录一个点时,请使用该函数记录采样名称和值。系统将自动记录采样的时间。执行之后,可以使用用户等义的数据,点击图形分析结果
;n'Z O ^jX#o#w/kq+H4g410011lr_get_host_name();//返回主机名
IS7^fR*D410011例子;
-l{{?r3R;`V410011char * host;51Testing软件测试网(N2I5^g n%[/G-{U Ud
host=lr_get_host_name();
N3`7@ MF^F*uk410011lr_output_message("Computer Name %s",host);
.k/f3Y%Q ^k)ic;^sef410011return 0;
VOOPRk!|s410011j,] P;qtg/bS410011web_url();//根据函数中的URL属性加载对应的URL,不需要上下文。
]#J)A NQ]410011web_image();//模拟鼠标在指定图片上的单击动作。此函数必须在有前置操作的上下文中使用。
c9mp3GM410011Tips:在Toos—Recording Option,如果录制级别设为基于HMTL的录制方式时,web_image才会被录制到。51Testing软件测试网2C']\ zj:Qh
Web_link();//模拟鼠标在由若干个属性集合描述的链接上进行单击。此函数必须在前置动作的上下文中才可以执行。
GU0j9YT(V S410011web_submit_form. ();//函数用来提交表单。此函数可能必须在前一个操作的上下文中执行。51Testing软件测试网9^/B}c,fM)_#L
Tips:支持Web虚拟用户,不支持WAP虚拟用户。
{%eW%T"L7g410011web_submit_data();//函数处理无状态或者上下文无关的表单提交。它用来生成表单的GET或POST请求,这些请求与Form自动生成的请求是一样的。发送这些请求时不需要表单上下文。
R lY\%E Vy410011web_find();//此函数的作用是在HTML页面中查找指定的字符串。当指定的HTML请求全部完成以后,开始执行搜索过程,比web_reg_find要慢。
7@0i8g Z:CxL]410011web_find函数在C语言的脚本中已经被web_reg_find所替代,web_reg_find运行速度比较快,而且在HTML-based和URL-based的录制方式中都可以使用。 在C语言脚本中,web_find是向后兼容的。Java和Visual Basic脚本中不再支持它。
)Nc$?*W*y&e%d/ob410011web_image_check();//检查指定的图象是否在HTML页面中出现,此函数仅仅支持基于HTML的脚本。51Testing软件测试网h&c~ w#J*@X
web_reg_add_cookie();//是注册类型的函数。它首先注册一个搜索文本字符串的请求。检查动作在后续的Action函数之后进行。如果字符串被找到,就添加到cookie中。
v Y w+XdS7X410011web_reg_find();//属于注册函数,注册一个在web页面中搜索文本字符串的请求,在接下来的Action(象web_url)类函数中执行搜索。
"V"n6Qv+G7dQQ410011web_concurrent_start();//函数是并发组开始的标记。组中所有的函数是并发执行的。并发组的结束web_concurrent_end 函数。
(N&jN~;^y-o410011web_reg_save_param();//关联函数,通过关联可以在测试中保持动态值,从服务器返回的数据库中查找需要关联的数据。51Testing软件测试网7K0j$fBg
web_add-filter();// 过滤函数,用于对指定的URL进行过滤,分析URL加载那部分对性能有影响。界面操作Run-time Settings 下的 Internet Protocol的Download Filters。51Testing软件测试网tZ6y)u4F"B6[7]Z9? \/W
web_custom_request();// 自定义请求函数,可以编写自定义请求格式进行接口功能测试。
`!\ C-s ?Ia%D410011FTP /IMAP方面:51Testing软件测试网~&N%hZq Y)b
ftp_logon_ex();//针对特定会话登录到FTP服务器。51Testing软件测试网&A4~l8\4m([
ftp_put_ex();//在FTP服务器上设置工作目录及上传文件。
%a'U6Vmm f}&M410011ftp_logout_ex();//注销当前FTP连接。51Testing软件测试网;P$S`\Ry$V!} A
imap_create();//创建新的邮件。51Testing软件测试网C/d.o1qo[3uhS
imap_check();//邮件中请求检查点,实现并适用与邮箱内部的内务管理。
)@/C,T-wL/`uZ410011Tips:针对IMAP的测试,把函数中的ftp替换成imap即可。51Testing软件测试网 kX` r QN Kp7\
其它常用函数:51Testing软件测试网? I TI8oA%@ m ~
Lr_decrypt():LR中的解密函数
~R&ad^410011实例代码: lr_output_message("解密函数测试,解密后数值:%s",lr_decrypt("4e0942869c958e3e"));51Testing软件测试网#fjMo2d3L
Getenv():得到定义的环境变量值51Testing软件测试网C8]Pw8BZ
实例代码:
am)h8zKU410011char *tmp,logfile[256],dlr_seperator;51Testing软件测试网U;?d8})S:o*J4A
logfile;51Testing软件测试网u u6d%WMGc7F6Y'n1I
//Create an environment variable51Testing软件测试网F:P(r8Sq9Y3u
putenv("LOGFILE_NAME=lr_xiaolintest.txt");51Testing软件测试网hD3MbEf\:]
//51Testing软件测试网%D;})u!U1T!o5x M
if(tmp = (char*)getenv("TEMP"))
-mO&x V5Q6D5ov8F410011lr_output_message("Temp Dir = %s",tmp);51Testing软件测试网h+f EKwf
else{51Testing软件测试网 DJ @+m1kT9iN
lr_output_message("TEMP environment variable undefined");
Y2`?F![~410011return -1;
w3a \,OcV u9\410011}51Testing软件测试网[P#iW v_)Z o
sprintf(logfile,"%s\\%s",tmp,(char*)getenv("LOGFILE_NAME"));
~$KG*]0U3lZ410011System():执行操作系统的命令51Testing软件测试网(Ww Y3s"f/}gxK
char filename[1024],command[1024];
/\S#YG~:T d!Lt410011char new_dir[] = "c:\\test";51Testing软件测试网#}9P1FEN9e
//Create a directory udder root calledtestand make it the current dir
\}oy6_410011if(mkdir(new_dir))51Testing软件测试网Mtb&m l,D`b
lr_output_message("Create directory :%s failed",new_dir);51Testing软件测试网/{4Q;\rJP]
else
j&LY,Y#n xQ q2bJ410011lr_output_message("Create new directory %s",new_dir);
(~z5NS7V#}410011sprintf(filename,"%s\\%s",new_dir,"xialin.txt");51Testing软件测试网4iAX Z|4L,yM
//Executr a dir /b command and directory it to a new_file
B6yZhx2aX*A410011sprintf(command,"dir /b c:\\ > %s /w",filename);
tx8K+sR9[xmM410011system(command)51Testing软件测试网"hY~\ y4W
lr_output_message("Create new file %s",filename);
8D$P7Zb6irxs410011Rand():得到一个整型的随机值(0到32767)
%FB$bj)p3h0f410011srand(time(NULL));
4Um yrcH8sEE410011//Generate a random number from 0-99
L^a`)n d410011lr_output_message("A number between 0 and 99 is :%d\n",rand()%100);51Testing软件测试网HsWhrNU
return 0;51Testing软件测试网i1|rGNN4H
Getdrive()and mkdir():返回当前驱动盘的名字。
G`A%g x9~iNQ410011int ch,drive,curdrive;
k9M Db4J~PEZn}410011static char path[1024];51Testing软件测试网[B-Rj#@
//Save current drive letter so it can be restored later51Testing软件测试网-j&V e ~@n;w
curdrive = getdrive();51Testing软件测试网%j!p-I-x4u$EqF5f
//If we can switch to the drive,it exists
.p3M)l_kR410011lr_output_message("Available drives are:");
J0Qq.|0I410011for(drive = 1;drive <= 26;drive++)
gA(HuhNq410011if (!chdrive(drive))
O1k)K d1M{410011lr_output_message("%c:",drive + 'A' -1);
J9i7Z/X&u~?410011chdrive(curdrive);//Restore original drive51Testing软件测试网j wD(i8C'|zo
return 0;
,R^_ _:Ta$o d410011Time():返回系统的时间51Testing软件测试网$L2k(@,D3K)e0Gz%g
typedef long time_t;51Testing软件测试网E%Re&t7u$aB
time_t t;51Testing软件测试网D;RJ/y&W6QfV{'y
//Get system time and display as number and string51Testing软件测试网J8a&PNw W:`Z
lr_message("Time in seconds since 1/1/88: %ld\n",time(&t));
u,X-TW9g5E3h1j410011lr_message("Formatted time and date: %s",ctime(&t));51Testing软件测试网]n5sEQ
return 0;
+k6N"{/W+?U410011TAG:
标题搜索
日历
|
|||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
1 | 2 | 3 | 4 | 5 | 6 | ||||
7 | 8 | 9 | 10 | 11 | 12 | 13 | |||
14 | 15 | 16 | 17 | 18 | 19 | 20 | |||
21 | 22 | 23 | 24 | 25 | 26 | 27 | |||
28 | 29 | 30 |
我的存档
数据统计
- 访问量: 3802
- 日志数: 15
- 建立时间: 2011-07-07
- 更新时间: 2012-11-21