sample LoadRunner script that demonstrates how to use lr_think_time()

sample think time script

Scenario: User logs in, searches for a product, then logs out

🧾 Script with Think Time Example

Action()

{

    // Start Login transaction

    lr_start_transaction(“Login”);

    web_submit_data(“login”,

        “Action=http://example.com/login”,

        “Method=POST”,

        ITEMDATA,

        “Name=username”, “Value=user1”, ENDITEM,

        “Name=password”, “Value=pass123”, ENDITEM,

        LAST);

    lr_end_transaction(“Login”, LR_AUTO);

    // Add think time (user is reading the page or thinking)

    lr_think_time(5);  // Wait 5 seconds

    // Start Search transaction

    lr_start_transaction(“Search”);

    web_url(“search”,

        “URL=http://example.com/search?q=laptop”,

        “TargetFrame=”,

        “Resource=0”,

        “RecContentType=text/html”,

        “Mode=HTTP”,

        LAST);

    lr_end_transaction(“Search”, LR_AUTO);

    // Add another think time

    lr_think_time(3);  // Wait 3 seconds

    // Start Logout transaction

    lr_start_transaction(“Logout”);

    web_url(“logout”,

        “URL=http://example.com/logout”,

        “TargetFrame=”,

        “Resource=0”,

        “RecContentType=text/html”,

        “Mode=HTTP”,

        LAST);

    lr_end_transaction(“Logout”, LR_AUTO);

    return 0;

}