免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
loadrunner 腳本開發(fā)

 腳本開發(fā)-參數(shù)化之將內(nèi)容保存為參數(shù)、參數(shù)數(shù)組及參數(shù)值獲取

by:授客QQ1033553122

VuGen中默認(rèn)使用{}的字符串稱為參數(shù)

注意:參數(shù)必須在雙引號(hào)中才能用

 

將字符串保存為參數(shù)

lr_save_string("string you want to save", "arg_name");

 

舉例:用參數(shù)來替換需要打開的url鏈接

Action2()

 

   lr_save_string("http://172.25.75.2:1080/WebTours/","web_site");

 

   //打開登錄頁(yè)面

   web_url("WebTours",

       "URL = {web_site}",   //運(yùn)行出錯(cuò)//改成"URL={web_site}"即可

       "Resource=0",

       "RecContentType=text/html",

       "Referer=",

       "Snapshot=t1.inf",

       "Mode=HTML",

       LAST);

 

   return 0;

}

運(yùn)行報(bào)錯(cuò):

Action2.c(6): Error -27226: The "URL =http://172.25.75.2:1080/WebTours/" argument (number 2) isunrecognized or misplaced    [MsgId:MERR-27226]

Action2.c(6): web_url("WebTours") highest severity level was"ERROR", 0 body bytes, 0 header bytes  [MsgId:MMSG-26388]

 

解決方法:

"URL = {web_site}",URL和等號(hào)”=”之間多出了一個(gè)空格,去掉該空格即可。

所以使用lr_eval_string()函數(shù)的時(shí)候也是使用雙引號(hào)來調(diào)用的。

 

還可以如下方式

Action2()

 

 

   lr_save_string("http://172.25.75.2:1080/", "web_site");

   lr_save_string("WebTours/", "web_name");

 

   //打開登錄頁(yè)面

   web_url("WebTours",

       "URL={web_site}{web_name}",

       "Resource=0",

       "RecContentType=text/html",

       "Referer=",

       "Snapshot=t1.inf",

       "Mode=HTML",

       LAST);

 

   return 0;

}

 

獲取參數(shù)值的字符串表識(shí)

可用lr_eval_string函數(shù)獲取參數(shù)值的字符串標(biāo)表示,然后用lr_output_message()函數(shù)輸出結(jié)果

Action2()

 

   lr_save_string("http://172.25.75.2:1080/", "web_site");

   lr_save_string("WebTours/", "web_name");

 

   lr_output_message(lr_eval_string("獲取參數(shù)值的字符串表示:{web_site}{web_name}"));

 

   //打開登錄頁(yè)面

   web_url("WebTours",

       "URL= {web_site}{web_name}",

       "Resource=0",

       "RecContentType=text/html",

       "Referer=",

       "Snapshot=t1.inf",

       "Mode=HTML",

       LAST);

 

    return 0;

}

 

注:如果想獲取參數(shù)字符串的第一個(gè)字母,同c,可以這樣:lr_eval_string(“{param}”)[0];

 

int型數(shù)字保存為參數(shù)

lr_save_int(int_number, “param_name”)

例如:

Action2()

   lr_save_int(0, "int_param");

 

   //打開登錄頁(yè)面

   web_url("WebTours",

       "URL=http://172.25.75.2:1080/WebTours/",

//     "Resource=0",

       "Resource={int_parma}",

       "RecContentType=text/html",

       "Referer=",

       "Snapshot=t1.inf",

       "Mode=HTML",

       LAST);

 

   return 0;

}

 

把時(shí)間保存為參數(shù)

通過lr_save_datetime函數(shù)來實(shí)現(xiàn)。

函數(shù)原型:

void lr_save_datetime(const char *format, int offset, const char*name);

format:期望輸出的日期格式,如:%Y、%m、%d、%X

offset:類似與表示時(shí)間的一些關(guān)鍵字常量:

DATE_NOW-> 現(xiàn)在的日期

TIME_NOW-> 現(xiàn)在的時(shí)間

ONE_DAY-> 一天的時(shí)間

ONE_HOUR-> 一小時(shí)的時(shí)間

ONE_MIN-> 一分鐘的時(shí)間

需要注意的是,他們可以單獨(dú)使用,也可以聯(lián)合使用

DATE_NOW + TIME_NOW -> 當(dāng)前時(shí)間

DATE_NOW-ONE_DAY-> 昨天

DATE_NOW+ONE_DAY-> 明天

兩天前的日期

 

 

DATE_NOW-2*(ONE_DAY)、DATE_NOW-2*24*(ONE_HOUR)、DATE_NOW-2*24*60*(ONE_MIN)

2個(gè)小時(shí)后的時(shí)間

TIME_NOW+2*(ONE_HOUR)

TIME_NOW+2*60*(ONE_MIN)

 

name:期望將時(shí)間保存到的那個(gè)參數(shù)的名稱

 

format格式參照表:

Code

Description

%a

dayof week, using locale's abbreviated weekday names

%A

dayof week, using locale's full weekday names

%b

month,using locale's abbreviated month names

%B

month,using locale's full month names

%c

dateand time as %x %X

%d

dayof month (01-31)

%H

hour(00-23)

%I

hour(00-12)

%j

numberof day in year (001-366)

%m

monthnumber (01-12)

%M

minute(00-59)

%p

locale'sequivalent of AM or PM, whichever is appropriate

%S

seconds(00-59)

%U

weeknumber of year (01-52), Sunday is the first day of the week. Weeknumber 01 is the first week with four or more January days init.

%w

dayof week; Sunday is day 0

%W

weeknumber of year (01-52), Monday is the first day of the week. Weeknumber 01 is the first week with four or more January days init.

%x

date,using locale's date format

%X

time,using locale's time format

%y

yearwithin century (00-99)

%Y

year,including century (for example, 1988)

%Z

timezone abbreviation

%%

toinclude the "%" character in your output string

 

舉例:

Action()

{

   lr_save_datetime("%X",TIME_NOW,"time");

   lr_save_datetime("%Y-%m-%d",DATE_NOW,"date");

   lr_save_datetime("%Y-%m-%d%X",DATE_NOW+TIME_NOW,"datetime");

   lr_save_datetime("%Y-%m-%d",DATE_NOW-ONE_DAY,"yesterday");

   lr_output_message(lr_eval_string("系統(tǒng)的當(dāng)前時(shí)間為:{time}"));

   lr_output_message(lr_eval_string("系統(tǒng)的當(dāng)前日期為:{date}"));  

   lr_output_message(lr_eval_string("系統(tǒng)的當(dāng)前日期,當(dāng)前時(shí)間:{datetime}"));

   lr_output_message(lr_eval_string("昨天的日期為:{yesterday}"));

 

   return 0;

}

 

運(yùn)行結(jié)果:

Starting iteration 1.

Starting action Action.

Action.c(7): 系統(tǒng)的當(dāng)前時(shí)間為:12:27:54

Action.c(8): 系統(tǒng)的當(dāng)前日期為:2014-10-22

Action.c(9): 系統(tǒng)的當(dāng)前日期,當(dāng)前時(shí)間:2014-10-2212:27:54

Action.c(10): 昨天的日期為:2014-10-21

Ending action Action.

Ending iteration 1.


把內(nèi)容保存為帶格式的參數(shù)

lr_param_sprintf(param_name,format,var1,var2,…);

示例:

Action2()

{

    intindex = 56;

    char*suffix = "txt";

   lr_param_sprintf("NewParam","log_%d.%s",index,suffix);

   lr_output_message("The new file name is%s",lr_eval_string("{NewParam}"));

   return 0;

}

 

運(yùn)行結(jié)果:

Startingaction Action2.

Action2.c(24):The new file name is log_56.txt

Endingaction Action2.

把內(nèi)容保存到參數(shù)數(shù)組

這個(gè)概念lr9.x后才有

參數(shù)數(shù)組必須滿足以下兩個(gè)條件:

1.參數(shù)必須都是以相同的名字開頭,后面接下劃線加數(shù)字的方式順序賦值。

2.參數(shù)數(shù)組必須有一個(gè)參數(shù)名_count”的參數(shù)來記錄數(shù)組的長(zhǎng)度

 

相關(guān)函數(shù):

lr_paramarr_idx()    //獲取參數(shù)數(shù)組中指定編號(hào)的參數(shù)的值

lr_paramarr_len()    //獲取參數(shù)數(shù)組的長(zhǎng)度

lr_paramarr_random() //參數(shù)列表中隨機(jī)獲取一個(gè)參數(shù)

 

例子:要?jiǎng)?chuàng)建一個(gè)訪問網(wǎng)站的參數(shù)數(shù)組,可以編寫以下代碼

 



說明:通過腳本創(chuàng)建了一個(gè)名為website的參數(shù)數(shù)組,并獲取編號(hào)為2的參數(shù)的值,

運(yùn)行結(jié)果:


 

此處:web_site= lr_paramarr_idx("website", 2),等同:lr_eval_string(“{website_2}”);

 

獲取參數(shù)數(shù)組長(zhǎng)度

例子:

Action2()

 

    intarray_size = 0;

    char*arr_size_str = NULL;

 

   lr_save_string("www.google.com", "website_1");

   lr_save_string("www.google.com", "website_2");

   lr_save_string("www.google.com", "website_3");

   lr_save_string("www.google.com", "website_4");

   lr_save_string("4", "website_count");

 

   array_size = lr_paramarr_len("website");

 

   //輸出整數(shù)

   //1.把結(jié)果array_size保存為參數(shù)

   lr_save_int(array_size, "arr_size");

   //2.獲取參數(shù)的字符串表示

   arr_size_str = lr_eval_string("{arr_size}");

   //輸出結(jié)果

   lr_output_message(arr_size_str);

 

   return 0;

}

運(yùn)行結(jié)果:


 

從參數(shù)列表中隨機(jī)獲取一個(gè)參數(shù)

例子:

Action2()

 

    char*web_site = NULL;

 

   lr_save_string("www.google.com", "website_1");

   lr_save_string("www.google.com", "website_2");

   lr_save_string("www.google.com", "website_3");

   lr_save_string("www.google.com", "website_4");

   lr_save_string("4", "website_count");

 

   web_site = lr_paramarr_idx("website", 2);

   return 0;

}

運(yùn)行結(jié)果:


 

例子:按順序輸出每個(gè)參數(shù)

Action2()

 

    int i= 0;

 

   lr_save_string("www.google.com", "website_1");

   lr_save_string("www.google.com", "website_2");

   lr_save_string("www.google.com", "website_3");

   lr_save_string("www.google.com", "website_4");

   lr_save_string("4", "website_count");

 

   for (i=0; i

   {

       lr_output_message(lr_paramarr_idx("website", i));

   }

   return 0;

}

輸出結(jié)果



 

用指針變量存放參數(shù)

Action2()

 

 

    char*pt = NULL;

 

   lr_save_string("hello world", "param");

    pt ="{param}";

   lr_output_message(pt);

   lr_output_message(lr_eval_string(pt));

 

   return 0;

}

 

運(yùn)行結(jié)果:



 

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
在LR中動(dòng)態(tài)拼接參數(shù)的問題
Loadrunner腳本編程(1)-大體思路
LR常用函數(shù)整理
LoadRunner字符串與參數(shù)的操作及轉(zhuǎn)換技巧
【竺】性能測(cè)試筆記10——?lr_eval_string和lr_save_string函數(shù)
LoadRunner常用函數(shù)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服