1、录制脚本中包含中文,出现乱码怎么办?
把录制选项中的Support charset选中UTF-8
录制脚本后,切换到树视图中,打开相应的脚本页面。在右侧的PageView中录制的脚本呈现中文版式,但是当切换到Server Response中,所有的中文全部换成的乱码,如“勌缞仫訆”。
原因是服务器端没有把响应的编码设置为gb2312
在IIS中找到Web.Config文件,在<system.web>….</system.web>节加入<globalization requestEncoding="gb2312" responseEncoding="gb2312" fileEncoding="gb2312"/>后再次录制脚本,乱码变中文。
HTTP协议,如果录制的时候产生乱码则在Recording Options -> Advanced -> Support charset中勾选UTF-8。
如果回放的时候日志中出现乱码则在Run-time Settings -> Internet Protocol Preference -> Advanced Options弹出对话框中的General列表中选择Convert from/to UTF-8为Yes
2、录制到的脚本是空白的
有可能是由于录制的URL地址采用的是localhost的问题,改成分配的IP地址或127.0.0.1试试。
3、插入文本检查点步骤时,使用web_reg_find,通常TextPfx和TextSfx中会包含双引号,需要进行转义(用斜杠),例如:
web_reg_find("Search=Body",
"SaveCount=Welcome",
"TextPfx=欢迎<a class=\"drop\" id=\"viewpro\" nMouseOver=\"showMenu(this.id)\">",
"TextSfx=</a>",
LAST);
4、使用web_image_check插入图片检查点时需要主要设置Run-Time Setting中的Enable Image and text check选项:
使用web_find函数插入文本检查点也一样要做此设置
5、性能测试往往需要准备大批量的数据,大批量数据的生成方法有很多种,常见的有:
(1)编写SQL语句来插入数据
(2)使用DataFactory等专业的数据生成工具
(3)通过LoadRunner录制回放的方式重复执行生成大批量数据
Tips:
使用DataFactory插入nchar数据类型的数据时会出现空值的情况,可以先修改数据库的数据类型设置,插完数据后再改回来
6、在录制脚本的过程中插入注释,录制后查看和理解脚本会更加方便。
7、LoadRunner回放脚本时,在浏览器显示的中文是乱码
解决办法(1):
首先设置Run-Time Settings – Browser – Browser Emulation – User-Agent
然后设置IE:
查看-编码-钩上“自动选择”和Unicode(UTF-8)。
解决办法(2):
使用lr_convert_string_encoding函数来转换编码
下面是一个使用的例子:
lr_convert_string_encoding(lr_eval_string("{ReplyContents}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"ReplyMessage");
web_submit_data("postreply.aspx_2",
"Action=http://127.0.0.1/postreply.aspx?infloat=1&topicid=2&&inajax=1",
"Method=POST",
"EncType=multipart/form-data",
"RecContentType=text/xml",
"Referer=http://127.0.0.1/showtopic-2.aspx",
"Snapshot=t9.inf",
"Mode=HTML",
ITEMDATA,
"Name=iconid", "Value=0", ENDITEM,
"Name=title", "Value=", ENDITEM,
"Name=wysiwyg", "Value=0", ENDITEM,
"Name=checkbox", "Value=0", ENDITEM,
"Name=message", "Value=[localimg=180,112]1[/localimg]\r\n\r\n{ReplyMessage}", ENDITEM,
"Name=e_mediatyperadio", "Value=on", ENDITEM,
"Name=sl_attachdesc", "Value=", ENDITEM,
"Name=attachid", "Value=", ENDITEM,
"Name=attachdesc", "Value=", ENDITEM,
"Name=localid", "Value=", ENDITEM,
"Name=attachdesc", "Value=", ENDITEM,
"Name=localid", "Value=1", ENDITEM,
"Name=attachdesc", "Value=", ENDITEM,
"Name=localid", "Value=2", ENDITEM,
"Name=emailnotify", "Value=on", ENDITEM,
"Name=postreplynotice", "Value=on", ENDITEM,
"Name=postfile", "Value=", "File=Yes", ENDITEM,
"Name=postfile", "Value=D:\\\\图片收集\\\\It's about time.JPG", "File=Yes", ENDITEM,
"Name=postfile", "Value=", "File=Yes", ENDITEM,
"Name=uploadallowmax", "Value=10", ENDITEM,
"Name=uploadallowtype", "Value=jpg,gif", ENDITEM,
"Name=thumbwidth", "Value=300", ENDITEM,
"Name=thumbheight", "Value=250", ENDITEM,
"Name=noinsert", "Value=0", ENDITEM,
LAST);
8、可以在LR测试脚本的目录中找到参数文件,直接修改参数文件
The parameter file is stored in the script. directory as .dat file extension. It can be opened with a simple text editor like Notepad as it is stored in pure text format. Therefore, you can manipulate the files via the Notepad. You can also use office applications such as Microsoft Excel or OpenOffice.org Calc to work on the file. This greatly the amount of work required for maintaining a long list of data.
9、LR9.x启动VUGen时提示"Failed to connect to server"
After upgrading to LoadRunner 9.x I started getting a window popup which said "Failed to connect to server" every time I opened virtual user generator (vugen.exe).
The solution to this was to close virtual user generator and delete the [vugen.ini] file.
vugen.ini is found in the %systemroot% folder on your Windows PC (usually C:\WINDOWS or C:\WINNT).
Once you've deleted the file, virtual user generator will open without any issues and create a new vugen.ini file automatically.
10、怎样抓取有相同左右边界的动态value?
怎样抓取有相同左右边界的动态value?例如:
stateID="d7lg0ehmjkkm6uin3s4boei7oq">
stateID="cvopakp46ftsf8mh6l37ti3ubm">
stateID="bv9mja8gtgr39ddibm5t9163re">
web_reg_save_param里的ORD应该怎样设置?
ORD: Indicates the ordinal position or instance of the match. The default instance is 1. If you specify "All," it saves the parameter values in an array.
例子:
char outFlightParam[50]; // The name of the parameter for correlation
char outFlightParamVal[50]; // The formatted value of outFlightParam
web_reg_save_param("outFlightVal",
"LB=outboundFlight value=", "RB=>",
"ORD=ALL",
"SaveLen=18",
LAST);
web_submit_form("reservations.pl",
"Snapshot=t4.inf",
ITEMDATA,
"Name=depart", "Value=London", ENDITEM,
"Name=departDate", "Value=11/20/2003", ENDITEM,
"Name=arrive", "Value=New York", ENDITEM,
"Name=returnDate", "Value=11/21/2003", 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=83", ENDITEM,
"Name=findFlights.y", "Value=16", ENDITEM,
LAST);
sprintf(outFlightParam, "{outFlightVal_%s}",
lr_eval_string("{outFlightVal_count}"));
sprintf(outFlightParamVal, "Value=%s",
lr_eval_string(outFlightParam));
lr_message("The value argument is : %s", outFlightParamVal);
web_submit_form("reservations.pl_2",
"Snapshot=t5.inf",
ITEMDATA,
"Name=outboundFlight",outFlightParamVal, ENDITEM,
"Name=reserveFlights.x", "Value=92", ENDITEM,
"Name=reserveFlights.y", "Value=10", ENDITEM,
LAST);
11、运行场景时提示“Step download timeout (120 seconds) has expired when downloading resource(s)”
vuser_init.c(12): Error -27728: Step download timeout (120 seconds) has expired when downloading non-resource(s)(出现个别,可以忽略)
vuser_init.c(12): Error -27727: Step download timeout (120 seconds) has expired when downloading resource(s). Set the "Step Timeout caused by resources is a warning" Run-Time Setting to Yes/No to have this message as a warning/error, respectively
如果觉得下载一个页面超过2分钟不是错误的话,可以在Run-Time设置中选择Preferences->Options,修改Step download timeout(sec)的时间
或者把“Step timeout caused by resources is a warning”设置为Yes,这样下载资源超时也只是作为警告,不作为错误提示,但是对于非资源的下载超时,则总是会提示错误的
12、用strtok函数分割字符串
需要在loadrunner里面获得“15”(下面红色高亮的部分),并做成关联参数。
//Body response 内容: <BODY><; PRE>//OK[8,7,5,15,6,5,0,4,0,3,0,3,2,0,0,0,1
用web_reg_save_param取出“8,7,5,15,6,5,0,4,0,3,0,3,2,0,0,0,1”这一段,然后用strtok函数切割出一个个数字,第四个数字就是要找的值
例如:
extern char * strtok(char * string, const char * delimiters ); // Explicit declaration
char separators[] = ",";
char * token;
lr_save_string("1,2,3,4,5,6","str");
token = (char *)strtok(lr_eval_string("{str}"), separators); // Get the first token
if (!token) {
lr_output_message ("No tokens found in string!");
return( -1 );
}
while (token != NULL ) { // While valid tokens are returned
lr_output_message ("%s", token );
token = (char *)strtok(NULL, separators); // Get the next token
}
13、LoadRunner没有购买webservice协议的license,只有http的,可不可以完全用http协议模拟webservice?
可以,参考:
http://blog.testsautomation.com/2009/01/web-services-performance-using-loadrunner/
http://blog.testsautomation.com/2009/05/validating-web-service-response-with-xpath/
14、在场景设置中不忽略思考时间,但是在查看响应时间的时候怎样让LR自动在响应时间里减去思考时间?
在analysis中找到了设置是否在报告中包含思考时间的地方做相应的设置即可:
15、LoadRunner在运行过程中停掉1半虚拟用户
Another issue that I’m facing from time to time is that LoadRunner stops 50% of running users without any notification, issue, error message etc. I’ve find out that it happens only when running with log level set to ‘always send a message’. Because of that, I suggest to run with log level set to ‘Send message only when error occur’.
16、LoadRunner录制不了任何东西
Sometimes LoadRunner is not recording anything while browsing using IE. I have no idea why but the fastest solution is to restart whole LR. Maybe some of you have good explanation for that?
17、测试RTMP协议应该在LoadRunner选择什么协议来录制?
用flex协议
有这几个函数可用:
flex_rtmp_connect Connects a client to an RTMP server and sets connection options.
flex_rtmp_disconnect Disconnects a client from an RTMP server.
flex_rtmp_send Sends messages to an RTMP server.
flex_rtmp_receive Receives responses from an RTMP server
Flex can record and replay scripts involving RTMP (Real Time Messaging Protocol). In order to enable RTMP simulation, you must configure the recording options for the Flex protocol.
To enable RTMP:
1 Open the Recording Options dialog box by selecting Tools > Recording Options or clicking the Options button in the Start Recording dialog box.
2 In the Network > Port Mapping node click Options.
3 Set the Send-Receive buffer size threshold to 1500.
18、如何在LoadRunner中运行QTP脚本?
1、运行准备:
1)勾选QTP的Tools--Options--Run的"Alow other Mercury products to run tests and components"
2)录制需要在lr中运行的QTP脚本,并且在QTP脚本中设置事务,Services.StartTransaction "start"与Services.EndTransaction "start"
2、运行QTP脚本
在LR中运行时选择QTP脚本,为QTP脚本存放目录下文件扩展名为.usr的文件。
注:LR中运行QTP脚本时,只能有一个Vuser,否则将报错:
The load generator is currently running the maximum number of Vusers of this type
19、在LR中如何忽略Socket接收数据的验证
在LR中对Socket进行性能测试时,LR会自己判断lrs_receive回来的数据的长度,而如果长度不符的话会有时间延迟的情况(这是性能测试完全不能接受的事情),如果做到这一点呢,经过反复尝试,发现一种简单的方法(用*代替具体的长度):
类似于将:
recv buf1 12
"Hello, Denny"
改为:
recv buf1 *
"Hello, Denny"
一切OK。
20、LoadRunner9.5的Controller中不能添加Apache的监控
在C:\Program Files\HP\LoadRunner\dat\online_graphs中找到online_resource_graphs.rmd文件,修改[Apache]部分中的EnableInUI为1
21、VB Vuser开发ADO脚本,提示“user-defined type not defined”
想在VB Vuser写入模拟数据操作的过程,然后在VB Vuser里定义了这个全局变量
Private m_Conn As ADODB.Connection '连接对象
Private m_Reco As ADODB.Recordset '结果集
但是在VB Vuser中不识别这个对象,报出user-defined type not defined
需要在Run-Time 设置中的VBA部分把ADO的库选上
如果用VB Script虚拟用户来开发就不要,直接用CreateObject来创建ADO对象即可
22、loadrunner9.5录制脚本时出现c:\PROGRA~1\MICROS~1\office12\Grooveutil.DLL时出错内存位置访问无效
Office2007的问题,IE加载项禁用Groove GFSBrowser Helper 组件
23、LR自带的例子端口号怎么修改?
LR自带的例子端口号是1080,我怎么样把这个端口设置我自己想用的端口号8088,在什么地方设置
在LR安装目录下,找到Xitami.config文件,找到portbase,可以修改它(默认是1000);
默认的端口号是portbase+80;
要把端口号改成8088,就把portionbase改为8008,保存之后就是了(8088=8008+80)。
24、用Web_reg_find查找中文字符串时查找不到
脚本文件里有个default.cfg ,里面有个参数是 UTF8InputOutput ,将其值改为0
25、替代IP Wizard的脚本
http://hi.baidu.com/higkoo/blog/item/39bbb21bc33d76dcac6e751c.html
LoadRunner自带的“IP Wizard”用起来非常麻烦,要不停的点,重要的是最后还必须重启系统生效。
于是乎写个脚本替代之:
1. 假设客户端IP为 192.168.10.31
2. 假设服务端IP为 192.168.10.10
3. 需要模拟的IP为 110.119.120.122
那么,客户端提供添加虚拟IP的BAT脚本:
netsh interface ip add address 本地连接 110.119.120.122 255.255.0.0
对应的删除设置为:
netsh interface ip del address 本地连接 110.119.120.122
对应服务器添加虚拟路由的Shell脚本:
route add -host 110.119.120.122 gw 192.168.10.31
删除路由的脚本:
route del -host 110.119.120.122 gw 192.168.10.31
这样就非常方便了,不用重启任何机器,执行脚本就生效,再执行脚本就取消。