You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Bob <b....@gmail.com> on 2015/05/11 12:26:28 UTC

What is alternative function of __P() and __property() for variables?

Hi,

What is alternative function of __P() and __property() for variables in 
JMeter? How I can define the condition: if Var1 is empty use default 
value or another variable? Thanks!

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


Re: What is alternative function of __P() and __property() for variables?

Posted by Bob <b....@gmail.com>.
Thanks sebb. It would be useful to have function similar to __P() or 
__property() for variables.

On 11/05/15 15:47, sebb wrote:
> On 11 May 2015 at 11:26, Bob <b....@gmail.com> wrote:
>> Hi,
>>
>> What is alternative function of __P() and __property() for variables in
>> JMeter? How I can define the condition: if Var1 is empty use default value
>> or another variable? Thanks!
> There is no such function currently.
>
> __P() was added in order to allow access to properties.
> As an option, a default was provided.
>
> If there is sufficient demand for this, I guess __V() could be
> extended to provide the same functionality for variables.
>
> In the meantime, one could use a scripting element (or Beanshell
> function) to do the work.
>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail: user-help@jmeter.apache.org
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>


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


Re: What is alternative function of __P() and __property() for variables?

Posted by sebb <se...@gmail.com>.
On 11 May 2015 at 11:26, Bob <b....@gmail.com> wrote:
> Hi,
>
> What is alternative function of __P() and __property() for variables in
> JMeter? How I can define the condition: if Var1 is empty use default value
> or another variable? Thanks!

There is no such function currently.

__P() was added in order to allow access to properties.
As an option, a default was provided.

If there is sufficient demand for this, I guess __V() could be
extended to provide the same functionality for variables.

In the meantime, one could use a scripting element (or Beanshell
function) to do the work.

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

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


RE: What is alternative function of __P() and __property() for variables?

Posted by Erez Naim <er...@theneura.com>.
So just use preprocessor beanshell sampler inside your http sampler and then insert the desired value into the http sampler.

-----Original Message-----
From: Bob [mailto:b.meliev@gmail.com] 
Sent: Monday, May 11, 2015 2:37 PM
To: JMeter Users List
Subject: Re: What is alternative function of __P() and __property() for variables?

Erez, I'm using it inside HTTP Sampler.

On 11/05/15 16:24, Erez Naim wrote:
> Where do u want to use ? while loop? If you want to use it in while loop you can use this condition:
>
> ${__javaScript("${var}"  !=  null)}
>
> Use afterwards beanshell processor which will get into the sampler and put a variable into it by using beanshell functions like "vars.put" and "vars.get".
>
> Good luck!
>
> --Erez--
>
> -----Original Message-----
> From: Bob [mailto:b.meliev@gmail.com]
> Sent: Monday, May 11, 2015 1:26 PM
> To: JMeter Users List
> Subject: What is alternative function of __P() and __property() for variables?
>
> Hi,
>
> What is alternative function of __P() and __property() for variables in JMeter? How I can define the condition: if Var1 is empty use default value or another variable? Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>


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



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


Re: What is alternative function of __P() and __property() for variables?

Posted by sebb <se...@gmail.com>.
On 11 May 2015 at 13:01, Flavio Cysne <fl...@gmail.com> wrote:
> As sebb said you can use __V() similarly to __P().

Not yet, you cannot.

__V() does not (currently) provide a default if the variable is undefined.

> There's also the
> __javaScript as one of the alternatives. Another, is using __eval() as it
> will process the content of the named variable and return the resulted
> variable content.

I don't see how __eval() could be used to return a default if the
variable is not defined, but perhaps I'm missing something.

> As Erez said there's the alternative of using a BeanShell
> pre-proceasor and, as well, the __BeanShell() function.
>
> __javaScript() function is the least performatic of the alternatives,
> followed closely by BeanShell.

There is also a Jexl funtion, which may be more efficient, as well as
JSR223 elements that can use other scripting languages such as Groovy.

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


Re: What is alternative function of __P() and __property() for variables?

Posted by Flavio Cysne <fl...@gmail.com>.
As sebb said you can use __V() similarly to __P(). There's also the
__javaScript as one of the alternatives. Another, is using __eval() as it
will process the content of the named variable and return the resulted
variable content. As Erez said there's the alternative of using a BeanShell
pre-proceasor and, as well, the __BeanShell() function.

__javaScript() function is the least performatic of the alternatives,
followed closely by BeanShell.

Re: What is alternative function of __P() and __property() for variables?

Posted by Bob <b....@gmail.com>.
Erez, I'm using it inside HTTP Sampler.

On 11/05/15 16:24, Erez Naim wrote:
> Where do u want to use ? while loop? If you want to use it in while loop you can use this condition:
>
> ${__javaScript("${var}"  !=  null)}
>
> Use afterwards beanshell processor which will get into the sampler and put a variable into it by using beanshell functions like "vars.put" and "vars.get".
>
> Good luck!
>
> --Erez--
>
> -----Original Message-----
> From: Bob [mailto:b.meliev@gmail.com]
> Sent: Monday, May 11, 2015 1:26 PM
> To: JMeter Users List
> Subject: What is alternative function of __P() and __property() for variables?
>
> Hi,
>
> What is alternative function of __P() and __property() for variables in JMeter? How I can define the condition: if Var1 is empty use default value or another variable? Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>


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


RE: What is alternative function of __P() and __property() for variables?

Posted by Erez Naim <er...@theneura.com>.
Where do u want to use ? while loop? If you want to use it in while loop you can use this condition: 

${__javaScript("${var}"  !=  null)}

Use afterwards beanshell processor which will get into the sampler and put a variable into it by using beanshell functions like "vars.put" and "vars.get".

Good luck! 

--Erez--

-----Original Message-----
From: Bob [mailto:b.meliev@gmail.com] 
Sent: Monday, May 11, 2015 1:26 PM
To: JMeter Users List
Subject: What is alternative function of __P() and __property() for variables?

Hi,

What is alternative function of __P() and __property() for variables in JMeter? How I can define the condition: if Var1 is empty use default value or another variable? Thanks!

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



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