While not done loop in Loadrunner


Loadrunner
Below is the scenario in which a request will be executed based on the while not done loop.

Code:

//While not done loop
while(!flag)
{

//Text check

web_reg_find("Search=Body", "SaveCount=PendingCounter", "Text=Pending", LAST);


//Request to be executed

web_url("IZ7_N2M81BG0K87C60AQE01L2O00M1=CZ6_N2M81BG0K87C60AQE01L2O0062=MEjavax.servlet.include.path_info!QCP_rlvid.jsp=_rvip!QCPBBDMyReportsView.jsp=_rap!ReportListBean.refresh=com.ibm.faces.portlet.mode!view==",
"URL=https://XXXXXX/wps/myportal/BBD/Home/bbdRptUserActivity/!ut/p/z1/{R6_1}/dz/d5/{L2_1}/p0/IZ7_N2M81BG0K87C60AQE01L2O00M1=CZ6_N2M81BG0K87C60AQE01L2O0062=MEjavax.servlet.include.path_info!QCP_rlvid.jsp=_rvip!QCPBBDMyReportsView.jsp=_rap!ReportListBean.refresh=com.ibm.faces.portlet.mode!view==/",
"Resource=0",
"RecContentType=text/html",
"Referer=https://XXXXXX/wps/myportal/BBD/Home/bbdRptUserActivity/!ut/p/z1/{R3_1}/",
"Snapshot=t121.inf",
"Mode=HTTP",
LAST);


//IF Block - condition

if(atoi(lr_eval_string("{PendingCounter}")) > 0)
{
flag = 0;

}
else
flag = 1;
}

Code Explained:

1. In the web_reg_find we are searching for the text 'Pending' and saving the text count in the variable 'PendingCounter'.

2. We are extracting the value from 'PendingCounter' using lr_eval_string and converting the string into integer using atoi function and passing the value as input to the IF Block.

3. If the text check is positive, IF Block will have value greater than 0 and the statement flag = 0 will be executed.
So the while condition becomes while(!0) == while(1) which is true and the request will be executed.

4.  If the text check is negative, IF Block will have value less than 0 and the statement flag = 1 will be executed.
So the while condition becomes while(!1) == while(0) which is false and the request will not be executed.



No comments:

Post a Comment