You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by xgan <xg...@medianewsgroup.com> on 2008/03/14 17:34:00 UTC

How to use _Random function

I have question about Random function. The scenarios are as follows: 

1. I run a HTTP Request by using external data file as my test script. I use
_StringFromFile(xxx.dat) function which setup in User Parameter (Name:
SEARCH; User_1:_StringFromFile(xxx.dat))  in my test script. 

2.Now I want to randomly choose the data from xxx.dat file. 

3.I tried to setup ${_Random(1,10,${SEARCH})} in value of HTTP Request's
Send Parameters With the Request:, but after script ran, it looks like
_Random function do not work.

Would you mind inform how to set Name of Function in Random function? 

Thanks. Xgan

-- 
View this message in context: http://www.nabble.com/How-to-use-_Random-function-tp16048595p16048595.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to use _Random function

Posted by sebb <se...@gmail.com>.
On 17/03/2008, xgan <xg...@medianewsgroup.com> wrote:
>
>  Hi Sebb,
>
>  Thank you very much for your reply. I got my script work. But I still have
>  two questions for you as follows:
>
>  1. I check manual for function, and I did not find that I need two
>  underscores" __" before function name in text, although I can notice that
>  there are two underscore bfore function in manual. But I did have one
>  underscore before StringFromFile (_StringFromFile()) function work
>  successfully. So which function needs two underscore and which one need one
>  underscroe ore all of them need two underscores?

StringFromFile was originally defined with just one underscore; the
preferred form is with two underscores - which all other functions
require. The single underscore version is kept for backwards
compatibility.

>  2. You mentioned that "As I wrote before, you cannot select random entries
>  from the CSV file". but why did I get random numbers displayed in "View
>  Result Tree"? Would you please explain more about __Random function and
>  provide some example?

The Random function generates random numbers.

There is no way to randomly select a line from the file read by
StringFromFile, whether using the random function or otherwise.

>  Thanks a lot in advance.
>
>
>  Xgan
>
>
>  sebb-2-2 wrote:
>  >
>  > On 14/03/2008, xgan <xg...@medianewsgroup.com> wrote:
>  >>
>  >>  Hi Sebb,
>  >>
>  >>  Thanks your response. I changed my value as "${_Random(1,10,SEARCH)}",
>  >> but
>  >>  the random function did not work as I expected.
>  >>
>  >
>  > Just noticed that you only used one _, it should be
>  >
>  > ${__Random(1,10,SEARCH)}
>  >
>  >>  My project is to test search on web page. I create a csv data file
>  >> include a
>  >>  lot string, ex:
>  >>  bark
>  >>  blend
>  >>  blast
>  >>  boast
>  >>  bump
>  >>  chase
>  >>  chap
>  >>  ......
>  >>
>  >>  I want to choose one by one randomly from csv file by using _Random
>  >>  function.
>  >
>  > As I wrote before, you cannot select random entries from the CSV file.
>  >
>  >>  I compared results with & without random function as follows:
>  >>
>  >>  without _Random function, I set ${SEARCH} in value of "Send Parameters
>  >> With
>  >>  the Request:". I got successful message from "View Result Tree" => tab
>  >> of
>  >>  Request (GET
>  >>
>  >> http://qa2live.twincities.com/circare/html/sca_template.jsp?_dyncharset=UTF-8&%2Fmngi%2Fsearch
>  >>  %2Fdroplet%2FFastESPDroplet.query=bark&_D%3A%2Fmngi%........) NOTE: bark
>  >>  after "FFastESPDroplet.query="
>  >>
>  >>  with _Random function I set ${_Random(1,10,SEARCH)} in value of "Send
>  >>  Parameters With the Request:". I got successful message from "View
>  >> Result
>  >>  Tree" => tab of Request (GET
>  >>
>  >> http://qa2live.twincities.com/circare/html/sca_template.jsp?_dyncharset=UTF-8&%2Fmngi%2Fsearch
>  >>
>  >> %2Fdroplet%2FFastESPDroplet.query=%24%7B1%2C10%2CSEARCH%29%7D&_D%3A%2Fmngi%.....)
>  >>  NOTE:%24%7B1%2C10%2CSEARCH%29%7D after "FFastESPDroplet.query="
>  >>
>  >
>  > This is ${1,10,SEARCH)} with URL encoding; that's because _Random is
>  > not a valid function.
>  >
>  >>  Would you mind let me know why I got those message with lot of %?
>  >
>  > Because the characters are not valid for a URL.
>  >
>  >>  Thanks.
>  >>
>  >>  Xgan
>  >>
>  >>
>  >>
>  >>
>  >>
>  >>  sebb-2-2 wrote:
>  >>  >
>  >>  > On 14/03/2008, xgan <xg...@medianewsgroup.com> wrote:
>  >>  >>
>  >>  >>  I have question about Random function. The scenarios are as follows:
>  >>  >>
>  >>  >>  1. I run a HTTP Request by using external data file as my test
>  >> script. I
>  >>  >> use
>  >>  >>  _StringFromFile(xxx.dat) function which setup in User Parameter
>  >> (Name:
>  >>  >>  SEARCH; User_1:_StringFromFile(xxx.dat))  in my test script.
>  >>  >>
>  >>  >>  2.Now I want to randomly choose the data from xxx.dat file.
>  >>  >
>  >>  > Not possible.
>  >>  >
>  >>  > Just randomise the dat file before starting the test.
>  >>  >
>  >>  >>  3.I tried to setup ${_Random(1,10,${SEARCH})} in value of HTTP
>  >> Request's
>  >>  >>  Send Parameters With the Request:, but after script ran, it looks
>  >> like
>  >>  >>  _Random function do not work.
>  >>  >>
>  >>  >
>  >>  > That should be ${_Random(1,10,SEARCH)}
>  >>  >
>  >>  > as you are defining the variable, not referencing it.
>  >>  >
>  >>  >>  Would you mind inform how to set Name of Function in Random
>  >> function?
>  >>  >>
>  >>  >>  Thanks. Xgan
>  >>  >>
>  >>  >>
>  >>  >>  --
>  >>  >>  View this message in context:
>  >>  >>
>  >> http://www.nabble.com/How-to-use-_Random-function-tp16048595p16048595.html
>  >>  >>  Sent from the JMeter - User mailing list archive at Nabble.com.
>  >>  >>
>  >>  >>
>  >>  >>
>  >> ---------------------------------------------------------------------
>  >>  >>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  >>  >>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >>  >>
>  >>  >>
>  >>  >
>  >>  > ---------------------------------------------------------------------
>  >>  > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  >>  > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >>  >
>  >>  >
>  >>  >
>  >>
>  >>
>  >> --
>  >>  View this message in context:
>  >> http://www.nabble.com/How-to-use-_Random-function-tp16048595p16059395.html
>  >>
>  >> Sent from the JMeter - User mailing list archive at Nabble.com.
>  >>
>  >>
>  >>  ---------------------------------------------------------------------
>  >>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  >>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >>
>  >>
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >
>  >
>  >
>
>  --
>
> View this message in context: http://www.nabble.com/How-to-use-_Random-function-tp16048595p16093025.html
>
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to use _Random function

Posted by xgan <xg...@medianewsgroup.com>.
Hi Sebb,

Thank you very much for your reply. I got my script work. But I still have
two questions for you as follows:

1. I check manual for function, and I did not find that I need two
underscores" __" before function name in text, although I can notice that
there are two underscore bfore function in manual. But I did have one
underscore before StringFromFile (_StringFromFile()) function work
successfully. So which function needs two underscore and which one need one
underscroe ore all of them need two underscores?

2. You mentioned that "As I wrote before, you cannot select random entries
from the CSV file". but why did I get random numbers displayed in "View
Result Tree"? Would you please explain more about __Random function and
provide some example?

Thanks a lot in advance.

Xgan 


sebb-2-2 wrote:
> 
> On 14/03/2008, xgan <xg...@medianewsgroup.com> wrote:
>>
>>  Hi Sebb,
>>
>>  Thanks your response. I changed my value as "${_Random(1,10,SEARCH)}",
>> but
>>  the random function did not work as I expected.
>>
> 
> Just noticed that you only used one _, it should be
> 
> ${__Random(1,10,SEARCH)}
> 
>>  My project is to test search on web page. I create a csv data file
>> include a
>>  lot string, ex:
>>  bark
>>  blend
>>  blast
>>  boast
>>  bump
>>  chase
>>  chap
>>  ......
>>
>>  I want to choose one by one randomly from csv file by using _Random
>>  function.
> 
> As I wrote before, you cannot select random entries from the CSV file.
> 
>>  I compared results with & without random function as follows:
>>
>>  without _Random function, I set ${SEARCH} in value of "Send Parameters
>> With
>>  the Request:". I got successful message from "View Result Tree" => tab
>> of
>>  Request (GET
>> 
>> http://qa2live.twincities.com/circare/html/sca_template.jsp?_dyncharset=UTF-8&%2Fmngi%2Fsearch
>>  %2Fdroplet%2FFastESPDroplet.query=bark&_D%3A%2Fmngi%........) NOTE: bark
>>  after "FFastESPDroplet.query="
>>
>>  with _Random function I set ${_Random(1,10,SEARCH)} in value of "Send
>>  Parameters With the Request:". I got successful message from "View
>> Result
>>  Tree" => tab of Request (GET
>> 
>> http://qa2live.twincities.com/circare/html/sca_template.jsp?_dyncharset=UTF-8&%2Fmngi%2Fsearch
>> 
>> %2Fdroplet%2FFastESPDroplet.query=%24%7B1%2C10%2CSEARCH%29%7D&_D%3A%2Fmngi%.....)
>>  NOTE:%24%7B1%2C10%2CSEARCH%29%7D after "FFastESPDroplet.query="
>>
> 
> This is ${1,10,SEARCH)} with URL encoding; that's because _Random is
> not a valid function.
> 
>>  Would you mind let me know why I got those message with lot of %?
> 
> Because the characters are not valid for a URL.
> 
>>  Thanks.
>>
>>  Xgan
>>
>>
>>
>>
>>
>>  sebb-2-2 wrote:
>>  >
>>  > On 14/03/2008, xgan <xg...@medianewsgroup.com> wrote:
>>  >>
>>  >>  I have question about Random function. The scenarios are as follows:
>>  >>
>>  >>  1. I run a HTTP Request by using external data file as my test
>> script. I
>>  >> use
>>  >>  _StringFromFile(xxx.dat) function which setup in User Parameter
>> (Name:
>>  >>  SEARCH; User_1:_StringFromFile(xxx.dat))  in my test script.
>>  >>
>>  >>  2.Now I want to randomly choose the data from xxx.dat file.
>>  >
>>  > Not possible.
>>  >
>>  > Just randomise the dat file before starting the test.
>>  >
>>  >>  3.I tried to setup ${_Random(1,10,${SEARCH})} in value of HTTP
>> Request's
>>  >>  Send Parameters With the Request:, but after script ran, it looks
>> like
>>  >>  _Random function do not work.
>>  >>
>>  >
>>  > That should be ${_Random(1,10,SEARCH)}
>>  >
>>  > as you are defining the variable, not referencing it.
>>  >
>>  >>  Would you mind inform how to set Name of Function in Random
>> function?
>>  >>
>>  >>  Thanks. Xgan
>>  >>
>>  >>
>>  >>  --
>>  >>  View this message in context:
>>  >>
>> http://www.nabble.com/How-to-use-_Random-function-tp16048595p16048595.html
>>  >>  Sent from the JMeter - User mailing list archive at Nabble.com.
>>  >>
>>  >>
>>  >> 
>> ---------------------------------------------------------------------
>>  >>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>  >>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>  >>
>>  >>
>>  >
>>  > ---------------------------------------------------------------------
>>  > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>  > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>  >
>>  >
>>  >
>>
>>
>> --
>>  View this message in context:
>> http://www.nabble.com/How-to-use-_Random-function-tp16048595p16059395.html
>>
>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-use-_Random-function-tp16048595p16093025.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to use _Random function

Posted by sebb <se...@gmail.com>.
On 14/03/2008, xgan <xg...@medianewsgroup.com> wrote:
>
>  Hi Sebb,
>
>  Thanks your response. I changed my value as "${_Random(1,10,SEARCH)}", but
>  the random function did not work as I expected.
>

Just noticed that you only used one _, it should be

${__Random(1,10,SEARCH)}

>  My project is to test search on web page. I create a csv data file include a
>  lot string, ex:
>  bark
>  blend
>  blast
>  boast
>  bump
>  chase
>  chap
>  ......
>
>  I want to choose one by one randomly from csv file by using _Random
>  function.

As I wrote before, you cannot select random entries from the CSV file.

>  I compared results with & without random function as follows:
>
>  without _Random function, I set ${SEARCH} in value of "Send Parameters With
>  the Request:". I got successful message from "View Result Tree" => tab of
>  Request (GET
>  http://qa2live.twincities.com/circare/html/sca_template.jsp?_dyncharset=UTF-8&%2Fmngi%2Fsearch
>  %2Fdroplet%2FFastESPDroplet.query=bark&_D%3A%2Fmngi%........) NOTE: bark
>  after "FFastESPDroplet.query="
>
>  with _Random function I set ${_Random(1,10,SEARCH)} in value of "Send
>  Parameters With the Request:". I got successful message from "View Result
>  Tree" => tab of Request (GET
>  http://qa2live.twincities.com/circare/html/sca_template.jsp?_dyncharset=UTF-8&%2Fmngi%2Fsearch
>  %2Fdroplet%2FFastESPDroplet.query=%24%7B1%2C10%2CSEARCH%29%7D&_D%3A%2Fmngi%.....)
>  NOTE:%24%7B1%2C10%2CSEARCH%29%7D after "FFastESPDroplet.query="
>

This is ${1,10,SEARCH)} with URL encoding; that's because _Random is
not a valid function.

>  Would you mind let me know why I got those message with lot of %?

Because the characters are not valid for a URL.

>  Thanks.
>
>  Xgan
>
>
>
>
>
>  sebb-2-2 wrote:
>  >
>  > On 14/03/2008, xgan <xg...@medianewsgroup.com> wrote:
>  >>
>  >>  I have question about Random function. The scenarios are as follows:
>  >>
>  >>  1. I run a HTTP Request by using external data file as my test script. I
>  >> use
>  >>  _StringFromFile(xxx.dat) function which setup in User Parameter (Name:
>  >>  SEARCH; User_1:_StringFromFile(xxx.dat))  in my test script.
>  >>
>  >>  2.Now I want to randomly choose the data from xxx.dat file.
>  >
>  > Not possible.
>  >
>  > Just randomise the dat file before starting the test.
>  >
>  >>  3.I tried to setup ${_Random(1,10,${SEARCH})} in value of HTTP Request's
>  >>  Send Parameters With the Request:, but after script ran, it looks like
>  >>  _Random function do not work.
>  >>
>  >
>  > That should be ${_Random(1,10,SEARCH)}
>  >
>  > as you are defining the variable, not referencing it.
>  >
>  >>  Would you mind inform how to set Name of Function in Random function?
>  >>
>  >>  Thanks. Xgan
>  >>
>  >>
>  >>  --
>  >>  View this message in context:
>  >> http://www.nabble.com/How-to-use-_Random-function-tp16048595p16048595.html
>  >>  Sent from the JMeter - User mailing list archive at Nabble.com.
>  >>
>  >>
>  >>  ---------------------------------------------------------------------
>  >>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  >>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >>
>  >>
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >
>  >
>  >
>
>
> --
>  View this message in context: http://www.nabble.com/How-to-use-_Random-function-tp16048595p16059395.html
>
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to use _Random function

Posted by xgan <xg...@medianewsgroup.com>.
Hi Sebb,

Thanks your response. I changed my value as "${_Random(1,10,SEARCH)}", but
the random function did not work as I expected.

My project is to test search on web page. I create a csv data file include a
lot string, ex:
bark
blend
blast
boast
bump
chase
chap
......

I want to choose one by one randomly from csv file by using _Random
function.

I compared results with & without random function as follows:

without _Random function, I set ${SEARCH} in value of "Send Parameters With
the Request:". I got successful message from "View Result Tree" => tab of
Request (GET
http://qa2live.twincities.com/circare/html/sca_template.jsp?_dyncharset=UTF-8&%2Fmngi%2Fsearch
%2Fdroplet%2FFastESPDroplet.query=bark&_D%3A%2Fmngi%........) NOTE: bark
after "FFastESPDroplet.query="

with _Random function I set ${_Random(1,10,SEARCH)} in value of "Send
Parameters With the Request:". I got successful message from "View Result
Tree" => tab of Request (GET
http://qa2live.twincities.com/circare/html/sca_template.jsp?_dyncharset=UTF-8&%2Fmngi%2Fsearch
%2Fdroplet%2FFastESPDroplet.query=%24%7B1%2C10%2CSEARCH%29%7D&_D%3A%2Fmngi%.....) 
NOTE:%24%7B1%2C10%2CSEARCH%29%7D after "FFastESPDroplet.query="

Would you mind let me know why I got those message with lot of %?

Thanks.

Xgan




sebb-2-2 wrote:
> 
> On 14/03/2008, xgan <xg...@medianewsgroup.com> wrote:
>>
>>  I have question about Random function. The scenarios are as follows:
>>
>>  1. I run a HTTP Request by using external data file as my test script. I
>> use
>>  _StringFromFile(xxx.dat) function which setup in User Parameter (Name:
>>  SEARCH; User_1:_StringFromFile(xxx.dat))  in my test script.
>>
>>  2.Now I want to randomly choose the data from xxx.dat file.
> 
> Not possible.
> 
> Just randomise the dat file before starting the test.
> 
>>  3.I tried to setup ${_Random(1,10,${SEARCH})} in value of HTTP Request's
>>  Send Parameters With the Request:, but after script ran, it looks like
>>  _Random function do not work.
>>
> 
> That should be ${_Random(1,10,SEARCH)}
> 
> as you are defining the variable, not referencing it.
> 
>>  Would you mind inform how to set Name of Function in Random function?
>>
>>  Thanks. Xgan
>>
>>
>>  --
>>  View this message in context:
>> http://www.nabble.com/How-to-use-_Random-function-tp16048595p16048595.html
>>  Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-use-_Random-function-tp16048595p16059395.html
Sent from the JMeter - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to use _Random function

Posted by sebb <se...@gmail.com>.
On 14/03/2008, xgan <xg...@medianewsgroup.com> wrote:
>
>  I have question about Random function. The scenarios are as follows:
>
>  1. I run a HTTP Request by using external data file as my test script. I use
>  _StringFromFile(xxx.dat) function which setup in User Parameter (Name:
>  SEARCH; User_1:_StringFromFile(xxx.dat))  in my test script.
>
>  2.Now I want to randomly choose the data from xxx.dat file.

Not possible.

Just randomise the dat file before starting the test.

>  3.I tried to setup ${_Random(1,10,${SEARCH})} in value of HTTP Request's
>  Send Parameters With the Request:, but after script ran, it looks like
>  _Random function do not work.
>

That should be ${_Random(1,10,SEARCH)}

as you are defining the variable, not referencing it.

>  Would you mind inform how to set Name of Function in Random function?
>
>  Thanks. Xgan
>
>
>  --
>  View this message in context: http://www.nabble.com/How-to-use-_Random-function-tp16048595p16048595.html
>  Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org