You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Wei Z <we...@perceptive.com> on 2009/10/15 17:59:58 UTC

How to set default value to null for Regular Expression Extractor

Hi,
I want to return a value null (i.e. blank) if now matches are found. I've
tried few things, e.g. leave the default value field blank, put a variable
name in the field and define the variable to have value "", etc.
But I just can't get a null value. Has anybody done this or does anybody
know how to do this? Your help would be much appreciated.

Wei
-- 
View this message in context: http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25911259.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: How to set default value to null for Regular Expression Extractor

Posted by Wei Z <we...@perceptive.com>.
Thanks deepak. It indeed works. My problem was that my jarascripts had wrong
syntax, I think. (I'm not very familiar with javascripts and the syntax that
is acceptable by JMeter).

Cheers,

Wei


Deepak Shetty wrote:
> 
> I just tried it works . The javascript function is the value specified in
> Send Parameters with request and it correctly sends blank or the actual
> value.
> Im not sure what you mean by null value , in http a null would be the same
> as not sending a parameter (and not sending it empty)
> Is that what you want? If not can you please illustrate what your test is
> and what you expect to happen ?
> 
> regards
> deepak
> 
> On Fri, Oct 16, 2009 at 9:31 AM, Wei Z <we...@perceptive.com> wrote:
> 
>>
>> Thanks deepak. I've tried this approach already, but whenever a null
>> value
>> was expected, it didn't work.
>> It seems a null value just cannot be returned.
>>
>> Wei
>>
>> Deepak Shetty wrote:
>> >
>> > oh i think I had a space before the javascript and that's why it seemed
>> to
>> > work (as a space, not emptyu)
>> >
>> > You can always use __javaScript function to check the value of the
>> > variable
>> > against the default.
>> > e.g. in the regex specify the default value as NOT_FOUND
>> > and in the parameter specify
>> > ${__javaScript('${YOUR_VAR}' == 'NOT_FOUND' ? '': '${YOUR_VAR}')}
>> >
>> > regards
>> > deepak
>> >
>> > On Fri, Oct 16, 2009 at 1:59 AM, Wei Z <we...@perceptive.com> wrote:
>> >
>> >>
>> >> Thanks for the reply deepak. Tried your suggestion, but it didn't work
>> -
>> >> returned the variable name "${variablename}" rather than a blank
>> string.
>> >> The reason I need a blank string is that I want to send back whatever
>> >> values
>> >> already on the page plus some comments. One of the existing values is
>> a
>> >> dropdown box. If a value has already been selected in the dropdown box
>> >> when
>> >> the page is opened, I will find a match. If a value has not been
>> >> selected,
>> >> the RegEx extractor will not find a match (i.e. the particular text
>> >> phrase
>> >> will not exist on the page). In case, I need to return a blank value -
>> >> any
>> >> other value will cause the request to fail.
>> >> Is this a restriction of JMeter or is there a way to do this?
>> >>
>> >> Wei
>> >>
>> >> Deepak Shetty wrote:
>> >> >
>> >> > Truly fugly but
>> >> > ${__javaScript('')} seems to work.
>> >> >
>> >> > I'd question why you need blank (would spaces work?) . other options
>> >> would
>> >> > be BSH listener to form the variable as you want.
>> >> > regards
>> >> > deepak
>> >> >
>> >> > On Thu, Oct 15, 2009 at 8:59 AM, Wei Z <we...@perceptive.com>
>> wrote:
>> >> >
>> >> >>
>> >> >> Hi,
>> >> >> I want to return a value null (i.e. blank) if now matches are
>> found.
>> >> I've
>> >> >> tried few things, e.g. leave the default value field blank, put a
>> >> >> variable
>> >> >> name in the field and define the variable to have value "", etc.
>> >> >> But I just can't get a null value. Has anybody done this or does
>> >> anybody
>> >> >> know how to do this? Your help would be much appreciated.
>> >> >>
>> >> >> Wei
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25911259.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
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25922069.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
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25928321.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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25928828.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: How to set default value to null for Regular Expression Extractor

Posted by Deepak Shetty <sh...@gmail.com>.
I just tried it works . The javascript function is the value specified in
Send Parameters with request and it correctly sends blank or the actual
value.
Im not sure what you mean by null value , in http a null would be the same
as not sending a parameter (and not sending it empty)
Is that what you want? If not can you please illustrate what your test is
and what you expect to happen ?

regards
deepak

On Fri, Oct 16, 2009 at 9:31 AM, Wei Z <we...@perceptive.com> wrote:

>
> Thanks deepak. I've tried this approach already, but whenever a null value
> was expected, it didn't work.
> It seems a null value just cannot be returned.
>
> Wei
>
> Deepak Shetty wrote:
> >
> > oh i think I had a space before the javascript and that's why it seemed
> to
> > work (as a space, not emptyu)
> >
> > You can always use __javaScript function to check the value of the
> > variable
> > against the default.
> > e.g. in the regex specify the default value as NOT_FOUND
> > and in the parameter specify
> > ${__javaScript('${YOUR_VAR}' == 'NOT_FOUND' ? '': '${YOUR_VAR}')}
> >
> > regards
> > deepak
> >
> > On Fri, Oct 16, 2009 at 1:59 AM, Wei Z <we...@perceptive.com> wrote:
> >
> >>
> >> Thanks for the reply deepak. Tried your suggestion, but it didn't work -
> >> returned the variable name "${variablename}" rather than a blank string.
> >> The reason I need a blank string is that I want to send back whatever
> >> values
> >> already on the page plus some comments. One of the existing values is a
> >> dropdown box. If a value has already been selected in the dropdown box
> >> when
> >> the page is opened, I will find a match. If a value has not been
> >> selected,
> >> the RegEx extractor will not find a match (i.e. the particular text
> >> phrase
> >> will not exist on the page). In case, I need to return a blank value -
> >> any
> >> other value will cause the request to fail.
> >> Is this a restriction of JMeter or is there a way to do this?
> >>
> >> Wei
> >>
> >> Deepak Shetty wrote:
> >> >
> >> > Truly fugly but
> >> > ${__javaScript('')} seems to work.
> >> >
> >> > I'd question why you need blank (would spaces work?) . other options
> >> would
> >> > be BSH listener to form the variable as you want.
> >> > regards
> >> > deepak
> >> >
> >> > On Thu, Oct 15, 2009 at 8:59 AM, Wei Z <we...@perceptive.com>
> wrote:
> >> >
> >> >>
> >> >> Hi,
> >> >> I want to return a value null (i.e. blank) if now matches are found.
> >> I've
> >> >> tried few things, e.g. leave the default value field blank, put a
> >> >> variable
> >> >> name in the field and define the variable to have value "", etc.
> >> >> But I just can't get a null value. Has anybody done this or does
> >> anybody
> >> >> know how to do this? Your help would be much appreciated.
> >> >>
> >> >> Wei
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25911259.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
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25922069.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
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25928321.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: How to set default value to null for Regular Expression Extractor

Posted by Wei Z <we...@perceptive.com>.
Thanks deepak. I've tried this approach already, but whenever a null value
was expected, it didn't work.
It seems a null value just cannot be returned.

Wei

Deepak Shetty wrote:
> 
> oh i think I had a space before the javascript and that's why it seemed to
> work (as a space, not emptyu)
> 
> You can always use __javaScript function to check the value of the
> variable
> against the default.
> e.g. in the regex specify the default value as NOT_FOUND
> and in the parameter specify
> ${__javaScript('${YOUR_VAR}' == 'NOT_FOUND' ? '': '${YOUR_VAR}')}
> 
> regards
> deepak
> 
> On Fri, Oct 16, 2009 at 1:59 AM, Wei Z <we...@perceptive.com> wrote:
> 
>>
>> Thanks for the reply deepak. Tried your suggestion, but it didn't work -
>> returned the variable name "${variablename}" rather than a blank string.
>> The reason I need a blank string is that I want to send back whatever
>> values
>> already on the page plus some comments. One of the existing values is a
>> dropdown box. If a value has already been selected in the dropdown box
>> when
>> the page is opened, I will find a match. If a value has not been
>> selected,
>> the RegEx extractor will not find a match (i.e. the particular text
>> phrase
>> will not exist on the page). In case, I need to return a blank value -
>> any
>> other value will cause the request to fail.
>> Is this a restriction of JMeter or is there a way to do this?
>>
>> Wei
>>
>> Deepak Shetty wrote:
>> >
>> > Truly fugly but
>> > ${__javaScript('')} seems to work.
>> >
>> > I'd question why you need blank (would spaces work?) . other options
>> would
>> > be BSH listener to form the variable as you want.
>> > regards
>> > deepak
>> >
>> > On Thu, Oct 15, 2009 at 8:59 AM, Wei Z <we...@perceptive.com> wrote:
>> >
>> >>
>> >> Hi,
>> >> I want to return a value null (i.e. blank) if now matches are found.
>> I've
>> >> tried few things, e.g. leave the default value field blank, put a
>> >> variable
>> >> name in the field and define the variable to have value "", etc.
>> >> But I just can't get a null value. Has anybody done this or does
>> anybody
>> >> know how to do this? Your help would be much appreciated.
>> >>
>> >> Wei
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25911259.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
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25922069.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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25928321.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: How to set default value to null for Regular Expression Extractor

Posted by Deepak Shetty <sh...@gmail.com>.
oh i think I had a space before the javascript and that's why it seemed to
work (as a space, not emptyu)

You can always use __javaScript function to check the value of the variable
against the default.
e.g. in the regex specify the default value as NOT_FOUND
and in the parameter specify
${__javaScript('${YOUR_VAR}' == 'NOT_FOUND' ? '': '${YOUR_VAR}')}

regards
deepak

On Fri, Oct 16, 2009 at 1:59 AM, Wei Z <we...@perceptive.com> wrote:

>
> Thanks for the reply deepak. Tried your suggestion, but it didn't work -
> returned the variable name "${variablename}" rather than a blank string.
> The reason I need a blank string is that I want to send back whatever
> values
> already on the page plus some comments. One of the existing values is a
> dropdown box. If a value has already been selected in the dropdown box when
> the page is opened, I will find a match. If a value has not been selected,
> the RegEx extractor will not find a match (i.e. the particular text phrase
> will not exist on the page). In case, I need to return a blank value - any
> other value will cause the request to fail.
> Is this a restriction of JMeter or is there a way to do this?
>
> Wei
>
> Deepak Shetty wrote:
> >
> > Truly fugly but
> > ${__javaScript('')} seems to work.
> >
> > I'd question why you need blank (would spaces work?) . other options
> would
> > be BSH listener to form the variable as you want.
> > regards
> > deepak
> >
> > On Thu, Oct 15, 2009 at 8:59 AM, Wei Z <we...@perceptive.com> wrote:
> >
> >>
> >> Hi,
> >> I want to return a value null (i.e. blank) if now matches are found.
> I've
> >> tried few things, e.g. leave the default value field blank, put a
> >> variable
> >> name in the field and define the variable to have value "", etc.
> >> But I just can't get a null value. Has anybody done this or does anybody
> >> know how to do this? Your help would be much appreciated.
> >>
> >> Wei
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25911259.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
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25922069.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: How to set default value to null for Regular Expression Extractor

Posted by Wei Z <we...@perceptive.com>.
Thanks for the reply deepak. Tried your suggestion, but it didn't work -
returned the variable name "${variablename}" rather than a blank string.
The reason I need a blank string is that I want to send back whatever values
already on the page plus some comments. One of the existing values is a
dropdown box. If a value has already been selected in the dropdown box when
the page is opened, I will find a match. If a value has not been selected,
the RegEx extractor will not find a match (i.e. the particular text phrase
will not exist on the page). In case, I need to return a blank value - any
other value will cause the request to fail.
Is this a restriction of JMeter or is there a way to do this?

Wei

Deepak Shetty wrote:
> 
> Truly fugly but
> ${__javaScript('')} seems to work.
> 
> I'd question why you need blank (would spaces work?) . other options would
> be BSH listener to form the variable as you want.
> regards
> deepak
> 
> On Thu, Oct 15, 2009 at 8:59 AM, Wei Z <we...@perceptive.com> wrote:
> 
>>
>> Hi,
>> I want to return a value null (i.e. blank) if now matches are found. I've
>> tried few things, e.g. leave the default value field blank, put a
>> variable
>> name in the field and define the variable to have value "", etc.
>> But I just can't get a null value. Has anybody done this or does anybody
>> know how to do this? Your help would be much appreciated.
>>
>> Wei
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25911259.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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25922069.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: How to set default value to null for Regular Expression Extractor

Posted by Deepak Shetty <sh...@gmail.com>.
Truly fugly but
${__javaScript('')} seems to work.

I'd question why you need blank (would spaces work?) . other options would
be BSH listener to form the variable as you want.
regards
deepak

On Thu, Oct 15, 2009 at 8:59 AM, Wei Z <we...@perceptive.com> wrote:

>
> Hi,
> I want to return a value null (i.e. blank) if now matches are found. I've
> tried few things, e.g. leave the default value field blank, put a variable
> name in the field and define the variable to have value "", etc.
> But I just can't get a null value. Has anybody done this or does anybody
> know how to do this? Your help would be much appreciated.
>
> Wei
> --
> View this message in context:
> http://www.nabble.com/How-to-set-default-value-to-null-for-Regular-Expression-Extractor-tp25911259p25911259.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
>
>