How to read and use number generated by random number generator in different actions within a recorded script?

138 views
Skip to first unread message

Software Testing

unread,
Aug 11, 2009, 10:46:14 AM8/11/09
to LoadRunner

Hi All,

I have a query regarding random number generator.

Here are details:

I recorded LoadRunner script for a web server, which contained one
special field i. e. Session id.
(Generated by javascript from the client side at the time of login)

Here is the request format that goes to server

"URL=http://test.com/Testserver/DynamicJS.aspx?
action=Login&session=0.123456789&userName=testuser&password=testr&orgName=&ID=529dc1d8=1&callback=SuccessEx&UID=1234"....,
Resource=1",
RecContentType=text/javascript",
"Referer=http://test.com/test.html",
LAST);


In order to login successfully; I used random number as parameter for
'Session'.
It replaces above session id with any random number. In this case say-
123456 (Required for successful login)


My script is having 3 different actions (transactions) after login and
each action refers same session id. Ex - 123456

My query is,
How to read and use number generated by LR (as parameter - 12345
generated at the time of login in action 1) in other 3 subsequent
actions from action 1 (in this case from Login action) within a
recorded script?

I have to use session id - 12345 to all subsequent actions after login
action and wherever session id is required.
(other actions will fail if session id is different. Need to pass same
session id for all requests).

To solve this -
1. Read that random number.
2. use and pass it to all other actions within script

Can anybody know how to do that?


Thanks,
Milind

Waiting for your reply :)




Anaz Mohamed

unread,
Aug 11, 2009, 1:08:00 PM8/11/09
to LR-Loa...@googlegroups.com
Hi
 
 
It's simple use correlation for Session ID that's all it's simple web_reg_save_param()

James Pulley

unread,
Aug 11, 2009, 1:18:37 PM8/11/09
to LR-Loa...@googlegroups.com
Rules of thumb for replacement
  • If you value present is one you typed it in or select it from an interface then the odds are high that you will have a straight replacement as a parameter
  • If the value present is one which has been provided by the system in a returned datastream but not one which you typed in then the odds are high that you will correlate the variable.
  • If the value is one which has not been selected and is one which is not present in a returned datastream then the odds are high that this is a calculated value and you will need to provide an algorithm equivalent of the output for inclusion in your submission to the server.
You have violated the rules of thumb by providing a purely parameterized replacement for a value which has been sent to you from the server in a returned datastream.   This value should be fed from a correlated LoadRunner variable and not one from the random number generator in the general parameterization engine.
 
You have a number of items present other than session which will also likely require correlation activities.
 
'Pulley
 


From: LR-Loa...@googlegroups.com [mailto:LR-Loa...@googlegroups.com] On Behalf Of Anaz Mohamed
Sent: Tuesday, August 11, 2009 1:08 PM
To: LR-Loa...@googlegroups.com
Subject: Re: How to read and use number generated by random number generator in different actions within a recorded script?

Krishnakanth PPS

unread,
Aug 12, 2009, 1:00:26 PM8/12/09
to LR-Loa...@googlegroups.com
Mr. Pulley seems to have frightened dear "Software Testing"

utkarsh sinha

unread,
Aug 16, 2009, 5:18:24 AM8/16/09
to LR-Loa...@googlegroups.com
Hi,
     I do agree with the thumb rules that Mr Pulley mentioned.But getting an algorithm from the dev team is not that easy.how ever some times replacing the digits with  random values does help .Since here we speak of only 6 random digits that needs to be replaced it can be easily acheived by using custom LR functions.call the function and store the value in the variable.Replace the random digits with this variable every where in your script.If u need help in writing that function do let know.I willl provide one. 

Software Testing

unread,
Aug 20, 2009, 12:47:42 AM8/20/09
to LoadRunner

Hi,

Thanks for your help.
It would be great if you provide me that function.

Regards,
Milind

On Aug 16, 2:18 pm, utkarsh sinha <utkarshsinh...@gmail.com> wrote:
> Hi,
>      I do agree with the thumb rules that Mr Pulley mentioned.But getting an
> algorithm from the dev team is not that easy.how ever some times replacing
> the digits with  random values does help .Since here we speak of only 6
> random digits that needs to be replaced it can be easily acheived by using
> custom LR functions.call the function and store the value in the
> variable.Replace the random digits with this variable every where in your
> script.If u need help in writing that function do let know.I willl provide
> one.
>
> On Wed, Aug 12, 2009 at 10:30 PM, Krishnakanth PPS <
>
>
>
> krishnakanth....@gmail.com> wrote:
> > Mr. Pulley seems to have frightened dear "Software Testing"
>
> > On Tue, Aug 11, 2009 at 10:48 PM, James Pulley <jpul...@itestsolutions.com
> > > wrote:
>
> >>  Rules of thumb for replacement
>
> >>    - If you value present is one you typed it in or select it from an
> >>    interface then the odds are high that you will have a straight replacement
> >>    as a parameter
> >>    - If the value present is one which has been provided by the system in
> >>    a returned datastream but not one which you typed in then the odds are high
> >>    that you will correlate the variable.
> >>    - If the value is one which has not been selected and is one which is
> >>    not present in a returned datastream then the odds are high that this is a
> >>    calculated value and you will need to provide an algorithm equivalent of the
> >>    output for inclusion in your submission to the server.
>
> >> You have violated the rules of thumb by providing a purely parameterized
> >> replacement for a value which has been sent to you from the server in a
> >> returned datastream.   This value should be fed from a correlated LoadRunner
> >> variable and not one from the random number generator in the general
> >> parameterization engine.
>
> >> You have a number of items present other than session which will also
> >> likely require correlation activities.
>
> >> 'Pulley
>
> >>  ------------------------------
> >> *From:* LR-Loa...@googlegroups.com [mailto:
> >> LR-Loa...@googlegroups.com] *On Behalf Of *Anaz Mohamed
> >> *Sent:* Tuesday, August 11, 2009 1:08 PM
> >> *To:* LR-Loa...@googlegroups.com
> >> *Subject:* Re: How to read and use number generated by random number
> >> generator in different actions within a recorded script?
>
> >>   Hi
>
> >> It's simple use correlation for Session ID that's all it's simple
> >> web_reg_save_param()
>
> >> On Tue, Aug 11, 2009 at 7:46 AM, Software Testing <
> >> patil.milin...@gmail.com> wrote:
>
> >>> Hi All,
>
> >>> I have a query regarding random number generator.
>
> >>> Here are details:
>
> >>> I recorded LoadRunner script for a web server, which contained one
> >>> special field i. e. Session id.
> >>> (Generated by javascript from the client side at the time of login)
>
> >>> Here is the request format that goes to server
>
> >>> "URL=http://test.com/Testserver/DynamicJS.aspx?
>
> >>> action=Login&session=0.123456789&userName=testuser&password=testr&orgName=&­ID=529dc1d8=1&callback=SuccessEx&UID=1234
> >>> Waiting for your reply :)- Hide quoted text -
>
> - Show quoted text -

Anaz Mohamed

unread,
Aug 21, 2009, 2:56:46 AM8/21/09
to LR-Loa...@googlegroups.com
lr_eval_string("{Variableparameter}"); is the function
 
The above should help
 
 
Regards,
Anaz

 
Reply all
Reply to author
Forward
0 new messages