使用loadrunner進行效能測試(四)--檢查點設定
阿新 • • 發佈:2018-12-31
action{ int HttpRetCode; web_url("login", "URL=http://www.163.com", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", LAST); HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE); lr_output_message( "HTTP_INFO_RETURN_CODE %d",HttpRetCode); //Check HttpRetCode if (HttpRetCode == 200) { lr_log_message("The script successfully accessed the login page"); } else { lr_log_message("The script failed to access the login page "); } } 通過跳轉頁面的內容進行校驗。 使用web_reg_find函式。 遇到需要用中文校驗時,有兩種方法解決:一是設定錄製時的格式為utf-8;二是通過lr_convert_string_encoding 函式轉化需要校驗的內容格式。 Action() { lr_start_transaction("tvtaobaologin"); web_reg_find("Text=四川電信-華為承接頁", "SaveCount=loginTextCount", LAST); //web_set_option("MaxRedirectionDepth", "2", LAST ); web_url("login", "URL=http://登入的url", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", LAST); // Check login result lr_output_message( "We are on iteration %s", lr_eval_string("{loginTextCount}")); if (atoi(lr_eval_string("{loginTextCount}")) > 0){ lr_output_message("Log on successful."); } else{ lr_error_message("Log on failed"); return 0; } lr_end_transaction("tvtaobaologin",LR_AUTO); }