Generating unique file name using LoadRunner 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

4 comments:

Anonymous said...

That’s really cool and helps me a lot. Let me tell you something I have created 15 folders and named them Vuser1, Vuser2, Vuser3……………..Vuser15. What I like to do is when I run 15 Virtual Users they should save the file in their define folder. Like Vuser1 should save the PDF file in Vuser1 folder, Vuser2 should save the file in Vuser2 folder and so forth.

Cheers

Ali from Sydney, Australia

Dmitry Motevich said...

If I create that test, I would create a File parameter, which contains values Vuser1, Vuser2,...Vuser15
Afther in the parameter settings I would assign one value for each vuser. And each vuser would be able to use the assigned folder to save files.

Sunsh said...

Thanx for the post. It helped me a lot.

Unknown said...

Hi Dimitry,

I just looked the example given for tool tips of Images.

But i just applied to my application but its having issues .

1) I have an webtable inside i have a column which shows the status , its an Image ( red,green,yellow lights ) and the code example when i applied is getting me the list of images but not the one in the webtable ,
Can you guide me here ?.



Thanks in advance and regards
harsha