lr_abort function in loadrunner with examples

Lr_abort function is used to exit the actions section in vugen if any error occurs and executes vuser_end action and comes out of the execution.

For example, if you are running the load test with 100 users and script fails with text check or response code error.

you call the lr_abort function to make the user come out the execution and you end up running the load test with only 99 users.

Example 1:

In this example, user is visiting bing.com and if the page is not loaded because of 500 response code error and the user will come out of it.

int ServerResponseCode;
    
lr_start_transaction("BingHomePage");
web_url("www.bing.com",
"URL=http://www.bing.com/",
"Mode=HTML",
LAST);
ServerResponseCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
if (ServerResponseCode=500)
{
lr_abort();
}

Example 2:

In this example, user tries to login to bing.com and it fails, if the login is failed the user will abort the execution and comes out the execution. This logic works based on lr_pass or lr_fail.

int RequestStatus;
RequestStatus = web_url("Login",
          "URL=https://bing.com//login.asp?user=(username)&password={password}", 
          "RecContentType=text/html", LAST );

if (RequestStatus == LR_FAIL) {
    lr_error_message("Login Failed");
        lr_abort();
}

For more examples, please all the list of loadrunner functions.

Leave a Comment