標籤:
效能需求:在列表中刪除後有記錄,或對列表中的每條記錄進行操作(如點擊每條記錄的“單號”進入訂單詳情頁面,或在列表中對每條記錄進行“啟用”、“停止”操作)
舉例:Vuser指令碼類比使用者在訂單列表中點擊每條記錄的“單號”進入訂單詳情頁面進行處理,處理後該記錄的狀態會發生變化,此時,如果又有另外的虛擬使用者進入訂單列表對同一條訂單記錄進行同樣一操作時,頁面會提示(該記錄已處理)導致後面的指令碼關聯失敗,運行情境也會報錯,那麼,就需要在LR指令碼中除了做參數化和關聯外,還需要實現翻頁尾本(假設列表每頁顯示10條記錄),並在每頁中做文本檢查點(“訂單號”),對列表所有的記錄進行遍曆的操作。
這裡是在本地環境中實現列表翻頁尾本,並在每頁做文本檢查點,
系統列表介面,
實現代碼,如下:
Action2(){ int i; int temp = 1; char str[205]; lr_think_time(6); web_reg_find("Text=101036", "SaveCount=modify_Count", LAST); web_url("admin_list", "URL=http://localhost:8088/spring-ssh/admin/admin_list", "Resource=0", "RecContentType=text/html", "Referer=http://localhost:8088/spring-ssh/index", "Snapshot=t3.inf", "Mode=HTML", EXTRARES, "Url=../images/navigation.png", ENDITEM, "Url=../images/index_out.png", ENDITEM, "Url=../images/search.png", ENDITEM, "Url=../images/body_bg.png", ENDITEM, "Url=../images/fee_out.png", ENDITEM, "Url=../images/role_out.png", ENDITEM, "Url=../images/bill_out.png", ENDITEM, "Url=../images/admin_out.png", ENDITEM, "Url=../images/top_bg.png", ENDITEM, "Url=../images/account_out.png", ENDITEM, "Url=../images/information_out.png", ENDITEM, "Url=../images/password_out.png", ENDITEM, "Url=../images/btn_bg.png", ENDITEM, "Url=../images/report_out.png", ENDITEM, "Url=../images/modification.png", ENDITEM, "Url=../images/warning.png", ENDITEM, "Url=../images/service_out.png", ENDITEM, "Url=../images/delete.png", ENDITEM, "Url=../images/admin_on.png", ENDITEM, LAST); //共有205頁,遍曆每一頁面 for(i=1;i<=205;i++){ //如果在該頁找到檢查點,則退出迴圈 if(atoi(lr_eval_string("{modify_Count}"))>0){ lr_output_message("在第%d頁面已找到檢查點",temp);//1,2,3 return -1; }else{ //在每頁做文本檢查點 web_reg_find("Text=101036", "SaveCount=modify_Count", LAST);temp = 1+i;//將int類型轉換為string類型,以10進位儲存itoa(temp,str,10); lr_save_string(str,"next"); //點擊下一頁 web_submit_data("admin_list", "Action=http://localhost:8088/spring-ssh/admin/admin_list?page={next}", "Method=POST", "RecContentType=text/html", "Referer=http://localhost:8088/spring-ssh/admin/admin_list", "Snapshot=t4.inf", "Mode=HTML", ITEMDATA, "Name=privilegeId", "Value=0", ENDITEM, "Name=roleName", "Value=", ENDITEM, EXTRARES, "Url=../images/body_bg.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/search.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/top_bg.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/role_out.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/index_out.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/navigation.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/fee_out.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/account_out.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/admin_out.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/bill_out.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/service_out.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/modification.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/delete.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/information_out.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/report_out.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/btn_bg.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/warning.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/password_out.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, "Url=../images/admin_on.png", "Referer=http://localhost:8088/spring-ssh/admin/admin_list?page={page}", ENDITEM, LAST); } } return 0;}
LR翻頁尾本並在每頁實現業務操作