Return-Path: X-Original-To: apmail-jmeter-user-archive@www.apache.org Delivered-To: apmail-jmeter-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1F51F92EA for ; Thu, 26 Jan 2012 09:50:58 +0000 (UTC) Received: (qmail 35473 invoked by uid 500); 26 Jan 2012 09:50:57 -0000 Delivered-To: apmail-jmeter-user-archive@jmeter.apache.org Received: (qmail 35090 invoked by uid 500); 26 Jan 2012 09:50:47 -0000 Mailing-List: contact user-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "JMeter Users List" Delivered-To: mailing list user@jmeter.apache.org Received: (qmail 35080 invoked by uid 99); 26 Jan 2012 09:50:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jan 2012 09:50:44 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of philippe.mouawad@gmail.com designates 209.85.210.171 as permitted sender) Received: from [209.85.210.171] (HELO mail-iy0-f171.google.com) (209.85.210.171) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jan 2012 09:50:37 +0000 Received: by iaeh11 with SMTP id h11so635369iae.2 for ; Thu, 26 Jan 2012 01:50:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=OLdDCExiChlRxMU6u8HRgN8XA8+ExcDKKBoIjI9m2bs=; b=lEx43XNSsL1khX+7ZH66WnQu8mrnavbit4l9ROGX467oP0DC/KZaCXll7SKJWnQ0Fj vLmW/2BhJCp96YmNl8jBLPjOZWffFM66wxGrHE1jQmkaEXvpKfpggDA1XT6JCcxvVIke NctWY9uRNtI7KDJEpGrBtgretKb4Jej9BSuPY= MIME-Version: 1.0 Received: by 10.50.6.194 with SMTP id d2mr1440124iga.24.1327571416084; Thu, 26 Jan 2012 01:50:16 -0800 (PST) Received: by 10.231.28.26 with HTTP; Thu, 26 Jan 2012 01:50:16 -0800 (PST) In-Reply-To: <1327570980546-5432410.post@n5.nabble.com> References: <1327570980546-5432410.post@n5.nabble.com> Date: Thu, 26 Jan 2012 10:50:16 +0100 Message-ID: Subject: Re: Setting random string in a text field From: Philippe Mouawad To: JMeter Users List Content-Type: multipart/alternative; boundary=e89a8f502a56ab706d04b76b4eed X-Virus-Checked: Checked by ClamAV on apache.org --e89a8f502a56ab706d04b76b4eed Content-Type: text/plain; charset=ISO-8859-1 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 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 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. --e89a8f502a56ab706d04b76b4eed--