把录制选项中的Support charset选中UTF-8
录制脚本后,切换到树视图中,打开相应的脚本页面。在右侧的PageView中录制的脚本呈现中文版式,但是当切换到Server Response中,所有的中文全部换成的乱码,如“勌缞仫訆”。
原因是服务器端没有把响应的编码设置为gb2312
在IIS中找到Web.Config文件,在<system.web>….</system.web>节加入<globalization requestEncoding="gb2312" responseEncoding="gb2312" fileEncoding="gb2312"/>后再次录制脚本,乱码变中文。
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\" onMouseOver=\"showMenu(this.id)\">",
"TextSfx=</a>",
LAST);
使用web_find函数插入文本检查点也一样要做此设置
5、性能测试往往需要准备大批量的数据,大批量数据的生成方法有很多种,常见的有:
(1)编写SQL语句来插入数据
(2)使用DataFactory等专业的数据生成工具
(3)通过LoadRunner录制回放的方式重复执行生成大批量数据
Tips:
使用DataFactory插入nchar数据类型的数据时会出现空值的情况,可以先修改数据库的数据类型设置,插完数据后再改回来
6、在录制脚本的过程中插入注释,录制后查看和理解脚本会更加方便。
解决办法(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);
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.
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?
例如:
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,这样下载资源超时也只是作为警告,不作为错误提示,但是对于非资源的下载超时,则总是会提示错误的
需要在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
}
可以,参考:
http://blog.testsautomation.com/2009/01/web-services-performance-using-loadrunner/
http://blog.testsautomation.com/2009/05/validating-web-service-response-with-xpath/
在analysis中找到了设置是否在报告中包含思考时间的地方做相应的设置即可:
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’.
用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.
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
在LR中对Socket进行性能测试时,LR会自己判断lrs_receive回来的数据的长度,而如果长度不符的话会有时间延迟的情况(这是性能测试完全不能接受的事情),如果做到这一点呢,经过反复尝试,发现一种简单的方法(用*代替具体的长度):
类似于将:
recv buf1 12
"Hello, Denny"
改为:
recv buf1 *
"Hello, Denny"
一切OK。
在C:\Program Files\HP\LoadRunner\dat\online_graphs中找到online_resource_graphs.rmd文件,修改[Apache]部分中的EnableInUI为1
参考:
想在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对象即可
Office2007的问题,IE加载项禁用Groove GFSBrowser Helper 组件
LR自带的例子端口号是1080,我怎么样把这个端口设置我自己想用的端口号8088,在什么地方设置
在LR安装目录下,找到Xitami.config文件,找到portbase,可以修改它(默认是1000);
默认的端口号是portbase+80;要把端口号改成8088,就把portionbase改为8008,保存之后就是了(8088=8008+80)。
Error -27727: Step download timeout (120 seconds)has expired when downloading resource(s). Set the "Resource Page Timeout is a Warning" Run-Time Setting to Yes/No to have this message as a warning/error, respectively
A、应用服务参数设置太大导致服务器的瓶颈
B、页面中图片太多
C、在程序处理表的时候检查字段太大多
Error -27728: Step download timeout (120 seconds)的解决方法
语法检查通过,但是在并发执行一个查询时候报错Action.c(16): Error -27728: Step download timeout (120 seconds) has expired when downloading non-resource(s)
设置了runt time setting中的internet protocol-preferences中的advaced区域有一个winlnet replay instead of sockets选项,选项后再回放就成功了。
Action.c(7): Error -27791: Server "10.10.0.88" has shut down the connection prematurely
解决方案如下:
1、应用服务器死掉。小用户时程序上的问题,程序上处理数据库的问题
2、应用服务没有死。应用服务参数设置问题。例如:在许多客户端weblogic应用服务器被拒绝,而在服务器端没有错误显示,则有可能是weblogic中的server元素的acceptbacklog属性值设得过低。如果连接时收到connection refused消息,说明应提高该值,每次增加25%。
3、数据库的连接
在应用服务的性能参数可能太小了,数据库启动的最大连接数(跟硬件的内存有关)
4、有时关闭卡巴斯基也会解决如上问题