lr_save_string & lr_eval_string使用介紹

《軟件性能測試與LoadRunner應用》視頻課程

http://edu.51cto.com/course/course_id-1377.html

更多課程體系介紹

http://www.1testing.cn        


最近再做Loadrunner課程時在再次碰到了lr_save_string函數,部分人在詢問這個函數的使用,再次貼出個demo供大家參考。

lr_save_string函數主要是將程序中的常量或變量保存爲lr中的參數。

int lr_save_string (const char *param_value, const char *param_name);

      函數目的:將param_value值保存到param_name變量中

      參數介紹:param_value:要保存的值

      param_name: 變量名稱



示例:


char *software="hello";

lr_save_string("10","test"); //將常量10保存爲參數test

lr_output_message(lr_eval_string("{test}"));  //獲取並輸出參數page的當前值  

lr_save_string(software,"test");     //將變量保存爲參數,software爲變量

lr_output_message(lr_eval_string("{test}"));

  

執行結果:

10

hello


2.再看個例子。在學習性能測試中,有些朋友經常使用虛擬機,用loadrunner錄製好腳本後,接下來就看通過通過 lr_save_string獲得服務器的IP

Action()

{

  lr_save_string("192.168.42.47","SeverIP");  //192.168.42.47是虛擬機的ip,如果虛擬機ip經常變動,可以在此修改,然後傳遞給參數SeverIP


web_url("forum.php", 

"URL=http://{SeverIP}/Discuz/upload/forum.php", 

"TargetFrame=", 

"Resource=0", 

"RecContentType=text/html", 

"Referer=", 

"Snapshot=t1.inf", 

"Mode=HTML", 

LAST);


    return 0;  

}  


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章