Showing posts with label LoadRunner. Show all posts
Showing posts with label LoadRunner. Show all posts

QTP Videos & LoadRunner Videos


HP QTP (QuickTest Professional) Videos:

1QTP video tutorial - How to record QTP scriptQTP video tutorial - How to record QTP script

The present QTP (QuickTest Pro) video tutorial covers the following:
  • How to record QTP script for Web applications
  • What record and run settings should be used to run and execute QTP script
  • How to replay/execute QTP script
  • How to get results of executed QTP script
  • How to enable capturing screenshots during QTP scipt replaying
  • How to enable capturing video during QTP scipt replaying
2QTP video tutorial - How to capture dynamic textQTP video tutorial - How to capture dynamic text

The present QTP (QuickTest Pro) video tutorial covers the following:
  • How to use QTP to capture text from the page
  • Settings from QTP 'Output Text Value Properties'
  • Explanation for QTP Output value
  • Explanation for left & right boundaries
  • How to save QTP Output text value into QTP DataTable
  • Differences between Global and Local QTP DataTable sheets
  • How to read value from QTP DataTable
3QTP video tutorial - QTP DatatableQTP video tutorial - QTP Datatable

This QTP video shows how to work with DataTable.
You will learn different QTP DataTable concepts:
  • How to create QTP DataTable parameter using QTP Data Driver
  • How to create QTP DataTable parameter manually
  • How to read/write values from/to QTP DataTable
  • QTP script and DataTable execution settings
  • Global and local (action) sheets of DataTable
  • QuickTest Professional data-driven tests
4QTP video tutorial - QTP RegExp and dynamic link in QTPQTP video tutorial - QTP RegExp and dynamic link in QTP

This QTP video tutorial covers the following:
  • working with QTP Object Repository
  • identification properties of QTP objects
  • QTP RegExp in object's properties
  • how QTP identifies objects in application
  • and others...
5QTP video tutorial - QTP Descriptive ProgrammingQTP video tutorial - QTP DP (Descriptive Programming)

This QTP video shows and explains concepts of QTP Descriptive Programming:
  • What is QTP Descriptive Programming?
  • How to pass properties and their values directly to test object?
  • How to pass properties and their values using Description object?
  • How to select Descriptive Programming properties of a test object?
  • How t0 oconvert usual QTP script into QTP Descriptive Programming script?
  • How to debug QTP DP?
  • Different secrets of QTP Descriptive Programming
6QTP video tutorial - How to run QTP test from command lineQTP video tutorial - How to run QTP test from command line

Do you run your QTP tests suit manually?
What about running them on the schedule, for example nightly testing?

I will show the way how to do that - i.e. how to run QTP tests from command line.
Using that approach, you can execute your QTP tests on the schedule.
7QTP video tutorial - QTP Recovery ScenarioQTP video tutorial - QTP Recovery Scenario

This QTP video shows and explains how to create and work with QTP Recovery Scenarios.

For example, during an execution of QTP test, it can be interrupted by different windows, pop-ups, message boxes, etc. The problem is that they can appear at any time and you cannot predict these events.

QTP provides Recoverry Scenarios to process such unexpected events and errors.


HP LoadRunner Videos:
1LoadRunner video tutorial - Automated Correlation in LoadRunnerLoadRunner video tutorial - Automated Correlation in LoadRunner

Correlation is a key concept of HP LoadRunner. The present LoadRunner video tutorial explains how to correlate dynamic values in LoadRunner automatically:
  • How to find dynamic values to be correlated
  • How to compare recorded & replayed dynamic values
  • How to correlate them in LoadRunner
  • How to verify correlation
2LoadRunner video tutorial - Manual Correlation in LoadRunnerLoadRunner video tutorial - Manual Correlation in LoadRunner

The present LoadRunner video explains how to manually correlate dynamic values:
  • How to find dynamic values in a server response
  • How to correlate them in LoadRunner
  • How to verify the LoadRunner correlation manually
  • How to use LoadRunner correlation functions
3LoadRunner video tutorial - LoadRunner Parameters, part #1LoadRunner video tutorial - LoadRunner Parameters,
part 1 of 3 (Select next row = Sequential)


The present LoadRunner video tutorial covers the following:
  • How to create new LoadRunner parameter
  • How to use 'Simulate Parameter' feature
  • Settings on Parameter List dlg:
    Option 'Select next row' = 'Sequential'
    Option 'Update value on' = 'Each iteration'
    Option 'Update value on' = 'Each occurrence'
    Option 'Update value on' = 'Once'
  • How to view an output value of parameter
4LoadRunner video tutorial - LoadRunner Parameters, part #2LoadRunner video tutorial - LoadRunner Parameters,
part 2 of 3 (Select next row = Random)


The present LoadRunner video tutorial covers the following:
  • How to create new LoadRunner parameter
  • Settings on Parameter List dlg:
    Option 'Select next row' = 'Random'
    Option 'Update value on' = 'Each iteration'
    Option 'Update value on' = 'Each occurrence'
    Option 'Update value on' = 'Once'
  • How to view an output value of parameter
5LoadRunner video tutorial - LoadRunner Parameters, part #3LoadRunner video tutorial - LoadRunner Parameters,
part 3 of 3 (Select next row = Unique)


The present LoadRunner video tutorial covers the following:
  • Settings on Parameter List dlg:
    Option 'Select next row' = 'Unique'
    Option 'Update value on' = 'Each iteration'
    Option 'Update value on' = 'Each occurrence'
    Option 'Update value on' = 'Once'Option 'When out of values' = 'Abort Vuser'Option 'When out of values' = 'Continue in a cyclic manner'Option 'When out of values' = 'Continue with last value'
    'Allocate Vuser values in the Controller'
  • How to view an output value of LoadRunner parameter
6LoadRunner video tutorial - How to capture the whole Web pageLoadRunner video tutorial - How to capture the whole Web page

This LoadRunner video tutorial shows how to capture Web page.
Using this approach, you can get HTML source code of any Web page and then downloade it to a local file.
7LoadRunner video tutorial - How to record a file saving in LoadRunnerLoadRunner video tutorial - How to record a file saving in LoadRunner

In some cases, we need to save PDF (or other) file on local disk and process it (edit, parse, or compare with 'etalon' file).

The present LoadRunner video tutorial explains how to record PDF file saving in LoadRunner.
8LoadRunner video tutorial - How to check a downloaded fileLoadRunner video tutorial - How to check a downloaded file

Do you know how to check that a file or a page was downloaded successfully in LoadRunner?
The present LoadRunner video tutorial explains how to do that.

There is an easy and practical approach.


Dear readers, as you can see, I performed a huge work to prepare these videos.
In general, it took me ~ 60 hours for each video:
  • to think up examples (they should be simple)
  • to develop a scenario of video tutorial (I prefer logical and 'step-by-step' scenarios)
  • to record video (actually, not easy task)
  • to make, edit, check and recheck, and then again to remake movie (it should be ideal!)

I think, that my readers should get the perfect QTP and LoadRunner video tutorials. And I create such video tutorials.
That's why I ask you to help me - please, make donations. Your donation will mean that my videos were useful fot you and I'll be glad that you learnt something new.

It will motivate me to make new, even better videos!






Related articles:

--
Dmitry Motevich

Manual Correlation in LoadRunner - Video

In previous LoadRunner video (Automated Correlation in LoadRunner) I shown how to use Automated Correlation. The present LoadRunner video explains how to manually correlate dynamic values:
  • How to find dynamic values in a server response
  • How to correlate them in LoadRunner
  • How to verify the correlation
There is a screenshot from the present LoadRunner video:
Manual Correlation in LoadRunner

Automated Correlation in LoadRunner - Video

Correlation is a key concept of HP LoadRunner. The present LoadRunner video tutorial explains how to correlate dynamic values in LoadRunner automatically:
  • How to find dynamic values to be correlated
  • How to compare recorded & replayed dynamic values
  • How to correlate them in LoadRunner
  • How to verify correlation
There is a screenshot from the present LoadRunner video:
Different server responses
Also, this LoadRunner video explains concepts of Correlation and how Correlation works.
Video tutorial demonstrates LoadRunner Correlation by the example of HP Web Tours application, which is shipped with LoadRunner. So, you can repeat and learn all shown actions yourself.

Automated Correlation in LoadRunner - Video


Related articles:


Do you like these LoadRunner video? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? Video guide)



Do you
know that you are free to use/copy/publish all my materials on your site/blog?


LoadRunner video - How to check manually a downloaded file

Do you know how to check that file or page was downloaded successfully in LoadRunner?
The present LoadRunner video tutorial explains how to do that. All you need is to check LoadRunner snapshot files (inf-files) located in LoadRunner script folder:
LoadRunner script files
LoadRunner video - How to check manually a downloaded file




Related articles:


Do you like this LoadRunner video tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? Video guide)




Do you know that you are free to use/copy/publish all my materials on your site/blog?


LoadRunner video - How to capture the whole Web page?

This LoadRunner video tutorial shows how to capture Web page.
Using this approach, you can get HTML source code of any Web page and then downloade it to a local file.

LoadRunner video - How to capture the whole Web page?


There is a final LR script for capturing and saving Web page:
int hFile;
char *szFileName = "c:\\page.html";

//Mark that we will capture the whole body of Web page
//Note: Mark that web_reg_save_param should be placed *before* web_url
web_reg_save_param("prmPage", "LB=", "RB=", "Search=Body", "RelFrameID=1", LAST);

web_url("labs.google.com", "URL=http://labs.google.com/", LAST);

//Web page has been captured, so print it out
lr_output_message("Page is: \r\n%s", lr_eval_string("{prmPage}"));

//Truncate to zero length or create file for writing.
if ((hFile = fopen(szFileName, "wb")) == NULL)
{
    lr_error_message("Cannot open %s", szFileName);
    return LR_FAIL;
}

//Write captured Web page to an output file
fprintf(hFile, "%s", lr_eval_string("{prmPage}"));

//Close the file pointer.

fclose(hFile);


Related articles:


Do you like this LoadRunner video tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? VIDEO guide)



LoadRunner unique file name with web_save_timestamp_param function

Earlier, I shown two ways how to create unique file names in LoadRunner:

Today I'm going to show the simplest way. And I would like to thank Charlie for his comment.
He suggested to use web_save_timestamp_param function.

web_save_timestamp_param function saves the current timestamp to LoadRunner parameter. Timestamp is the number of milliseconds since midnight January 1st, 1970 (also known as Unix Epoch).

This is how web_save_timestamp_param works:
web_save_timestamp_param("TimeStamp", LAST);
lr_output_message("Timestamp: %s", lr_eval_string("{TimeStamp}"));

And the result is:
Results in LoadRunner Generator
As I explained in this loadRunner tutorial about unique file names in LoadRunner, we have to get unique ids per virtual users with lr_whoami LoadRunner function.

So, the final LoadRunner script is:
char szFileName[256];
int vuserid, scid;
char *groupid;

lr_whoami(&vuserid, &groupid, &scid); web_save_timestamp_param("TimeStamp", LAST);

sprintf(szFileName, "%s_%d_%d_%s",
    lr_eval_string("{TimeStamp}"),
    vuserid,

    scid,

    groupid);


lr_output_message("File name: %s", szFileName);
And its result is from LoadRunner Controller:
Results in LoadRunner ControllerSo, you can add a required file extension (txt, pdf, etc) and get a unique file name. It will work for any number of concurrent virtual users in LoadRunner Controller.


Summary:
  • Shown the way how to generate unique file names in LoadRunner
  • It uses web_save_timestamp_param function


Related articles:


Do you like this LoadRunner tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? VIDEO guide)




Do you know that you are free to use/copy/publish all my materials on your site/blog?


LoadRunner Analysis - tabbed world

Do you like this dialog from LoadRunner Analysis? Not too many tabs? :)
LoadRunner Analysis - tabsNo words!
It seems, HP should hire a professional UI designer :)



Related articles:


Do you
know that you are free to use/copy/publish all my materials on your site/blog?


Bugs in LoadRunner

Watch for my logic please:
  • Each program contains errors (bugs).
  • LoadRunner is a program too.
  • So, LoadRunner should contain bugs.
    Even more! LoadRunner contains bugs.

Here is a list of bugs in LoadRunner 9.10 that I noticed.
And I would like to ask you to share your experience on LoadRunner too. I'm sure that you faced with such errors.


Why do I do that?

  • I know, that some members of LoadRunner development team read this blog. So dear readers, you can report errors and make your favourite (I hope :)) LoadRunner better.
  • Also, there is another reason to post LoadRunner bugs. Since you are QA specialists, I think it will be interesting to find bugs in a released commercial product (= LoadRunner).
    Prove, that you are qualified bugs hunters! :)
#
Description
11. LoadRunner Controller
2. Open Design tab
3. Double-click any action from 'Global Schedule' section
-> 'Edit Action' dlg is opened. OK
4. Click 'Help'
-> Nothing happens
'Help' btn doesn't work
21. Open LR Controller Help pdf-file, page 77.
2. It contains the phrase:
The following additional right-click options are available:
Reset IDs. Resets the IDs of the Vusers in the group.

Actually, menu item is named as "Renumber":
'Renumber' menu item
31. Open LoadRunner VuGen
2. Record and replay script
3. Open 'Tree view'
4. Select 'Response' item from tree view
-> 'Create Parameter' menu item is disabled, see:
5. Select 'Body' item from tree view
-> 'Create Parameter' menu item is enabled, see:
I think, 'Create Parameter' menu item should be enabled in both cases.
41. Open LoadRunner VuGen
2. Create new LR parameter
3. Open 'Parameter Simulation' dlg
-> There are not 'short keys' (underlined letters for quick access with keyboard):

5Could you send yours, dear reader?..


I think, the list of LoadRunner bugs is an interesting challenge for LoadRunner users community.
And definitely - it will be usefull for all of us.


That's why I ask you to send your
notes about LoadRunner bugs. Send detailed info and do not forget to mention your name. The world should know best testers :)

Please, send your notes about LoadRunner bugs or enhancements to my email: Dmitry Motevich's email
If you have any interesting ideas, feel free to share them.


Thank you in advance, dear readers.
Dmitry Motevich

P.S. Dear HP, may I join your LoadRunner team? :)


Related articles:

LoadRunner VIDEO tutorial - Parameters part3 ('Select next row' = 'Unique')

Here is last part of LoadRunner video tutorial on working with LoadRunner parameters.
It explains different combinations of the parameter setting 'Select next row' = 'Unique'.

Note:

LoadRunner parameters #1 - video tutorial is available here.
LoadRunner parameters #2 - video tutorial is available here.


The present LoadRunner video tutorial covers the following:
  • Settings on Parameter List dlg
    Option 'Select next row' = 'Unique'
    Option 'Update value on' = 'Each iteration'
    Option 'Update value on' = 'Each occurrence'
    Option 'Update value on' = 'Once'
    Option 'When out of values' = 'Abort Vuser'
    Option 'When out of values' = 'Continue in a cyclic manner'
    Option 'When out of values' = 'Continue with last value'
    'Allocate Vuser values in the Controller'
  • How to view an output value of LoadRunner parameter
LoadRunner parameters explained
part 3 of 3 (Select next row = Unique)

LoadRunner VIDEO tutorial - Parameters part2 ('Select next row' = 'Random')

I've prepared the second part of LoadRunner video tutorial on working with LoadRunner parameters.
Note: First part of LoadRunner parameters - video tutorial is available here.

The present LoadRunner video tutorial covers the following:
  • How to create new LoadRunner parameter
  • Settings on Parameter List dlg
    Option 'Select next row' = 'Random'
    Option 'Update value on' = 'Each iteration'
    Option 'Update value on' = 'Each occurrence'
    Option 'Update value on' = 'Once'
  • How to view an output value of parameter
LoadRunner parameters explained
part 2 of 3 (Select next row = Random)

How to record LoadRunner script on FireFox?

By default, LoadRunner records Web applications on Internet Explorer browser.
LoadRunner recording options look like on this image:


How to record LoadRunner script on FireFox?

Answer:
Use the following Recording options:

Use these settings with any LoadRunner Web protocol, such as:
  • Web (HTTP/HTML)
  • AJAX (Click and Script)
  • Web (Click and Script)
This way works correctly for all FireFox versions - 1.5, 2.0, 3.0.


Related articles:

LoadRunner VIDEO tutorial - Parameters part1 ('Select next row' = 'Sequential')

I've prepared new LoadRunner video tutorial on working with LoadRunner parameters.
The present LoadRunner video tutorial covers the following:
  • How to create new LoadRunner parameter
  • How to use 'Simulate Parameter' feature
  • Settings on Parameter List dlg
    Option 'Select next row' = 'Sequential'
    Option 'Update value on' = 'Each iteration'
    Option 'Update value on' = 'Each occurrence'
    Option 'Update value on' = 'Once'
  • How to view an output value of parameter

Generating unique file name using LoadRunner parameter

I'm sure that my readers are the best readers in the world!
They are careful and they are great professionals. I constantly learn from them. Indeed!

I want to thank Tim for his comment on getting unique file name in LoadRunner.

Sure, there is very simple way to generate unique file name in LoadRunner using LoadRunner parameters.

How to do that?

We have to create three different types LoadRunner parameters:
  • Vuser ID
  • Iteration Number
  • Date/Time
  1. Open "Parameter List" dialog from "Vuser/Parameter list...":
  2. Add new LoadRunner parameter of "Vuser ID" type:
  3. Then add second LoadRunner parameter of "Iteration" type:
  4. And add third LoadRunner parameter of "Date/Time" type:
    (Click the image to enlarge it)

    Please, note that I added new Date/Time format - "%Y%m%d_%H%M%S.000".
    I described the meanings of %Y, %m, etc in this post. Point and three zeros (".000") means using of milliseconds.
    So, this Date/Time format produce a string like: 20080616_231514.953

  5. That's all. Now I add the following line of code:
    lr_output_message(lr_eval_string("{VuserID}_{Iteration}_{DateTime}"));
    The result of this line is:
    As you can see, we generated unique string for the current LoadRunner virtual user. You can use it to save the current file, for example as "1_1_20080616_232322.940.pdf".

Summary:

Using of LoadRunner parameters is easy enough.
LoadRunner provides several useful types of parameters. We used three of them:
  • Vuser ID
  • Iteration Number
  • Date/Time
Also, this way doesn't require strong programming knowledge. The code is small and compact (in our script it consists of 1 line).

Simple and useful!



Related articles:


Have you got interested materials or your own thoughts on LoadRunner?
Let's share them and help each other to improve our skills and knowledge!
You can send them to my email: Dmitry Motevich's email

Thank you in advance, dear readers.

--
Dmitry Motevich

How to save parameter value to other parameter in LoadRunner?

One my reader asked me - "How to save parameter value to other parameter in LoadRunner?". OK, there is a simple solution.

To save parameter value to other parameter you have to:
  1. Evaluate value of initial parameter
    Use lr_eval_string LoadRunner function.
  2. Save the evaluated string to a second parameter
    Use lr_save_string LoadRunner function.
Please, check the following code:
// save string value to initial parameter
lr_save_string("some string value", "prmStr1");
lr_output_message(lr_eval_string("Value of prmStr1: {prmStr1}"));

// save the evaluated value to second parameter
lr_save_string(lr_eval_string("{prmStr1}"), "prmStr2");
lr_output_message(lr_eval_string("Value of prmStr2: {prmStr2}"));
Let's execute this code and check the result:
(click the image to enlarge it)

As you can see, both parameters (prmStr1 & prmStr2) have the same values - "some string value".
So, we assigned the parameter value to other parameter successfully.


Related articles:


Do you have questions on this topic - working with LoadRunner parameters?
Feel free to post them in comments.

--
Dmitry

How to get unique file name in LoadRunner?

In my previous LoadRunner VIDEO post, I shown and explained how to record PDF file saving in LoadRunner.
The provided code works correctly in LoadRunner VuGen or in LoadRunner Controller for one concurrent user. Here it is:
//Truncate to zero length or create file for writing.
fp = fopen("c:\\temp\\_file.pdf","wb");

//Process the data ...

//Write the data to an output file.
fwrite(bufData, nSize, 1, fp);
If you try to run this code with several concurrent users, all of them will try to create the same file and write to it. As a result, this will led to the error.

How to resolve this problem?
Each user has to get unique file name and create a file with the unique name .


Now, I'm going to show - how to generate unique file name in LoadRunner.

The first step is to get a timestamp as a part of file name.
The timestamp consists of:
  • date (month, day, year)
  • time (hours, minutes, seconds, milliseconds)
You can use the following simple code to get a full timestamp without milliseconds:
lr_save_datetime("%m%d%Y_%H%M%S", DATE_NOW, "prmTimeStamp");
lr_output_message(lr_eval_string("Timestamp is: {prmTimeStamp}"));
The result of this code is:
(click the image to enlarge it)
Do you know what does the string "%m%d%Y_%H%M%S" mean?
These are Datetime Format Codes. Please, refer to a table for their descriptions:
#
Datetime Format Code
Description
1
%m
month number (01-12)
2
%d
day of month (01-31)
3
%Y
year, including century (for example, 1988)
4
%H
hour (00-23)
5
%M
minute (00-59)
6
%S
seconds (00-59)

The above code is not ideal. If you application (and LoadRunner script) saves more than one file per second, then file names will be dublicated.

That's why I can propose the code, which get a timestamp with milliseconds:
ent timestamp:
typedef long time_t;

struct _timeb {
    time_t time;
    unsigned short millitm;
    short timezone;
    short dstflag;
};

struct tm {
    int tm_sec; // seconds after the minute - [0,59]
    int tm_min; // minutes after the hour - [0,59]
    int tm_hour; // hours since midnight - [0,23]
    int tm_mday; // day of the month - [1,31]
    int tm_mon; // months since January - [0,11]
    int tm_year; // years since 1900
    int tm_wday; // days since Sunday - [0,6]
    int tm_yday; // days since January 1 - [0,365]
    int tm_isdst; // daylight savings time flag
    #ifdef LINUX
    int tm_gmtoff;
    const char * tm_zone;
    #endif
};

struct _timeb tb;
struct tm * now;
char szFileName[256];

_tzset(); // Sets variables used by localtime
_ftime(&tb); // Gets the current timestamp

// Convert to time structure
now = (struct tm *)localtime(&tb.time);

sprintf(szFileName, "%02d%02d%04d_%02d%02d%02d_%03u",
    now->tm_mon + 1,
    now->tm_mday,
    now->tm_year + 1900,
    now->tm_hour,
    now->tm_min,
    now->tm_sec,
    tb.millitm);
lr_output_message("Timestamp is: %s", szFileName);
Let's execute this code and check the result:
(click the image to enlarge it)
That's much better :) We can generate timestamp with millisecond.
Unfortunately, the chances that concurrent users will generate the same file name at the same time still exist.

To resolve this issue, we can get unique ids per virtual users. This can be done with lr_whoami LoadRunner function:
int vuserid, scid;
char *groupid;

lr_whoami(&vuserid, &groupid, &scid);
lr_message("Group: %s, vuser id: %d, scenario id %d", groupid, vuserid, scid);
lr_whoami LoadRunner function returns information about the Vuser executing the script.

When you run this code in LoadRunner Vuser Generator, the result will be:

When you run this code in LoadRunner Controller, the result will be:

So, the last step is to combine timestamp with a vuser execution's ids and use them as a file name.
This will guarantee, that each LoadRunner virtual user will have unique file name.

So, the final code is:
typedef long time_t;

struct _timeb {
    time_t time;
    unsigned short millitm;
    short timezone;
    short dstflag;
};

struct tm {
    int tm_sec; // seconds after the minute - [0,59]
    int tm_min; // minutes after the hour - [0,59]
    int tm_hour; // hours since midnight - [0,23]
    int tm_mday; // day of the month - [1,31]
    int tm_mon; // months since January - [0,11]
    int tm_year; // years since 1900
    int tm_wday; // days since Sunday - [0,6]
    int tm_yday; // days since January 1 - [0,365]
    int tm_isdst; // daylight savings time flag
    #ifdef LINUX
    int tm_gmtoff;
    const char * tm_zone;
    #endif
};

struct _timeb tb;
struct tm * now;
char szFileName[256];

int vuserid, scid;
char *vusergroup;

_tzset(); // Sets variables used by localtime
_ftime(&tb); // Gets the current timestamp

// Convert to time structure
now = (struct tm *)localtime(&tb.time);

sprintf(szFileName, "%02d%02d%04d_%02d%02d%02d_%03u_%d_%d_%s",
    now->tm_mon + 1,
    now->tm_mday,
    now->tm_year + 1900,
    now->tm_hour,
    now->tm_min,
    now->tm_sec,
    tb.millitm,
    vuserid,
    scid,
    vusergroup);

lr_output_message
("File name is: %s", szFileName);
Note: You can download this source code from here.

The result of above code is:
Using the generated name (05312008_221557_116_7_0_group1) you can save the file into "05312008_221557_116_7_0_group1.pdf" or "05312008_221557_116_7_0_group1.txt" depending on the file type.


Related articles:


I hope, this solution will help you in LoadRunner scripting.
Thank you for your attention, dear reader.

--
Dmitry

Examples on LoadRunner Regular Expressions

I'm going to show and explain how to use Regular Expressions in LoadRunner.

Introduction:
The present article is a summarizing of the LoadRunner Regular Expressions challenge and its results. Also, I added code for RegExp patterns/subpatterns matching.
All LoadRunner Regular Expressions functions are shown with examples.


Outline:
  1. How to check - whether RegExp pattern matches against a text or not
  2. How to get a matched strings (RegExp patterns and subpatterns)

How to check - Whether RegExp pattern matches against a text or not


I thanks Charlie Weiblen and Tim Koopmans for the solution. I modified it slightly.
So, here it is:
  1. Download and unpack Binaries and Developer files for PCRE (Perl Compatible Regular Expressions).
    These and others files are available on Pcre for Windows page.

  2. Unzip downloaded archives into c:\pcre
    C:\pcre folder
  3. Сomment out the include for stdlib.h file in:
    • C:\pcre\include\pcre.h
    • C:\pcre\include\pcreposix.h
    Commented stdlib.h file
  4. In your LoadRunner script, add to globals.h:
    • #include "c:\\pcre\\include\\pcre.h"
    • #include "c:\\pcre\\include\\pcreposix.h"
    Edited globals.h file
  5. Add the match() function to vuser_init section:
    //////////////////////////////////////////////////////////////////////////
    /// 'match' function matches a 'pattern' against a given 'subject'
    /// It returns 1 for a match, or 0 for a non-match / error
    int match(const char *subject, const char *pattern)
    {
    int rc; // Returned code
    regex_t re; // Compiled regexp pattern

    lr_load_dll("c:\\pcre\\bin\\pcre3.dll");

    if (regcomp(&re, pattern, 0) != 0)
    return 0; // Report error

    rc = regexec(&re, subject, 0, NULL, 0);
    regfree(&re);

    if (rc != 0)
    return 0; // Report error
    else
    return 1;
    }

  6. Let's run sample LoadRunner script and check the result:
    As you can see, match() function works correctly. Using match() function, you can check - whether RegExp pattern matches against a text or not.

    It can be helpful, when you verify in LoadRunner that the text (RegExp pattern) matches the text on a downloaded page.

    I tested the match() function with different patterns and subject strings:
    #
    Subject string
    Patterns
    Result of
    match()
    Is correct
    result?
    1
    abcdefb(c(.*))e
    1
    Yes
    2
    abcdef
    b(z(.*))e
    0
    Yes
    3
    2008
    \\d{2,5}
    1
    Yes
    4
    2008
    \\d{5}
    0
    Yes
    5
    abc 1st of May 2008xyz
    \\d.*\\d
    1
    Yes
    Note: Since LoadRunner uses ANSI C language, please do not forget to double backslashes (\\). For example, to match any digit character (0-9), use pattern "\\d".

    match() function is simple enough. But it searches only and it cannot extract matched subpatterns from the text. For example, we have to extract the name of month from these strings:
    • "abc 1st of May 2008xyz"
    • "abc 25th of February 2031"
    • etc
    We can use the following pattern:
    • \d.+([A-Z]\w+)\s+\d{4}

    The name of month will be matches by subpattern ([A-Z]\w+). How to extract the found text? You can use matchex() function for that. Let's discuss it in details...

How to get a matched strings (RegExp patterns and subpatterns)

To get a matched (found) strings, we have to update our match() function.
That's why I created matchex() ('match' EXtended) function.
  1. Add the matchex() function to vuser_init section
    //////////////////////////////////////////////////////////////////////////
    /// 'matchex' (EXtended) function matches a 'pattern' against a given 'subject'
    /// It returns number of matches:
    /// 0 - for a non-match or error
    /// 1 and more - for successful matches
    int matchex(const char *subject, const char *pattern, int nmatch, regmatch_t *pmatch)
    {
    int rc; // Returned code
    regex_t re; // Compiled regexp pattern

    lr_load_dll("c:\\pcre\\bin\\pcre3.dll");

    if (regcomp(&re, pattern, 0) != 0)
    return 0; // Report error

    rc = regexec(&re, subject, nmatch, pmatch, 0);
    pcre_free(&re); // Release memory used for the compiled pattern

    if (rc < 0)
    return 0; // Report error

    // Get total number of matched patterns and subpatterns
    for (rc = 0; rc < nmatch; rc++)
    if (pmatch[rc].rm_so == -1)
    break;

    return rc;
    }

  2. Let's run sample LoadRunner script and check the result:
    matchex() function returns a number of matched patterns/subpatterns and fill an array in with information about each matched substring.


    What is an information about each matched substring?


    This info contains the offset (rm_so) to the first character of each substring and the offset (rm_eo) to the first character after the end of each substring, respectively.

    Note1:
    The 0th element of the array relates to the entire portion of string that was matched.
    Note2: Subsequent elements of the array relate to the capturing subpatterns of the regular expression.
    Note3: Unused entries in the array have both structure members set to -1.

    Let's investigate it with the example. This is our subject string:
    ExampleThe replay log shows offsets for matched substrings:
    • Action.c(7): Matched 3 patterns
    • Action.c(10): Start offset: 1, End offset: 6
    • Action.c(10): Start offset: 2, End offset: 5
    • Action.c(10): Start offset: 3, End offset: 5

    Start offset: 1 and End offset: 6 match substring "bcdef".
    Note4: End offset is the first character after the end the current substring. That's why character "g" (with index 6) is not a part of matched string.

    As I've written in Note1, "bcdef" is the entire portion of string that was matched.
    Others items from an array relate to matched subpatterns.


    What is a subpattern in Regular Expression?

    It is a part of the RegExp pattern surrounded with parenthesis - "(" and ")".

    It's easy to get out the order of subpatterns. Just look through your pattern from left to right. When you find an open parenthes, this is a start of the current subpattern.
    Subpattern can be embedded.

    So, others captured subpatterns are:
    • Start offset: 2, End offset: 5 matches substring "cde".
      Note: current subpattern is "([acqz](.*))".
    • Start offset: 3, End offset: 5 match substring "de".
      Note: current subpattern is "(.*)".

    As you can see - this is not so difficult. :)
    Regular Expressions can be very powerful and useful in LoadRunner.

Another example:

Let's practise with an example I mentioned early:
For example, we have to extract the name of month from these strings:
  • "abc 1st of May 2008xyz"
  • "abc 25th of February 2031"
  • etc
We can use the following pattern:
  • \d.+([A-Z]\w+)\s+\d{4}
The name of month will be matches by subpattern ([A-Z]\w+).

Please, see LoadRunner script, which captures and prints name of months:
Note: Pay attention that I use arr[1] to get info about substring.
As you remember, arr[0] contains info about the entire matched pattern, arr[1], arr[2], and so on contain info about matched subpattern.


Summary:
I've explained, shown and demonstrated how to use Regular Expressions (RegExp) in LoadRunner.
I hope, this knowledge will help you to create advanced LoadRunner scripts.



Related articles:


--
Thank you, my readers!
Dmitry Motevich