// lr_convert_string_encoding 在下列编码之间转换字符串编码:系统区域设置、Unicode 和 UTF-8。
// 该函数将结果字符串(包括其终止 // 结果字符串 NULL)保存在参数 paramName 中。
int lr_convert_string_encoding ( const char *sourceString, const char *fromEncoding, const char *toEncoding, const char *paramName);
// lr_output_message 函数将带有脚本部分和行号的消息 // 发送到输出窗口和日志文件。 int lr_output_message (const char * format, exp1, exp2,...expn.);
-- Sends a Vuser message to the log file and output window with location information.
// lr_log_message -- Sends a message to the Vuser log file.
// lr_message -- Sends a message to the log file and output window.
// lr_save_string 函数将指定的以 null 终止的 // 字符串赋给参数。该函数可用于关联 // 查询。要确定参数值,请使用 // 函数 lr_eval_string。
int lr_save_string (const char *param_value, const char *param_name);
// lr_eval_string 函数在评估任何嵌入的参数之后 // 返回输入字符串。如果字符串 // 实参 (argument) 只包含一个形参 (parameter),该函数 // 返回形参的当前值。 char * lr_eval_string (const char * instring );
HP LoadRunner Online Function Reference > C Language Functions > Example: strcpy
// strcat 连接两个字符串。 char *strcat ( char *to, const char *from );
-- The following example uses strcat to append a backslash to the directory name, fullpath. It then appends filename to fullpath.
// strcpy 将一个字符串复制给另一个。 char *strcpy ( char *dest, const char *source );
-- The following example uses strcpy to copy the string "c:\\tmp" to the character array fullpath.
Action() { char fullpath[1024], *filename = "logfile.txt"; strcpy(fullpath, "c:\\tmp"); lr_output_message("fullpath after strcpy: %s", fullpath); strcat(fullpath, "\\"); strcat(fullpath, filename); lr_output_message("Full path of file is %s", fullpath); lr_output_message( "We are on iteration #%s", lr_eval_string( "{iteration}" ) ); lr_log_message( "We are on iteration #%s", lr_eval_string( "{iteration}" ) ); lr_output_message("111"); lr_log_message("222"); lr_message("333"); return 0; }
O utput:
Action.c(6): fullpath after strcpy: c:\tmp
Action.c(10): Full path of file is c:\tmp\logfile.txt
ReplayLog:
Virtual User Script started at : 2012-01-10 11:42:18
Starting action vuser_init.
Web Turbo Replay of LoadRunner 11.0.0 for Windows 7; build 8859 (Aug 18 2010 20:14:31) [MsgId: MMSG-27143]
Run Mode: HTML [MsgId: MMSG-26000]
Run-Time Settings file: "D:\dev_test\loadrunner_scripts\function_test\\default.cfg" [MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(7): fullpath after strcpy: c:\tmp
Action.c(12): Full path of file is c:\tmp\logfile.txt
Action.c(13): We are on iteration #{iteration}
We are on iteration #{iteration}
Action.c(16): 111
222
333
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
Action() { int i; for(i=0;i<10;i++) { char tmp1[100]; lr_convert_string_encoding( lr_eval_string("{KeyWord}"), LR_ENC_SYSTEM_LOCALE, LR_ENC_UTF8, "EncodedSearchTerm" ); strcpy( tmp1, lr_eval_string("{EncodedSearchTerm}") ); lr_save_string( tmp1, "sorvalue_book" ); web_url("SNGetKeywordCmd", "URL=http://b2cpre.********.com/emall/SNGetKeywordCmd?keyWord={sorvalue_book}", "Resource=0", "RecContentType=text/html", "Referer=http://b2cpre.********.com/", "Snapshot=t4.inf", "Mode=HTML", LAST); /* ............................... */ return 0; } }
HP-LoadRunner ---- Run-time Settings ---- General ---- Run Logic ---- Iteration Counter ---- Number of Iterations ----"2"
HP-LoadRunner ---- Parameter List ---- "worklist"
wordlist
大学英语
大学语文
HP-LoadRunner ---- Action
Action() { // 中文搜索关键词参数化乱码,再转码过程 char tmp1[100]; lr_convert_string_encoding( lr_eval_string("{wordlist}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"EncodedSearchTerm" ); strcpy( tmp1, lr_eval_string("{EncodedSearchTerm}") ); lr_save_string( tmp1, "wordlist2" ); web_url("b2cpre.********.com", "URL=http://b2cpre.********.com/", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", EXTRARES, "Url=http://prescript.******.cn/css/ShoppingArea/V5/images/repeatX.png", ENDITEM, "Url=http://preimage3.******.cn/images/advertise/002/dingtong_1200.jpg", ENDITEM, "Url=http://prescript.******.cn/css/ShoppingArea/V5/images/btn.png", ENDITEM, "Url=http://image2.******.cn/images/advertise/hg/saohuo1124/baliansaohuo.jpg", ENDITEM, "Url=http://prescript.******.cn/javascript/sn_da/sa.js", ENDITEM, "Url=http://prescript.******.cn/css/ShoppingArea/V5/images/btn.jpg", ENDITEM, "Url=http://preimage3.******.cn/images/advertise/002/tanchu_1200.jpg", ENDITEM, "Url=http://prescript.******.cn/css/ShoppingArea/V5/images/main.png", ENDITEM, "Url=http://prescript.******.cn/css/ShoppingArea/V5/images/hotline.png", ENDITEM, "Url=http://prescript.******.cn/css/ShoppingArea/V5/images/diaocha.png", ENDITEM, "Url=http://image.******.cn/images/advertise/lss/dianhua1110/dianhua1110.jpg", ENDITEM, "Url=http://image.******.cn/images/advertise/lss/kxo1122/lunzhuan.jpg", ENDITEM, "Url=http://image2.******.cn/images/advertise/ys/shehua1114/shehua1114l.jpg", ENDITEM, "Url=http://image3.******.cn/images/advertise/lss/chuwei109/lunzhuan.gif", ENDITEM, "Url=http://image2.******.cn/images/advertise/ys/shoubiao1110/shoubiao1110.jpg", ENDITEM, "Url=/emall/SNSetCityIdCmd?storeId=10052&catalogId=10051&_=1326424112574", ENDITEM, "Url=http://clicksit.******.cn/sa/ajaxInit.gif?_snma=b2cpre.********.com|13260945389278220278194493|1326094538927|1326423537783|1326424113946|39|16&_snmb=" "13264241139625735696968538%7C-1002%7CG%7C%7C%7C%7C%7Chttp%3A%2F%2Fb2cpre.********.com%2F%7C%E8%8B%8F%E5%AE%81%E6%98%93%E8%B4%AD-%E8%8B%8F%E5%AE%81%E7%94%B5%E5%99%A8%E7%BD%91%E4%B8%8A%E5%95%86%E5%9F%8E%EF%BC%8C%E9%A2%86%E5%85%88%E7%9A%84%E7%BB%BC%E5%90%88%E7%BD%91%E4%B8%8A%E8%B4%AD%E7%89%A9%E5%95%86%E5%9F%8E%EF%BC%8C%E6%AD%A3%E5%93%81%E8%A1%8C%E8%B4%A7%EF%BC%8C%E5%85%A8%E5%9B%BD%E8%81%94%E4%BF%9D%EF%BC%8C%E8%B4%A7%E5%88%B0%E4%BB%98%E6%AC%BE%EF%BC%8C%E8%AE%A9%E6%82%A8%E5%B0%BD%E4%BA%AB%E8%B4%AD%E7%8" "9%A9%E4%B9%90%E8%B6%A3%EF%BC%81%7C1&_snmx=Win7|msie%208.0|1440x900|32bit|1|1|&_snsr=direct|direct|||&_snmz=13264241141969141840906002|", ENDITEM, "Url=http://192.168.121.82/epp-ppp/style/default/css/e-go/images/btn.png", "Referer=http://192.168.121.82/epp-ppp/mo/mobile!beanInput.action", ENDITEM, "Url=http://preimage3.******.cn/images/advertise/001/1212hd_1200.jpg", ENDITEM, LAST); /* //热门搜索页 ---- 热门搜索:九阳豆浆机 全自动洗衣机 大金空调 被毯 三星手机 宏基A500 web_custom_request("snkwvw_10052_10051_3_3_4_.html", "URL=http://b2cpre.********.com/emall/snkwvw_10052_10051_3_3_4_.html?false", "Method=GET", "Resource=0", "RecContentType=text/html", "Referer=http://b2cpre.********.com/", "Snapshot=t2.inf", "Mode=HTML", "EncType=application/x-www-form-urlencoded", LAST); */ /* //秒杀搜索页 web_custom_request("v4secondView", "URL=http://b2cpre.********.com/emall/v4secondView?_=1326424113744&storeId=10052&catalogId=10051&langId=-7&cityId=9173", "Method=GET", "Resource=0", "RecContentType=text/html", "Referer=http://b2cpre.********.com/", "Snapshot=t3.inf", "Mode=HTML", "EncType=application/x-www-form-urlencoded", LAST); */ lr_start_transaction("图书搜索"); /* web_custom_request("SNGetKeywordCmd", "URL=http://b2cpre.********.com/emall/SNGetKeywordCmd?keyWord=d", "Method=GET", "Resource=0", "RecContentType=text/html", "Referer=http://b2cpre.********.com/", "Snapshot=t4.inf", "Mode=HTML", "EncType=application/x-www-form-urlencoded", LAST); */ web_custom_request("SNGetKeywordCmd_2", "URL=http://b2cpre.********.com/emall/SNGetKeywordCmd?keyWord=%E6%98%AF", "Method=GET", "Resource=0", "RecContentType=text/html", "Referer=http://b2cpre.********.com/", "Snapshot=t5.inf", "Mode=HTML", "EncType=application/x-www-form-urlencoded", LAST); lr_think_time(4); web_custom_request("SNGetKeywordCmd_3", "URL=http://b2cpre.********.com/emall/SNGetKeywordCmd?keyWord=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", "Method=GET", "Resource=0", "RecContentType=text/html", "Referer=http://b2cpre.********.com/", "Snapshot=t6.inf", "Mode=HTML", "EncType=application/x-www-form-urlencoded", LAST); // 关键词搜索结果页面 web_submit_data("SNBookSolrSearch", "Action=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords={wordlist2}", "Method=POST", "RecContentType=text/html", "Referer=http://b2cpre.********.com/", "Snapshot=t7.inf", "Mode=HTML", ITEMDATA, EXTRARES, "Url=http://prescript.******.cn/css/css_sn/bookchannel/images/book/topbg.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://prescript.******.cn/css/css_sn/bookchannel/images/book/sub_book.gif", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://prescript.******.cn/css/css_sn/bookchannel/images/book/sprite.gif", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://prescript.******.cn/css/css_sn/bookchannel/images/book/bookHeader.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://prescript.******.cn/css/css_sn/bookchannel/images/book/btn_x.gif", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preimage2.******.cn/content/catentries/00000000010186/000000000101864413/000000000101864413_ls1.jpg", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preimage3.******.cn/content/catentries/00000000010168/000000000101681072/000000000101681072_ls1.jpg", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, LAST); web_url("SNBookBrowseHistoryView", "URL=http://b2cpre.********.com/emall/SNBookBrowseHistoryView?storeId=10052&catalogId=22001&langId=-7&emsName=RecentlyViewedESpot&rankingTitle=RBP&cityId=&_=1326424198474", "Resource=0", "RecContentType=text/html", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", "Snapshot=t8.inf", "Mode=HTML", EXTRARES, "Url=http://preimage3.******.cn/content/catentries/00000000010167/000000000101672842/000000000101672842_ls1.jpg", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preimage1.******.cn/content/catentries/00000000010162/000000000101629965/000000000101629965_ls1.jpg", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preprice2.******.cn/webapp/wcs/stores/prdprice/583718_9173_10052_5-0.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preprice1.******.cn/webapp/wcs/stores/prdprice/591451_9173_10052_5-0.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preprice1.******.cn/webapp/wcs/stores/prdprice/982167_9173_10052_5-0.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preprice2.******.cn/webapp/wcs/stores/prdprice/956863_9173_10052_5-0.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://clicksit.******.cn/sa/ajaxInit.gif?_snma=b2cpre.********.com|13260945389278220278194493|1326094538927|1326424113946|1326424198474|40|16&_snmb=" "13264241139625735696968538%7C33034359212%7CG%7Chttp%3A%2F%2Fb2cpre.********.com%2F%7C%E8%8B%8F%E5%AE%81%E6%98%93%E8%B4%AD-%E8%8B%8F%E5%AE%81%E7%94%B5%E5%99%A8%E7%BD%91%E4%B8%8A%E5%95%86%E5%9F%8E%EF%BC%8C%E9%A2%86%E5%85%88%E7%9A%84%E7%BB%BC%E5%90%88%E7%BD%91%E4%B8%8A%E8%B4%AD%E7%89%A9%E5%95%86%E5%9F%8E%EF%BC%8C%E6%AD%A3%E5%93%81%E8%A1%8C%E8%B4%A7%EF%BC%8C%E5%85%A8%E5%9B%BD%E8%81%94%E4%BF%9D%EF%BC%8C%E8%B4%A7%E5%88%B0%E4%BB%98%E6%AC%BE%EF%BC%8C%E8%AE%A9%E6%82%A8%E5%B0%BD%E4%BA%AB%E8%B4%AD%E7%89%A9%E" "4%B9%90%E8%B6%A3%EF%BC%81%7C1326424114212%7C1326424198489%7Chttp%3A%2F%2Fb2cpre.********.com%2Femall%2FSNBookSolrSearch%3FstoreId%3D10052%26catalogId%3D22001%26langId%3D-7%26brand%3D2%26inventory%3D0%26facet%3Dtrue%26searchKeywords%3D%25E5%25A4%25A7%25E5%25AD%25A6%25E8%258B%25B1%25E8%25AF%25AD%7C%E5%9B%BE%E4%B9%A6%E9%A6%86--%E8%8B%8F%E5%AE%81%E6%98%93%E8%B4%AD%EF%BC%8C%E8%8B%8F%E5%AE%81%E7%94%B5%E5%99%A8%E7%BD%91%E4%B8%8A%E5%95%86%E5%9F%8E%EF%BC%8C%E4%B8%AD%E5%9B%BD%E6%9C%80%E4%B8%93%E4%B8%9A%E7%9" "A%84%E6%89%8B%E6%9C%BA%E3%80%81%E6%95%B0%E7%A0%81%E3%80%81%E7%94%B5%E8%84%91%E3%80%81%E5%BD%A9%E7%94%B5%E3%80%81%E7%A9%BA%E8%B0%83%E3%80%81%E5%86%B0%E7%AE%B1%E3%80%81%E6%B4%97%E8%A1%A3%E6%9C%BA%E3%80%81%E7%94%9F%E6%B4%BB%E7%94%B5%E5%99%A8%E3%80%81%E5%AE%B6%E5%B1%85%E7%94%A8%E5%93%81%E8%B4%AD%E7%89%A9%E6%9C%8D%E5%8A%A1%7C2&_snmx=Win7|msie%208.0|1440x900|32bit|1|1|&_snsr=direct|direct|||&_snmz=13264241749433228584430117|(385,168)(499,122)(499,122)", "Referer=http://b2cpre.********.com/emall/" "SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, LAST); web_url("SNBookListHistoryrecomView", "URL=http://b2cpre.********.com/emall/SNBookListHistoryrecomView?catentry_id1=&catentry_id2=&catentry_id3=&_=1326424198989", "Resource=0", "RecContentType=text/html", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", "Snapshot=t9.inf", "Mode=HTML", EXTRARES, "Url=http://prescript.******.cn/css/css_sn/bookchannel/images/product/out_bg.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://prescript.******.cn/css/css_sn/bookchannel/images/product/sprite.gif", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://prescript.******.cn/css/css_sn/bookchannel/images/product/out_x.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preprice2.******.cn/webapp/wcs/stores/prdprice/448209_9173_10052_5-0.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preimage1.******.cn/content/catentries/00000000010159/000000000101599104/000000000101599104_ls1.jpg", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preprice1.******.cn/webapp/wcs/stores/prdprice/1059636_9173_10052_5-0.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preprice1.******.cn/webapp/wcs/stores/prdprice/1004325_9173_10052_5-0.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preprice2.******.cn/webapp/wcs/stores/prdprice/837657_9173_10052_5-0.png", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preimage2.******.cn/content/catentries/00000000010147/000000000101474489/000000000101474489_ls1.jpg", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://image2.******.cn/images/advertise/hg/tushuqita/four.jpg", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preimage2.******.cn/content/catentries/00000000010146/000000000101465746/000000000101465746_ls1.jpg", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, "Url=http://preimage2.******.cn/content/catentries/00000000010155/000000000101553363/000000000101553363_ls1.jpg", "Referer=http://b2cpre.********.com/emall/SNBookSolrSearch?storeId=10052&catalogId=22001&langId=-7&brand=2&inventory=0&facet=true&searchKeywords=%E5%A4%A7%E5%AD%A6%E8%8B%B1%E8%AF%AD", ENDITEM, LAST); lr_end_transaction("图书搜索",LR_AUTO); return 0; }
LoadRunner lr_eval_string() 函数使用及LR中变量、参数的简单使用
http://blog.csdn.net/oobibigo/article/details/3321558
lr_eval_string()
函数的主要作用:返回脚本中的一个参数当前的值,
返回值类型:char
一般多用在调试脚本时输出参数的值.具体用法如下:
lr_output_message("The parameter1's value is %s",lr_eval_string("{parameter1}")),其中参数parameter1在之前已经定义了的参数
lr_log_message(lr_eval_string("{parameter1}"))
1.参数的赋值和取值
lr_save_string("hello world","param");
lr_eval_string("{param}");
2.变量到参数
int x;
x=10;
lr_save_string(x,"param");
lr_eval_string("{param}");
3.变量读参数
char x[100];
x="{param}";
lr_save_string("hello world","param");
lr_eval_string(x);
loadrunner 参数化文件读取问题解决
/*
loadrunner 参数化文件
http://dl2.iteye.com/upload/attachment/0098/8966/f2f50855-0699-3df3-bd8b-2b2b4e97833f.jpg
http://dl2.iteye.com/upload/attachment/0098/8976/a7baddd1-de47-353e-99cb-9b854f6f5d8c.jpg
*/
Action() { // 方法一,参数化文件A列+B列,同行取值但B列数据需要提交两次,char 指针位移即可 char *B1; char *B2; B1=lr_eval_string("{B}"); B2=lr_eval_string("{B}"); lr_output_message("A取值%s",lr_eval_string("{A}")); lr_output_message("B取值%s",B1); lr_output_message("B取值%s",B2); //方法二,参数化文件 A列+B列的test.dat数据文件改成A列+B1列+B2列test2.dat数据文件,同行取值,提交一次 //如图:http://dl2.iteye.com/upload/attachment/0098/8976/a7baddd1-de47-353e-99cb-9b854f6f5d8c.jpg lr_output_message("A取值%s",lr_eval_string("{A}")); lr_output_message("B取值%s",lr_eval_string("{B1}")); lr_output_message("B取值%s",lr_eval_string("{B2}")); // 空格快捷键 shift + tab // loadrunner注释快捷键 ctrl + alt + c // loadrunner取消注释快捷键 ctrl + alt + u // loadrunner 调用外部杀sap记事本进程函数命令: system("taskkill \/im \"SAPld.exe\""); return 0; }
loadrunner search cpc / yangyao 12090718 / 10.19.95.17
D:\TestCase\20140925_search\ad_cpc_storm_pre_201409190944\ad_cpc_storm_pre_201409190944.usr
Action() { static long pv=0; web_reg_find("Fail=NotFound", "Search=Body", "SaveCount=aa", "Text=jsonpCallback", LAST); web_set_max_html_param_len("9999999"); web_reg_save_param_ex( "ParamName=good", "LB=\"apsClickUrl\":\"", "RB=\",\"cmdPrice\"", "Ordinal=ALL", SEARCH_FILTERS, LAST); lr_start_transaction("tran_Search"); web_url("cpc_data.html", "URL=http://apscorepre.cns*****.com/getCpcDatas?keyword=iphone&positionID=100000001", //"URL=http://apssolrpre.cns*****.com/solr/cpcSearch/select?q=keyword:{keywords}&fq=status:1&fq=flag:true&fq=pushTime:2014-09-19&sort=product(price,qualityScore,query({!dismax+qf=keyword+v='{keywords}'},0.01))+desc,dayBudget+desc,createTime+desc&wt=json&group=true&group.field=sid", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t8.inf", "Mode=HTML", EXTRARES, LAST); lr_end_transaction("tran_Search", LR_AUTO); pv = pv + atoi(lr_eval_string("{good_count}"));// 统计行项目数 lr_output_message("%d",pv); return 0; }
D:\TestCase\20140925_search\ad_cpc_searchclick_201409191101\ad_cpc_searchclick_201409191101.usr
Action() { char *temp; char str[10]; web_reg_find("Fail=NotFound", "Search=Body", "SaveCount=aa", "Text=jsonpCallback", LAST); web_set_max_html_param_len("9999999"); web_reg_save_param_ex( "ParamName=goods", "LB=\"apsClickUrl\":\"", "RB=\",\"cmdPrice\"", "Ordinal=ALL", "NotFound=warning", SEARCH_FILTERS, LAST); lr_start_transaction("tran_Search"); web_url("cpc_data.html", "URL=http://apscorepre.cns*****.com/getCpcDatas?keyword=iphone&positionID=100000001", //"URL=http://apscorepre.cns*****.com/getCpcDatas?keyword={keyword}&positionID=100000001&inputCpcNumbers=13", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t8.inf", "Mode=HTML", EXTRARES, LAST); lr_end_transaction("tran_Search", LR_AUTO); if(atoi(lr_eval_string("{goods_count}"))!= 0){ temp=lr_paramarr_random("goods"); lr_save_string(temp,"str"); //lr_save_string(lr_paramarr_random("goods"),"str"); web_url("cpc_data.html", "URL={str}", "TargetFrame=xxxx", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t8.inf", "Mode=HTML", EXTRARES, LAST); } return 0; }
dd
Loadrunner C
loadrunenr 测试机内存泄露解决
http://dl2.iteye.com/upload/attachment/0103/4819/4660f773-44b3-300a-af15-d682a6830e6b.png
http://dl2.iteye.com/upload/attachment/0103/4821/478d0525-d51e-367b-9811-ad7678105d12.png
loadrunner测试机内存泄露原始脚本.zip
http://dl.iteye.com/topics/download/a439142b-e7bf-393c-b397-6bf26c7d12f3
loadrunner测试机内存泄露修改后脚本
D:\TestCase\20141121_b2c_search_click\tc_ad_cpc_searchclick_201409191101\tc_ad_cpc_searchclick_201409191101.usr
dd
- Action()
- {
- int num;
- char *temp; // 此处多余删除,压测时导致测试机内存泄露,
- char str[300];
- web_reg_find("Fail=NotFound",
- "Search=Body",
- "SaveCount=aa",
- "Text=jsonpCallback",
- LAST);
- web_set_max_html_param_len("9999999");
- web_reg_save_param_ex(
- "ParamName=goods", //抓到搜索页面里商品URL
- "LB=\"apsClickUrl\":\"",
- "RB=\",\"cmdPrice\"",
- "Ordinal=all",
- "NotFound=warning", // 商品搜索允许搜索不到数据
- SEARCH_FILTERS,
- LAST);
- lr_start_transaction("tran_Search");
- web_url("cpc_data.html",
- "URL=http://apscorepre.cns*****.com/getCpcDatas?keyword={keyword}&positionID=100000001&inputCpcNumbers=13&inputTime=20141111",
- //"URL=http://apscorepre.cns*****.com/getCpcDatas?keyword={keyword}&positionID=100000001&inputCpcNumbers=13",
- "TargetFrame=",
- "Resource=0",
- "RecContentType=text/html",
- "Referer=",
- "Snapshot=t8.inf",
- "Mode=HTML",
- EXTRARES,
- LAST);
- lr_end_transaction("tran_Search", LR_AUTO);
- //搜索50次点击1次
- if(atoi(lr_eval_string("{goods_count}"))!= 0){
- //countHaveGoods++;
- num = rand()%50 + 1; // 得到1-50的随机值
- if(num == 1){ //当随机到1时进行下面的点击操作业务
- //countClick++;
- temp=lr_paramarr_random("goods"); //此处多余删除,压测时导致测试机内存泄露
- lr_save_string(temp,"str"); //此处多余删除,压测时导致测试机内存泄露
- lr_save_string(lr_paramarr_random("goods"),"str");
- lr_start_transaction("click");
- web_url("cpc_data.html",
- "URL={str}", //抓到搜索页面里商品URL,然后点击
- "TargetFrame=xxxx",
- "Resource=0",
- "RecContentType=text/html",
- "Referer=",
- "Snapshot=t8.inf",
- "Mode=HTML",
- EXTRARES,
- LAST);
- lr_end_transaction("click", LR_AUTO);
- }
- }
- //lr_user_data_point("countClick/countHaveGoods",countClick*1.0/countHaveGoods);
- //lr_user_data_point("countClick",countClick);
- return 0;
- }
dd
end
相关推荐
标题中的“web test LoadRunner FTP / vsftpd / vsftp / WebUploader 0.1.5 / shangchuan”涉及到了多个IT领域的知识点,主要包括Web性能测试、FTP服务器、以及一个前端文件上传库WebUploader。现在我们将逐一深入...
标题中的"web test LoadRunner SAP / java / Java Vuser / web_set_max_html_param_len"涉及到的是性能测试领域,特别是使用HP LoadRunner工具进行Web应用程序的压力测试。LoadRunner是一款功能强大的性能测试工具,...
NULL 博文链接:https://lindows.iteye.com/blog/1725279
NULL 博文链接:https://lindows.iteye.com/blog/1209451
NULL 博文链接:https://lindows.iteye.com/blog/1266180
标题“web test LoadRunner fuction_list”涉及到的是使用LoadRunner进行Web测试的相关知识,特别是关于LoadRunner中的函数列表。LoadRunner是一款由Micro Focus公司开发的性能测试工具,它能够模拟大量用户并发执行...
标题“web test / docs / QA”表明这是一组与Web应用程序测试、文档和质量保证相关的资源。这可能包括测试策略、测试用例、文档规范以及可能的自动化测试工具的使用。描述中的“NULL”没有提供额外的信息,但我们...
7. **高级特性**:最后,教程会涉及LoadRunner的一些高级功能,如分布式测试、Web服务测试、数据库性能监控、协议扩展等,以满足更复杂的测试需求。 总的来说,"LoadRunner11-中文教程.pdf"是一个全面而深入的学习...