Krishna Logo
Divied
Call: Sana @ (571) 386-2972

 

Loading
Latest News
Home Navigation Divied
INTERVIEW Navigation Divied LOADRUNNER Navigation Divied How to Handle Erro and Re-submiting the same Web_URL_Request
How To Handle Erro And Re-submiting The Same Web_URL_Request
How to Handle Erro and Re-submiting the same Web_URL_Request

HOW TO HANDLE ERRORS AND RE-SUBMITTING THE SAME  WEB_URL REQUEST

// Declare integers
int HTTP_rc, retry_count;

/*
* This section includes the page request statement and switches on the
* continue on error functionality, for this step only.
*/
for (retry_count = 0; retry_count < 5; retry_count++)
{
lr_start_transaction("Transaction_Name");

lr_continue_on_error(1);
web_url("Index.htm",
"URL=http://webpage.server.co.uk/cgi-bin/gen001_serverselect.dll",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
lr_continue_on_error(0);

// Captures the HTTP_rc
HTTP_rc = web_get_int_property(HTTP_INFO_RETURN_CODE);

// Condition statement: if less than 400 end transaction and carry on with rest of script
if (HTTP_rc < 400)
{
lr_end_transaction("Transaction_Name", LR_PASS);
lr_log_message("Index page displayed after %i attempts", retry_count +1);
break;
}

/*
* Condition statement: if equals 503 and retry_count is less than 4, wait for 5secs
* before logging a message confirming that page is not available and what attempt you are on
* NOTE: HTTP 503 = Server is busy
*/
else if (HTTP_rc == 503 && retry_count < 4)
{
lr_end_transaction("Transaction_Name", LR_STOP);
sleep(5000);
lr_log_message("Index page not available, retrying attempt %i", retry_count +1);
continue;
}

/*
* Condition statement: End Transaction. If HTTP error equals 503, log a message confirming
* that the page is not available and what HTTP error you received, i.e. 404 (Page not found)
* Finally, the last line exits the current iteration and fails this iteration.
*/
else
{
lr_end_transaction("Transaction_Name", LR_FAIL);
if (HTTP_rc == 503) lr_log_message ("Index page not available, no retry attempts left");
else lr_error_message("Index page failed, HTTP error %i received", HTTP_rc);
lr_exit(LR_EXIT_ITERATION_AND_CONTINUE, LR_FAIL);
}

}


Shadow Bottom
 
 
© 2005 - 2018 Krishna Training.
Designed & Developed By BitraNet