You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by sprozzy <da...@jhc.co.uk> on 2010/09/24 16:56:37 UTC

Create random variable then use same variable

Hi, I am currently working on creating a randon variable (Stock$).  When the
variable is first created I then want to use the same variable throughout
the script.

How is this possible.

Many thanks
-- 
View this message in context: http://jmeter.512774.n5.nabble.com/Create-random-variable-then-use-same-variable-tp2852755p2852755.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: Create random variable then use same variable

Posted by Fazal Syed Ali <sy...@gmail.com>.
Try this: ${__time(YMDHMS, var_name)}

The above expression will take the time stamp and store it in "var_name"
variable. You can refer to it later in your script by using ${var_name}.

This should give you randomness since the time stamp will be different each
time you run the script.

Thanks
Fazal


On Fri, Sep 24, 2010 at 9:56 AM, sprozzy <da...@jhc.co.uk> wrote:

>
> Hi, I am currently working on creating a randon variable (Stock$).  When
> the
> variable is first created I then want to use the same variable throughout
> the script.
>
> How is this possible.
>
> Many thanks
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/Create-random-variable-then-use-same-variable-tp2852755p2852755.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
>
>


-- 
Syed Fazal Ali

Re: Create random variable then use same variable

Posted by sebb <se...@gmail.com>.
On 24 September 2010 16:31, sprozzy <da...@jhc.co.uk> wrote:
>
> Hi Sebb
>
> Ive created a UDP for two values and I want these values to be random.  I
> then enter into a screen for a check of the value which then defaults to a
> name.
>
> On another screen I then want to use the same random value generated and
> enter this value into a field.

Either use another UDV (because it cannot refer to variables created
on the same UDV) or use:
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#User_Parameters

to define the following Name / Value

StockId             ${__V(Stock${__Random(1,2)})}

Then use ${StockId} in the plan.

But for larger numbers of random variables, it would be better to
create a file and use CSV Dataset.

> Hope this is helpful.
>
> Thanks
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/Create-random-variable-then-use-same-variable-tp2852755p2852815.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: Create random variable then use same variable

Posted by sprozzy <da...@jhc.co.uk>.
Hi Sebb

Ive created a UDP for two values and I want these values to be random.  I
then enter into a screen for a check of the value which then defaults to a
name.

On another screen I then want to use the same random value generated and
enter this value into a field.

Hope this is helpful.

Thanks
-- 
View this message in context: http://jmeter.512774.n5.nabble.com/Create-random-variable-then-use-same-variable-tp2852755p2852815.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: Create random variable then use same variable

Posted by sebb <se...@gmail.com>.
On 24 September 2010 16:21, sprozzy <da...@jhc.co.uk> wrote:
>
> Hi,
>
> The first string that I am using is:
>
> ${__V(Stock${__Random(1,2,)})}

Where are you using this?

Just assign it to a variable.

But why are you using a random variable name?
What are you trying to achieve?

>
> Then I want to ensure that this is the same all through the script.
>
> I have tried the following:
>
> ${Stock$}
> ${__V(Stock$)}
>
> Both of which do not work, any ideas???
>
> Thanks
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/Create-random-variable-then-use-same-variable-tp2852755p2852795.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: Create random variable then use same variable

Posted by sprozzy <da...@jhc.co.uk>.
Hi,

The first string that I am using is:

${__V(Stock${__Random(1,2,)})}

Then I want to ensure that this is the same all through the script.

I have tried the following:

${Stock$}
${__V(Stock$)}

Both of which do not work, any ideas???

Thanks
-- 
View this message in context: http://jmeter.512774.n5.nabble.com/Create-random-variable-then-use-same-variable-tp2852755p2852795.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: want a 400 response to pass

Posted by sebb <se...@gmail.com>.
On 24 September 2010 16:17, Ray Trejo <ra...@rackspace.com> wrote:
> Hi,
>
> I create a new user thru my API.  I then attempt to add the same user again.  I receive a 400 response code from the API, which is by design.  Jmeter displays this as a failure.  I added a response assertion which has response code matches 400, but Jmeter fails the request before it executes the response assertion.
>
> I would like Jmeter to hit the response assertion of 400 and not fail the request.
>
> Any ideas?

Use the Response Assertion / Ignore Status checkbox

BTW, please start a new thread when asking a new question.
It's confusing to see irrelevant responses to different question as
part of the posting (so I've removed them here)

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


want a 400 response to pass

Posted by Ray Trejo <ra...@rackspace.com>.
Hi,

I create a new user thru my API.  I then attempt to add the same user again.  I receive a 400 response code from the API, which is by design.  Jmeter displays this as a failure.  I added a response assertion which has response code matches 400, but Jmeter fails the request before it executes the response assertion.

I would like Jmeter to hit the response assertion of 400 and not fail the request.

Any ideas?

Ray



-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com] 
Sent: Friday, September 24, 2010 10:11 AM
To: JMeter Users List
Subject: Re: Create random variable then use same variable

On 24 September 2010 15:56, sprozzy <da...@jhc.co.uk> wrote:
>
> Hi, I am currently working on creating a randon variable (Stock$).  When the
> variable is first created I then want to use the same variable throughout
> the script.
>
> How is this possible.

Just refer to the variable by name, i.e. ${Stock$}

> Many thanks
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/Create-random-variable-then-use-same-variable-tp2852755p2852755.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



Confidentiality Notice: This e-mail message (including any attached or
embedded documents) is intended for the exclusive and confidential use of the
individual or entity to which this message is addressed, and unless otherwise
expressly indicated, is confidential and privileged information of Rackspace.
Any dissemination, distribution or copying of the enclosed material is prohibited.
If you receive this transmission in error, please notify us immediately by e-mail
at abuse@rackspace.com, and delete the original message.
Your cooperation is appreciated.


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


Re: Create random variable then use same variable

Posted by sebb <se...@gmail.com>.
On 24 September 2010 15:56, sprozzy <da...@jhc.co.uk> wrote:
>
> Hi, I am currently working on creating a randon variable (Stock$).  When the
> variable is first created I then want to use the same variable throughout
> the script.
>
> How is this possible.

Just refer to the variable by name, i.e. ${Stock$}

> Many thanks
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/Create-random-variable-then-use-same-variable-tp2852755p2852755.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