jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Mouawad <philippe.moua...@gmail.com>
Subject Re: Setting random string in a text field
Date Thu, 26 Jan 2012 09:50:16 GMT
Note that if you use latest nightly build that will be very close to next
2.6 release , you have a new function __RandomString
with 3 parameters:
- String length
- Chars to use in generation
- Name of variable if you want to store result in a variable.

Regards
Philippe

On Thu, Jan 26, 2012 at 10:43 AM, ZK <stevesenior69@gmail.com> wrote:

> Hi,
> you could use this JAVA code in a beanshell PreProcessor:
> //code start
> import java.util.Random;
>
> chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
> int string_length = 8;
> randomstring ="";
>    for (int i=0; i<string_length; i++) {
>        Random randomGenerator = new Random();
>        int randomInt = randomGenerator.nextInt(chars.length());
>        randomstring += chars.substring(randomInt,randomInt+1);
>    }
>
> vars.put("yourValue",randomstring);
> //code end
>
>
>
>
> The above code creates a random string and outputs to the variable
> yourValue
> This can be accessed in the normal way by using:
> ${yourValue}
>
>
> HTH
> ZK
>
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/Setting-random-string-in-a-text-field-tp5432039p5432410.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>


-- 
Cordialement.
Philippe Mouawad.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message