Blog

  • LoadRunner Run-Time Settings: Additional Attributes

    Posted on August 27, 2012 by Admin

    Many times I want to set up Vugen scripts so that I can easily move from one environment to another. Often, the environment being tested if not the same one I script in because of logistics in getting the environments ready. Without getting into the issue of poor configuration management between environments screwing up your scripts – and most LoadRunner scripters know how bad of a problem this is –  I wanted to demonstrate the use of the “Additional Attributes” run-time setting to easily change environments without changing the Read Entire Entry

  • VuGen Custom Function: Right

    Posted on August 22, 2012 by Admin

    Today’s posting comes courtesy of Brian Wilson of TechSouth Consulting. This is a completely working example of Right() (rightmost characters) just like you can do in VB. I’d create a library of functions like this in a header (.h file) and include them in your scripts where you’re doing string manipulation.
    char* Right(char* String, char* TempBuffer, int Nr)
    {
    if(strlen(String) >= Nr)
    {
    strcpy(TempBuffer, &String[strlen(String) – Nr]);
    TempBuffer[Nr] = ‘\0’;
    return TempBuffer;
    }
    else return Strin Read Entire Entry

  • VuGen Custom Function: Left() (leftmost characters)

    Posted on August 20, 2012 by Admin

    Today’s code is courtesy of Brian Wilson of TechSouth Consulting. This is a completely working example of a VuGen Left() (leftmost characters) function, just like you can do in VB. I’d create a library of functions like this in a header (.h file) and include them in your scripts where you’re doing string manipulation.
    char* Left(char* String, char* TempBuffer, int Nr)
    {
    if(strlen(String) >= Nr)
    {
    strcpy(TempBuffer, String);
    TempBuffer[Nr] = ‘\0’;
    return TempBuffer;
    }
    else return String;
    }

    int vuser_ini Read Entire Entry

  • Vugen: RTE Custom Function – CheckForErrors()

    Posted on August 15, 2012 by Admin

    Today’s updated comes courtesy of Brian Wilson of TechSouth Consulting. This is a function for the RTE protocol called CheckForErrors(). It checks for specific errors and returns the application state to the initial iteration state. Use this as a starting point to create your own conditions to check for, as the ones here are specific to the application being tested at the time. The point here is to demonstrate the stricmp function to check for various condition matches.
    Usage : CheckForErrors()
    CheckForErrors(int icount)
    {
    char Read Entire Entry

  • Vugen: Writing To An External Log File

    Posted on August 13, 2012 by Admin

    Writing information to the Vugen execution log file is pretty basic stuff, but what happens when you need to write data to an external log file on your the local drive? I can think of a few reasons you might want to do this, but there are a couple of ways I have found using some basic ANSI C code, and I keep this handy in case I ever need it.
    This first example prototypes the memset function at the beginning of the init section.
    That would look like this:

    extern int memset (char *, int, int);
    Declare some variables needed at the to Read Entire Entry

  • Vugen: Loop Through An Array Of Parameters

    Posted on August 13, 2012 by Admin

    I had a situation where I needed to find a specific record within a list. The web page had a list of 300 orders, and I had to find an order with a matching status of “NONE” based on some text displayed. The first thing I had to do was capture all the statuses and put them into an array, and then find a match.
    To get the statuses into an array, I used the ORD=ALL argument with the web_reg_save_param function:

    // Get all 300 orders displayed on this HTML page
    web_reg_save_param(“statusA”,
    “LB=&orderStatus=”,
    Read Entire Entry

  • Vugen: RTE Protocol Wait/Polling Routine

    Posted on August 8, 2012 by Admin

    While it isn’t the most popular protocol out there, RTE (terminal emulation) continues to serve a need for those testing against “green screen” apps, AS400’s, etc…There are times where you may be waiting on a particular string of text to show up on a screen. You may want to continue polling until the text is there. The script below gives you one idea of how to do this. Note that the X/Y coordinates and field length will be different based on your screen and what you are looking for.

    int rc, i;
    char match[80];

    // Grab some tex Read Entire Entry

  • Vugen: Old School Random Selections With srand

    Posted on August 6, 2012 by Admin

    At the beginning of your script where you declare variables, seed time() with the srand() function:
    char buffer[80];
    int TotalNum, RandNum, i;
    srand(time(NULL));
    Here is how you might use this. Let’s say you need to use a random selection from a web page. This might be a different check box or drop down selection and you want it to be random each time:
    //First grab the total count of items to choose from using ORD=ALL

    web_reg_save_param(“pCapture”, “LB=something”,
    “RB=something else”, “Ord=All”, LAST);

    web_submit_data(“BLINGBLING”, Read Entire Entry

  • Vugen: Manipulate The Date

    Posted on August 1, 2012 by Admin

    When using the lr_save_datetime function, you may want to advance or decrement more than one day, you have to multiply by the number of days.
    Example code:

    // Display Current Date Only
    lr_save_datetime(“%m/%d/%Y”,DATE_NOW,”Currdate”);
    lr_output_message(“Current Date: %s”,lr_eval_string(“{Currdate}”));

    // Subtract 30 days from current date
    lr_save_datetime(“%m/%d/%Y”, DATE_NOW – (ONE_DAY*30), “Startdate”);
    lr_output_message(“Previous 30 Days: %s”,lr_eval_string(“{Startdate}”));

    // Advance 30 days from curre Read Entire Entry

  • Vugen: Read A File Stream For Validation

    Posted on July 30, 2012 by Admin

    In this example we are running tasklist.exe in windows to check the existence of a process by looking at the first 13 characters in the file.

    checkprocess()
    {
    char command[1024];
    int i, total = 0;
    char buffer[12], ch;
    char *filename = lr_eval_string(“C:\\tasklist_{pTime}.txt”);
    long file_stream;

    //Run a system command to open up a DOS prompt and tasklist
    //Save it to a file

    sprintf(command, “tasklist /FI \”IMAGENAME eq MobileEngine.exe\”
    /FI \”STATUS eq running\” /FO TABLE /NH > %s”, filename);
    sys Read Entire Entry