You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Senthil Kumaran <se...@proaxiom.co.nz> on 2007/05/03 06:31:29 UTC
Creating Random Names or Characters
Hi,
I am trying to create a random string or character in the name field of
the web application.
So that i can create dynamic names to post the http request.
Is it possible to create a random string or characters in jmeter.
Thanks and Regards,
Senthil
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: Creating Random Names or Characters
Posted by CaHamdy <wa...@riskmetrics.com>.
Ha. Foolish. Thanks for the quick reply.
sebb-2-2 wrote:
>
> On 01/12/2008, CaHamdy <wa...@riskmetrics.com> wrote:
>>
>> I have done the suggested steps and added the function to the bshrc
>> file, but
>> when I put ${__BeanShell(generateRandomString(20))} as the value for a
>> parameter in an HTTP request, it doesn't work - the parameter gets
>> listed,
>> but its value is blank, null, "", whatever you would like to call it.
>>
>> Is it a problem with making sure I have
>> #beanshell.function.init=BeanShellFunction.bshrc enabled? It exists in
>> my
>> properties file, so I'm assuming this means that it is enabled.
>
> # starts a comment, so it is not enabled unless you remove the leading #.
>
>> Thanks for any help.
>>
>>
>>
>> hillybilly wrote:
>> >
>> > in your jmeter.properties file, check if you have
>> > #beanshell.function.init=BeanShellFunction.bshrc
>> > enabled.
>> >
>> > in order to use beanshell, download the jar file from
>> > http://www.beanshell.org/bsh-2.0b4.jar
>> > and put it in jmeter's lib-directory.
>> >
>> > put
>> > >> ${__BeanShell(generateRandomString(20))}
>> > in your sampler, wherever you need your random string. i guess you
>> want to
>> > use it as a parameter value.
>> >
>> > for more info, read
>> >
>> http://jakarta.apache.org/jmeter/usermanual/functions.html#__BeanShell.
>> >
>> > //chris
>> >
>> >
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > 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/Creating-Random-Names-or-Characters-tp10298855p20780380.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/Creating-Random-Names-or-Characters-tp10298855p20781019.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: Creating Random Names or Characters
Posted by sebb <se...@gmail.com>.
On 01/12/2008, CaHamdy <wa...@riskmetrics.com> wrote:
>
> I have done the suggested steps and added the function to the bshrc file, but
> when I put ${__BeanShell(generateRandomString(20))} as the value for a
> parameter in an HTTP request, it doesn't work - the parameter gets listed,
> but its value is blank, null, "", whatever you would like to call it.
>
> Is it a problem with making sure I have
> #beanshell.function.init=BeanShellFunction.bshrc enabled? It exists in my
> properties file, so I'm assuming this means that it is enabled.
# starts a comment, so it is not enabled unless you remove the leading #.
> Thanks for any help.
>
>
>
> hillybilly wrote:
> >
> > in your jmeter.properties file, check if you have
> > #beanshell.function.init=BeanShellFunction.bshrc
> > enabled.
> >
> > in order to use beanshell, download the jar file from
> > http://www.beanshell.org/bsh-2.0b4.jar
> > and put it in jmeter's lib-directory.
> >
> > put
> > >> ${__BeanShell(generateRandomString(20))}
> > in your sampler, wherever you need your random string. i guess you want to
> > use it as a parameter value.
> >
> > for more info, read
> > http://jakarta.apache.org/jmeter/usermanual/functions.html#__BeanShell.
> >
> > //chris
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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/Creating-Random-Names-or-Characters-tp10298855p20780380.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: Creating Random Names or Characters
Posted by CaHamdy <wa...@riskmetrics.com>.
I have done the suggested steps and added the function to the bshrc file, but
when I put ${__BeanShell(generateRandomString(20))} as the value for a
parameter in an HTTP request, it doesn't work - the parameter gets listed,
but its value is blank, null, "", whatever you would like to call it.
Is it a problem with making sure I have
#beanshell.function.init=BeanShellFunction.bshrc enabled? It exists in my
properties file, so I'm assuming this means that it is enabled.
Thanks for any help.
hillybilly wrote:
>
> in your jmeter.properties file, check if you have
> #beanshell.function.init=BeanShellFunction.bshrc
> enabled.
>
> in order to use beanshell, download the jar file from
> http://www.beanshell.org/bsh-2.0b4.jar
> and put it in jmeter's lib-directory.
>
> put
> >> ${__BeanShell(generateRandomString(20))}
> in your sampler, wherever you need your random string. i guess you want to
> use it as a parameter value.
>
> for more info, read
> http://jakarta.apache.org/jmeter/usermanual/functions.html#__BeanShell.
>
> //chris
>
>
>
>
>
> ---------------------------------------------------------------------
> 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/Creating-Random-Names-or-Characters-tp10298855p20780380.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: Creating Random Names or Characters
Posted by chris <hi...@gmx.at>.
in your jmeter.properties file, check if you have
#beanshell.function.init=BeanShellFunction.bshrc
enabled.
in order to use beanshell, download the jar file from
http://www.beanshell.org/bsh-2.0b4.jar
and put it in jmeter's lib-directory.
put
>> ${__BeanShell(generateRandomString(20))}
in your sampler, wherever you need your random string. i guess you want to
use it as a parameter value.
for more info, read
http://jakarta.apache.org/jmeter/usermanual/functions.html#__BeanShell.
//chris
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: Creating Random Names or Characters
Posted by mahesh kumar <pm...@gmail.com>.
Hi chris,
I added the below function in BeanShellFunction.bshrc file.Please let me
know how and where I have to use this function.
Mahesh....
On 5/4/07, chris <hi...@gmx.at> wrote:
>
> in your BeanShellFunction.bshrc file, you can define following method (i
> use
> it in my testplans and it works perfectly):
>
> // generates a random string with length n
> // string consists of number, uppercase letters and lowercase letters
> String generateRandomString(int n) {
> char[] pw = new char[n];
> int c = 'A';
> int r1 = 0;
> for (int i=0; i < n; i++) {
> r1 = (int)(Math.random() * 3);
> switch(r1) {
> case 0: c = '0' + (int)(Math.random() * 10); break;
> case 1: c = 'a' + (int)(Math.random() * 26); break;
> case 2: c = 'A' + (int)(Math.random() * 26); break;
> }
> pw[i] = (char)c;
> }
> return new String(pw);
> }
>
> call this function in your jmeter testplan with
> ${__BeanShell(generateRandomString(20))}
>
> //chris
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
Re: Creating Random Names or Characters
Posted by chris <hi...@gmx.at>.
in your BeanShellFunction.bshrc file, you can define following method (i use
it in my testplans and it works perfectly):
// generates a random string with length n
// string consists of number, uppercase letters and lowercase letters
String generateRandomString(int n) {
char[] pw = new char[n];
int c = 'A';
int r1 = 0;
for (int i=0; i < n; i++) {
r1 = (int)(Math.random() * 3);
switch(r1) {
case 0: c = '0' + (int)(Math.random() * 10); break;
case 1: c = 'a' + (int)(Math.random() * 26); break;
case 2: c = 'A' + (int)(Math.random() * 26); break;
}
pw[i] = (char)c;
}
return new String(pw);
}
call this function in your jmeter testplan with
${__BeanShell(generateRandomString(20))}
//chris
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: Creating Random Names or Characters
Posted by sebb <se...@gmail.com>.
But if you need a lot of random strings, it would be better to create
a file containing the strings and then use CSV Data Set or
StringFromFile to read it.
[You could use the code to create the file.]
S.
On 03/05/07, Matthew Coventon <ma...@iseinc.biz> wrote:
> Here is a link to some java code that generates random strings:
> http://www.koders.com/java/fid469723E78254774BEC5E0E17D580B2DA38BA3658.aspx.
>
> With a little modification, you could use it in a Beanshell Preprocessor to
> generate a random string. In the beanshell you would put the string in a
> variable using vars.put("myString", randomString).
>
> Then you can use ${myString} in your sampler.
>
> Regards,
>
> Matt C.
>
> -----Original Message-----
> From: Senthil Kumaran [mailto:senthilk@proaxiom.co.nz]
> Sent: Thursday, May 03, 2007 12:40 AM
> To: JMeter Users List
> Subject: Re: Creating Random Names or Characters
>
> Hi,
> Thanks for the response,
> I want create random dynamic string in the name field of the web
> application in the registeration form.
> For eg:
> _ random function is used to create random numbers.
> Is there any javascript function or any other function to perform it.
>
> Thanks
> Senthil
>
>
> gopal labudu wrote:
>
> > we can send string or characters by using parameterization
> > we have to use ${_StringFromFile(name)} function.
> >
> >
> >
> >
> > On 5/3/07, Senthil Kumaran <se...@proaxiom.co.nz> wrote:
> >
> >>
> >> Hi,
> >>
> >> I am trying to create a random string or character in the name field of
> >> the web application.
> >> So that i can create dynamic names to post the http request.
> >> Is it possible to create a random string or characters in jmeter.
> >>
> >> Thanks and Regards,
> >> Senthil
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
>
>
>
> ---------------------------------------------------------------------
> 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: Creating Random Names or Characters
Posted by Matthew Coventon <ma...@iseinc.biz>.
Here is a link to some java code that generates random strings:
http://www.koders.com/java/fid469723E78254774BEC5E0E17D580B2DA38BA3658.aspx.
With a little modification, you could use it in a Beanshell Preprocessor to
generate a random string. In the beanshell you would put the string in a
variable using vars.put("myString", randomString).
Then you can use ${myString} in your sampler.
Regards,
Matt C.
-----Original Message-----
From: Senthil Kumaran [mailto:senthilk@proaxiom.co.nz]
Sent: Thursday, May 03, 2007 12:40 AM
To: JMeter Users List
Subject: Re: Creating Random Names or Characters
Hi,
Thanks for the response,
I want create random dynamic string in the name field of the web
application in the registeration form.
For eg:
_ random function is used to create random numbers.
Is there any javascript function or any other function to perform it.
Thanks
Senthil
gopal labudu wrote:
> we can send string or characters by using parameterization
> we have to use ${_StringFromFile(name)} function.
>
>
>
>
> On 5/3/07, Senthil Kumaran <se...@proaxiom.co.nz> wrote:
>
>>
>> Hi,
>>
>> I am trying to create a random string or character in the name field of
>> the web application.
>> So that i can create dynamic names to post the http request.
>> Is it possible to create a random string or characters in jmeter.
>>
>> Thanks and Regards,
>> Senthil
>>
>>
>> ---------------------------------------------------------------------
>> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: Creating Random Names or Characters
Posted by gopal labudu <go...@gmail.com>.
there is random function in java script which picks a random value
On 5/3/07, Senthil Kumaran <se...@proaxiom.co.nz> wrote:
>
> Hi,
> Thanks for the response,
> I want create random dynamic string in the name field of the web
> application in the registeration form.
> For eg:
> _ random function is used to create random numbers.
> Is there any javascript function or any other function to perform it.
>
> Thanks
> Senthil
>
>
> gopal labudu wrote:
>
> > we can send string or characters by using parameterization
> > we have to use ${_StringFromFile(name)} function.
> >
> >
> >
> >
> > On 5/3/07, Senthil Kumaran <se...@proaxiom.co.nz> wrote:
> >
> >>
> >> Hi,
> >>
> >> I am trying to create a random string or character in the name field
> of
> >> the web application.
> >> So that i can create dynamic names to post the http request.
> >> Is it possible to create a random string or characters in jmeter.
> >>
> >> Thanks and Regards,
> >> Senthil
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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: Creating Random Names or Characters
Posted by Senthil Kumaran <se...@proaxiom.co.nz>.
Hi,
Thanks for the response,
I want create random dynamic string in the name field of the web
application in the registeration form.
For eg:
_ random function is used to create random numbers.
Is there any javascript function or any other function to perform it.
Thanks
Senthil
gopal labudu wrote:
> we can send string or characters by using parameterization
> we have to use ${_StringFromFile(name)} function.
>
>
>
>
> On 5/3/07, Senthil Kumaran <se...@proaxiom.co.nz> wrote:
>
>>
>> Hi,
>>
>> I am trying to create a random string or character in the name field of
>> the web application.
>> So that i can create dynamic names to post the http request.
>> Is it possible to create a random string or characters in jmeter.
>>
>> Thanks and Regards,
>> Senthil
>>
>>
>> ---------------------------------------------------------------------
>> 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: Creating Random Names or Characters
Posted by gopal labudu <go...@gmail.com>.
we can send string or characters by using parameterization
we have to use ${_StringFromFile(name)} function.
On 5/3/07, Senthil Kumaran <se...@proaxiom.co.nz> wrote:
>
> Hi,
>
> I am trying to create a random string or character in the name field of
> the web application.
> So that i can create dynamic names to post the http request.
> Is it possible to create a random string or characters in jmeter.
>
> Thanks and Regards,
> Senthil
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>