日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

LoadRunner小技巧集锦

發(fā)布時間:2025/3/15 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 LoadRunner小技巧集锦 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

?

?

1、錄制腳本中包含中文,出現(xiàn)亂碼怎么辦?

把錄制選項中的Support charset選中UTF-8

?

?

錄制腳本后,切換到樹視圖中,打開相應(yīng)的腳本頁面。在右側(cè)的PageView中錄制的腳本呈現(xiàn)中文版式,但是當切換到Server Response中,所有的中文全部換成的亂碼,如“勌缞仫訆”。

?

原因是服務(wù)器端沒有把響應(yīng)的編碼設(shè)置為gb2312

?

在IIS中找到Web.Config文件,在<system.web>….</system.web>節(jié)加 入<globalization requestEncoding="gb2312" responseEncoding="gb2312" fileEncoding="gb2312"/>后再次錄制腳本,亂碼變中文。

?

2、錄制到的腳本是空白的

有可能是由于錄制的URL地址采用的是localhost的問題,改成分配的IP地址或127.0.0.1試試。

?

?

3、插入文本檢查點步驟時,使用web_reg_find,通常TextPfx和TextSfx中會包含雙引號,需要進行轉(zhuǎn)義(用斜杠),例如:

?

?????? web_reg_find("Search=Body",

????????????? "SaveCount=Welcome",

????????????? "TextPfx=歡迎<a class=\"drop\" id=\"viewpro\" onMouseOver=\"showMenu(this.id)\">",

????????????? "TextSfx=</a>",

????????????? LAST);

?

4、使用web_image_check插入圖片檢查點時需要主要設(shè)置Run-Time Setting中的Enable Image and text check選項:

?

?

使用web_find函數(shù)插入文本檢查點也一樣要做此設(shè)置

?

5、性能測試往往需要準備大批量的數(shù)據(jù),大批量數(shù)據(jù)的生成方法有很多種,常見的有:

?????? (1)編寫SQL語句來插入數(shù)據(jù)

(2)使用DataFactory等專業(yè)的數(shù)據(jù)生成工具

?????? (3)通過LoadRunner錄制回放的方式重復執(zhí)行生成大批量數(shù)據(jù)

?

Tips:

使用DataFactory插入nchar數(shù)據(jù)類型的數(shù)據(jù)時會出現(xiàn)空值的情況,可以先修改數(shù)據(jù)庫的數(shù)據(jù)類型設(shè)置,插完數(shù)據(jù)后再改回來

?

6、在錄制腳本的過程中插入注釋,錄制后查看和理解腳本會更加方便。

?

?

7、LoadRunner回放腳本時,在瀏覽器顯示的中文是亂碼

?

解決辦法(1):

首先設(shè)置Run-Time Settings – Browser – Browser Emulation – User-Agent

?

?

然后設(shè)置IE:

查看-編碼-鉤上“自動選擇”和Unicode(UTF-8)。

?

解決辦法(2):

使用lr_convert_string_encoding函數(shù)來轉(zhuǎn)換編碼

?

下面是一個使用的例子:

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測試腳本的目錄中找到參數(shù)文件,直接修改參數(shù)文件

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、怎樣抓取有相同左右邊界的動態(tài)value?

怎樣抓取有相同左右邊界的動態(tài)value?例如:

stateID="d7lg0ehmjkkm6uin3s4boei7oq">

stateID="cvopakp46ftsf8mh6l37ti3ubm">

stateID="bv9mja8gtgr39ddibm5t9163re">

web_reg_save_param里的ORD應(yīng)該怎樣設(shè)置?

?

?

?

?

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)(出現(xiàn)個別,可以忽略)

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設(shè)置中選擇Preferences->Options,修改Step download timeout(sec)的時間

或者把“Step timeout caused by resources is a warning”設(shè)置為Yes,這樣下載資源超時也只是作為警告,不作為錯誤提示,但是對于非資源的下載超時,則總是會提示錯誤的

?

12、用strtok函數(shù)分割字符串

需要在loadrunner里面獲得“15”(下面紅色高亮的部分),并做成關(guān)聯(lián)參數(shù)。

//Body response 內(nèi)容: <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函數(shù)切割出一個個數(shù)字,第四個數(shù)字就是要找的值

?

例如:

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協(xié)議的license,只有http的,可不可以完全用http協(xié)議模擬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、在場景設(shè)置中不忽略思考時間,但是在查看響應(yīng)時間的時候怎樣讓LR自動在響應(yīng)時間里減去思考時間?

?

在analysis中找到了設(shè)置是否在報告中包含思考時間的地方做相應(yīng)的設(shè)置即可:

?

?

?

?

?

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 ‘a(chǎn)lways 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協(xié)議應(yīng)該在LoadRunner選擇什么協(xié)議來錄制?

?

用flex協(xié)議

?

有這幾個函數(shù)可用:

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腳本中設(shè)置事務(wù),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接收數(shù)據(jù)的驗證

在LR中對Socket進行性能測試時,LR會自己判斷l(xiāng)rs_receive回來的數(shù)據(jù)的長度,而如果長度不符的話會有時間延遲的情況(這是性能測試完全不能接受的事情),如果做到這一點呢,經(jīng)過反復嘗試,發(fā)現(xiàn)一種簡單的方法(用*代替具體的長度):

?

類似于將:

recv buf1 12

"Hello, Denny"

?

改為:

recv buf1 *

"Hello, Denny"

?

一切OK。

?

?

?

20、LoadRunner9.5的Controller中不能添加Apache的監(jiān)控

?

?

在C:\Program Files\HP\LoadRunner\dat\online_graphs中找到online_resource_graphs.rmd文件,修改[Apache]部分中的EnableInUI為1

參考:

http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1274450165814+28353475&threadId=1229523

?

?

21、VB Vuser開發(fā)ADO腳本,提示“user-defined type not defined”

想在VB Vuser寫入模擬數(shù)據(jù)操作的過程,然后在VB Vuser里定義了這個全局變量

Private m_Conn As ADODB.Connection '連接對象

Private m_Reco As ADODB.Recordset? '結(jié)果集

但是在VB Vuser中不識別這個對象,報出user-defined type not defined

?

?

需要在Run-Time 設(shè)置中的VBA部分把ADO的庫選上

如果用VB Script虛擬用戶來開發(fā)就不要,直接用CreateObject來創(chuàng)建ADO對象即可

?

?

22、loadrunner9.5錄制腳本時出現(xiàn)c:\PROGRA~1\MICROS~1\office12\Grooveutil.DLL時出錯內(nèi)存位置訪問無效

?

Office2007的問題,IE加載項禁用Groove? GFSBrowser Helper 組件

?

?

23、LR自帶的例子端口號怎么修改?

LR自帶的例子端口號是1080,我怎么樣把這個端口設(shè)置我自己想用的端口號8088,在什么地方設(shè)置

?

?

在LR安裝目錄下,找到Xitami.config文件,找到portbase,可以修改它(默認是1000);

默認的端口號是portbase+80;

要把端口號改成8088,就把portionbase改為8008,保存之后就是了(8088=8008+80)。

?

24、用Web_reg_find查找中文字符串時查找不到

?

腳本文件里有個default.cfg ,里面有個參數(shù)是 UTF8InputOutput ,將其值改為0

?

?

?

25、替代IP Wizard的腳本

?

http://hi.baidu.com/higkoo/blog/item/39bbb21bc33d76dcac6e751c.html

?

LoadRunner自帶的“IP Wizard”用起來非常麻煩,要不停的點,重要的是最后還必須重啟系統(tǒng)生效。

于是乎寫個腳本替代之:

1. 假設(shè)客戶端IP為 192.168.10.31

2. 假設(shè)服務(wù)端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

對應(yīng)的刪除設(shè)置為:

netsh??? interface??? ip??? del??? address??? 本地連接??? 110.119.120.122

?

對應(yīng)服務(wù)器添加虛擬路由的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

?

這樣就非常方便了,不用重啟任何機器,執(zhí)行腳本就生效,再執(zhí)行腳本就取消。

?

?

26、如何從命令行調(diào)用LoadRunner腳本?

?

Here is the command line that you need to execute to run a VuGen script from the command prompt:

???<LoadRunner>\bin\mmdrv.exe -usr <path to usr file>?

Note:
In order to get all the other options that go with the command, run mmdrv.exe from the command prompt without any options.

?

?

27、請問"int64這個類型,在LR中怎么表示"。我將一段C的代碼放在LR中,LR不認int64這個類型,怎么解決?

?

把那段C代碼做成DLL,然后在LR中調(diào)用

?

?

28、LoadRunner監(jiān)控遠程機器Windows資源,提示“net use failed”

?

解決辦法

在被監(jiān)控機器上更改本地帳戶的共享和安全模式為經(jīng)典模式。控制面板->管理工具->本地安全策略->網(wǎng)絡(luò)訪問:本地帳戶的共享和安全模式->經(jīng)典模式。

?

監(jiān)視連接前的準備工作

首先保證被監(jiān)視的windows系統(tǒng)開啟以下二個服務(wù)Remote Procedure Call(RPC) 和Remote Registry Service

被監(jiān)視的WINDOWS機器:右擊我的電腦,選擇管理->共享文件夾->共享 在這里面要有C$這個共享文件夾,(要是沒有自己手動加)

然后保證在安裝LR的機器上使用運行.輸入\\被監(jiān)視機器IP\C$ 然后輸入管理員帳號和密碼,如果能看到被監(jiān)視機器的C盤了,就說明你得到了那臺機器的管理員權(quán)限,可以使用LR去連接了

?

?

?

?

?

?

?

?

?

?

?

?

? ----------- 軟件性能測試工作室:提供性能測試咨詢、培訓和項目指導 (QQ: 2225045276 E-Mail: Automa

總結(jié)

以上是生活随笔為你收集整理的LoadRunner小技巧集锦的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。