How to Generate Random Passwords with Alphanumeric and special characters ?

     char charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+";

  //  int passwordLength = 10; // Change this value to set the desired length of the password
    char generatedPassword[10 + 1];
    int i;

    lr_save_string("""GeneratedPassword"); // Clear any previous values

    // Generate random characters for the password
    for (i = 0; i < 10; i++) {
        int index = rand() % (sizeof(charset) - 1);
        generatedPassword[i] = charset[index];
    }

    generatedPassword[10] = '\0'// Null-terminate the string

    lr_save_string(generatedPassword, "GeneratedPassword"); // Save the generated password as a parameter

    lr_output_message("Random password: %s", generatedPassword);

Modify Common Parameters in Multiple Scripts Using Additional Attributes

 Problem statement: Your performance regression scenario contains 20 different Loadrunner scripts. You run this scenario a number of times in a given release.For simplicity, let’s assume that all scripts are developed using web services protocol. There may or may not be any changes to the scripts but version of the service endpoint changes a lot of times. For example, from version R200 to version R300

From http://ServerName:Port/R200/CustomerDataManagement.svc
To http://ServerName:Port/R300/CustomerDataManagement.svc

How to modify all the endpoints to have latest version, possibly without opening the scripts?

Solution 1: One trivial solution which would come to everyone’s mind is to create a parameter, say pEndpointVersion, and use that in the URL as shown below

http://ServerName:Port/{pEndpointVersion}/CustomerDataManagement.svc

Drawback: You will have to update the parameter value every time the endpoint version changes. Thus, you will have to download, open and update the parameter in all the scripts. This activity is very time consuming especially when it comes to VUGEN 11.52 as we all know how slow it is for opening scripts. Have a look a solution 2.

Solution 2 (preferred): In your script, go to RunTime Settings(RTS) under ‘Additional Attributes’, add a new argument name and a argument value. For example: argument name ‘EndpointVersion’ with argument value ‘R300’.

RTS-Additional Attributes Option

Then use the statement lr_get_attrib_string(“<Argument Name>“) to retrieve the argument value. In our example, use lr_get_attrib_string(“EndpointVersion“) to retrieve the value ‘R300’.

You can output the value like this

lr_output_message("*******version: %s"lr_eval_string(lr_get_attrib_string("EndpointVersion")));

OR save it into a parameter via lr_save_string() and access it anywhere in the script using the parameter name. For example,

lr_save_string(lr_get_attrib_string(("EndpointVersion")),"rVersion");

The endpoint will look like http://ServerName:Port/{rVersion}/CustomerDataManagement.svc
Example:

lr_output_message("*******version: %s"lr_eval_string(lr_get_attrib_string("EndpointVersion")));
lr_save_string(lr_get_attrib_string(("EndpointVersion")),"rVersion");

Output
Action.c(25): *******version: R300
Action.c(27): Notify: Saving Parameter “rVersion = R300”.

Benefit: If the endpoint version changes, you can modify the RunTime Settings (RTS) for all the scripts in the scenario in Performance Center itself. You don’t need to open and update it in individual scripts. If all the scripts use same RTS, then it’s even easier. Just modify RTS of one script and duplicate the RTS to rest of the scripts. Following screenshot shows the location of ‘Duplicate Runtime Settings’ option in Performance Center.

Duplicate RTS

In Truclient protocol script, the function is LR.getLRAttr(“<attrib_name>”);

Refer for details: VUGEN help > VuGen > Protocols > Ajax TruClient Protocol > Enhancing Ajax TruClient Scripts > Ajax TruClient Functions

Hope it helps to someone!

LoadRunner checks Previous HTTP request i.e. (HTTP 200

 Whenever server responds to the clients request then with the response code it sends HTTP 200 i.e.

The request was fulfilled.

Suppose we want to check the status of the returncode from  the server

int web_get_int_property ( const int HttpInfoType );

The above syntax returns specific information about previous HTTP request.

1. The meaning of the return value depends on the HttpInfoType argument.

2.HttpInfoType can be of any options like Returncode,Download Size,Download time.

How to use this function ::

Action()
{
int HttpRetCode;
lr_start_transaction(“Load_File”);

web_reg_find(“Text=My Workplace”,
LAST);

web_url(“LoadFile.jsp”,
“URL=http://servername/Workplace/LoadFile.jsp”,
“Resource=0”,
“RecContentType=text/html”,
“Referer=”,
“Snapshot=t1.inf”,
“Mode=HTML”,
LAST);

HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);

if (HttpRetCode == 200)

lr_log_message(“The script successfully accessed the Load page”);

else

lr_log_message(“The script failed to access the Load page “);

lr_end_transaction(“Load_File”,LR_AUTO);

return 0;
}

output :: You will find the desired output at the Replay log pane on the vugen