You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Steve Eckhart <St...@wausaufs.com> on 2009/08/28 15:36:39 UTC

Help With Passing Multiple Variables From a Regular Expression Extractor

I am having difficulty understanding how to pull multiple values from a Regular Expression Extractor and pass them along in my script.

Basically, here's what I'm trying to accomplish:

1.     Submit a form which will return 0 or more links to other pages. Each link has four parameters which I need to pull out for later processing.

2.     Randomly select one of the links.

3.     Put the four parameters into four variables for use by another Controller.

Here's what I tried (which doesn't seem to work):

*         HTTP Request

o    Regular Expression Extractor-Var (all of the Var on the page will be the same value)

o    Random Variable from 1 to ${Var_matchNr} called Sample

o    Regular Expression Extractor with Match No. set to ${Sample} for each of the other parameters.

When I run this with a Debug Sampler, Sample is not getting set to anything.

Is there a way to just set a variable to a value during processing? Is there a better way to do what I'm doing?

Thanks,

Steve Eckhart
Business Analyst/Project Manager

WAUSAU Financial Systems
14010 FNB PKWY STE500
Omaha, NE 68154-5206
Main: (402) 431-8810
Direct line: (402) 715-9382
Cellular: (402) 510-5387
Email: steve.eckhart@wausaufs.com<bl...@wausaufs.com>

Enterprise Payment Solutions.
CONFIDENTIALITY NOTICE:  This electronic transmission (including files attached hereto) is intended only for the use of the individual or entity named above.  If the reader of this message is not the intended recipient, you are hereby notified that any disclosure, dissemination, copying, distribution or taking of any action in reliance on the contents of this confidential information is strictly prohibited.  If you have received this communication in error, please destroy it and immediately notify us by return email.  Thank you.

Re: Help With Passing Multiple Variables From a Regular Expression Extractor

Posted by sebb <se...@gmail.com>.
On 28/08/2009, Steve Eckhart <St...@wausaufs.com> wrote:
> I can't use Match No = 0 because I could get a different link for each of the three Regular Expression Extractors.  I need each part from the same link.
>
>  This would be fairly simple if I understood how to assign a variable directly. For example, suppose I have:
>
>  Var_1_g=3
>  Var_1_g0=href="pagerequest.aspx?a=7000&amp;b=104&amp;c=12047
>  Var_1_g1=7000
>  Var_1_g2=104
>  Var_1_g3=12047
>
>  What I would like to end up with is three output variables:
>
>  A = Var_1_g1 = 7000
>  B = Var_1_g2 = 104
>  C = Var_1_g3 = 12047

You can create variables using

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#User_Parameters

Name:    User_1:

A          ${Var_1_g1}

etc.

If you want to change the _1_ part of the Regex var, you will need to
use the function

http://jakarta.apache.org/jmeter/usermanual/functions.html#__V

i.e.

A        ${__V(Var_${N}_g1)}

where N=1

>  I can't figure out from the documentation how to set the value of a variable outside of a Regular Expression Extractor or a Random Variable.
>
>  Steve
>
>
>  -----Original Message-----
>  From: sebb [mailto:sebbaz@gmail.com]
>  Sent: Friday, August 28, 2009 12:02 PM
>  To: JMeter Users List
>  Subject: Re: Help With Passing Multiple Variables From a Regular Expression Extractor
>
>  Or just use Match No = 0 and JMeter will choose a match at random.
>
>  On 28/08/2009, Deepak Shetty <sh...@gmail.com> wrote:
>  > Hi
>  >  You'd probably need to check the scoping rules for Random variable config
>  >  element. I think you've created everything as children of the HTTP request
>  >  right?
>  >
>  >  Depending on how easy difficult it is to extract the values i would try
>  >  Option 1
>  >  a. Each Parameter is extracted separately (so in your case you would have 4
>  >  Regex extractors , 1 per parameter)
>  >  b. Use __Random and __V to randomise the index and pick out the value
>  >  http://jakarta.apache.org/jmeter/usermanual/functions.html (I think this is
>  >  what you were trying)
>  >
>  >  Option 2
>  >  If its easier to extract all parameters for 1 type (e.g. they are the query
>  >  string of some url). In this case you only have 1 Regex (each result has all
>  >  parameters and you have multiple results that you want to randomise) , Use a
>  >  beanshell script or function to parse the parameters out and set them into
>  >  variables, and use random again...
>  >
>  >  regards
>  >  deepak
>  >
>  >
>  >  On Fri, Aug 28, 2009 at 6:36 AM, Steve Eckhart
>  >  <St...@wausaufs.com>wrote:
>  >
>  >
>  >  > I am having difficulty understanding how to pull multiple values from a
>  >  > Regular Expression Extractor and pass them along in my script.
>  >  >
>  >  > Basically, here's what I'm trying to accomplish:
>  >  >
>  >  > 1.     Submit a form which will return 0 or more links to other pages. Each
>  >  > link has four parameters which I need to pull out for later processing.
>  >  >
>  >  > 2.     Randomly select one of the links.
>  >  >
>  >  > 3.     Put the four parameters into four variables for use by another
>  >  > Controller.
>  >  >
>  >  > Here's what I tried (which doesn't seem to work):
>  >  >
>  >  > *         HTTP Request
>  >  >
>  >  > o    Regular Expression Extractor-Var (all of the Var on the page will be
>  >  > the same value)
>  >  >
>  >  > o    Random Variable from 1 to ${Var_matchNr} called Sample
>  >  >
>  >  > o    Regular Expression Extractor with Match No. set to ${Sample} for each
>  >  > of the other parameters.
>  >  >
>  >  > When I run this with a Debug Sampler, Sample is not getting set to
>  >  > anything.
>  >  >
>  >  > Is there a way to just set a variable to a value during processing? Is
>  >  > there a better way to do what I'm doing?
>  >  >
>  >  > Thanks,
>  >  >
>  >  > Steve Eckhart
>  >  > Business Analyst/Project Manager
>  >  >
>  >  > WAUSAU Financial Systems
>  >  > 14010 FNB PKWY STE500
>  >  > Omaha, NE 68154-5206
>  >  > Main: (402) 431-8810
>  >  > Direct line: (402) 715-9382
>  >  > Cellular: (402) 510-5387
>  >  > Email: steve.eckhart@wausaufs.com<blocked::mailto:
>  >  > steve.eckhart@wausaufs.com>
>  >  >
>  >  > Enterprise Payment Solutions.
>  >  > CONFIDENTIALITY NOTICE:  This electronic transmission (including files
>  >  > attached hereto) is intended only for the use of the individual or entity
>  >  > named above.  If the reader of this message is not the intended recipient,
>  >  > you are hereby notified that any disclosure, dissemination, copying,
>  >  > distribution or taking of any action in reliance on the contents of this
>  >  > confidential information is strictly prohibited.  If you have received this
>  >  > communication in error, please destroy it and immediately notify us by
>  >  > return email.  Thank you.
>  >  >
>  >
>
>
> ---------------------------------------------------------------------
>  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
>
>

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


Re: Help With Passing Multiple Variables From a Regular Expression Extractor

Posted by Deepak Shetty <sh...@gmail.com>.
hi
ok , if you know java bean shell is easy and invaluable (though maybe
inefficient) in jmeter...
regards
deepak

On Fri, Aug 28, 2009 at 10:38 AM, Steve Eckhart
<St...@wausaufs.com>wrote:

> Thanks, Deepak.
>
> I'm not familiar with BeanShell, but I was able to use what you sent to get
> the desired result.
>
> What I ended up doing was randomly select one of the links and then use
> your script to parse out the parts I need for my other module.
>
> -----Original Message-----
> From: Deepak Shetty [mailto:shettyd@gmail.com]
> Sent: Friday, August 28, 2009 12:14 PM
> To: JMeter Users List
> Subject: Re: Help With Passing Multiple Variables From a Regular Expression
> Extractor
>
> You should be able to get these values using the functions (i.e. you dont
> need to explicitly define A)  __V, __Random. (No time to test :) )
>
> Fairly easy to do this in BSH
> vars.put("A", vars.get("Var_" + random + "_g1"));
> regards
> deepak
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

RE: Help With Passing Multiple Variables From a Regular Expression Extractor

Posted by Steve Eckhart <St...@wausaufs.com>.
Thanks, Deepak.

I'm not familiar with BeanShell, but I was able to use what you sent to get the desired result.

What I ended up doing was randomly select one of the links and then use your script to parse out the parts I need for my other module.

-----Original Message-----
From: Deepak Shetty [mailto:shettyd@gmail.com] 
Sent: Friday, August 28, 2009 12:14 PM
To: JMeter Users List
Subject: Re: Help With Passing Multiple Variables From a Regular Expression Extractor

You should be able to get these values using the functions (i.e. you dont
need to explicitly define A)  __V, __Random. (No time to test :) )

Fairly easy to do this in BSH
vars.put("A", vars.get("Var_" + random + "_g1"));
regards
deepak

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


Re: Help With Passing Multiple Variables From a Regular Expression Extractor

Posted by Deepak Shetty <sh...@gmail.com>.
You should be able to get these values using the functions (i.e. you dont
need to explicitly define A)  __V, __Random. (No time to test :) )

Fairly easy to do this in BSH
vars.put("A", vars.get("Var_" + random + "_g1"));
regards
deepak

On Fri, Aug 28, 2009 at 10:08 AM, Steve Eckhart
<St...@wausaufs.com>wrote:

> I can't use Match No = 0 because I could get a different link for each of
> the three Regular Expression Extractors.  I need each part from the same
> link.
>
> This would be fairly simple if I understood how to assign a variable
> directly. For example, suppose I have:
>
> Var_1_g=3
> Var_1_g0=href="pagerequest.aspx?a=7000&amp;b=104&amp;c=12047
> Var_1_g1=7000
> Var_1_g2=104
> Var_1_g3=12047
>
> What I would like to end up with is three output variables:
>
> A = Var_1_g1 = 7000
> B = Var_1_g2 = 104
> C = Var_1_g3 = 12047
>
> I can't figure out from the documentation how to set the value of a
> variable outside of a Regular Expression Extractor or a Random Variable.
>
> Steve
>
> -----Original Message-----
> From: sebb [mailto:sebbaz@gmail.com]
> Sent: Friday, August 28, 2009 12:02 PM
> To: JMeter Users List
> Subject: Re: Help With Passing Multiple Variables From a Regular Expression
> Extractor
>
> Or just use Match No = 0 and JMeter will choose a match at random.
>
> On 28/08/2009, Deepak Shetty <sh...@gmail.com> wrote:
> > Hi
> >  You'd probably need to check the scoping rules for Random variable
> config
> >  element. I think you've created everything as children of the HTTP
> request
> >  right?
> >
> >  Depending on how easy difficult it is to extract the values i would try
> >  Option 1
> >  a. Each Parameter is extracted separately (so in your case you would
> have 4
> >  Regex extractors , 1 per parameter)
> >  b. Use __Random and __V to randomise the index and pick out the value
> >  http://jakarta.apache.org/jmeter/usermanual/functions.html (I think
> this is
> >  what you were trying)
> >
> >  Option 2
> >  If its easier to extract all parameters for 1 type (e.g. they are the
> query
> >  string of some url). In this case you only have 1 Regex (each result has
> all
> >  parameters and you have multiple results that you want to randomise) ,
> Use a
> >  beanshell script or function to parse the parameters out and set them
> into
> >  variables, and use random again...
> >
> >  regards
> >  deepak
> >
> >
> >  On Fri, Aug 28, 2009 at 6:36 AM, Steve Eckhart
> >  <St...@wausaufs.com>wrote:
> >
> >
> >  > I am having difficulty understanding how to pull multiple values from
> a
> >  > Regular Expression Extractor and pass them along in my script.
> >  >
> >  > Basically, here's what I'm trying to accomplish:
> >  >
> >  > 1.     Submit a form which will return 0 or more links to other pages.
> Each
> >  > link has four parameters which I need to pull out for later
> processing.
> >  >
> >  > 2.     Randomly select one of the links.
> >  >
> >  > 3.     Put the four parameters into four variables for use by another
> >  > Controller.
> >  >
> >  > Here's what I tried (which doesn't seem to work):
> >  >
> >  > *         HTTP Request
> >  >
> >  > o    Regular Expression Extractor-Var (all of the Var on the page will
> be
> >  > the same value)
> >  >
> >  > o    Random Variable from 1 to ${Var_matchNr} called Sample
> >  >
> >  > o    Regular Expression Extractor with Match No. set to ${Sample} for
> each
> >  > of the other parameters.
> >  >
> >  > When I run this with a Debug Sampler, Sample is not getting set to
> >  > anything.
> >  >
> >  > Is there a way to just set a variable to a value during processing? Is
> >  > there a better way to do what I'm doing?
> >  >
> >  > Thanks,
> >  >
> >  > Steve Eckhart
> >  > Business Analyst/Project Manager
> >  >
> >  > WAUSAU Financial Systems
> >  > 14010 FNB PKWY STE500
> >  > Omaha, NE 68154-5206
> >  > Main: (402) 431-8810
> >  > Direct line: (402) 715-9382
> >  > Cellular: (402) 510-5387
> >  > Email: steve.eckhart@wausaufs.com<blocked::mailto:
> >  > steve.eckhart@wausaufs.com>
> >  >
> >  > Enterprise Payment Solutions.
> >  > CONFIDENTIALITY NOTICE:  This electronic transmission (including files
> >  > attached hereto) is intended only for the use of the individual or
> entity
> >  > named above.  If the reader of this message is not the intended
> recipient,
> >  > you are hereby notified that any disclosure, dissemination, copying,
> >  > distribution or taking of any action in reliance on the contents of
> this
> >  > confidential information is strictly prohibited.  If you have received
> this
> >  > communication in error, please destroy it and immediately notify us by
> >  > return email.  Thank you.
> >  >
> >
>
> ---------------------------------------------------------------------
> 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: Help With Passing Multiple Variables From a Regular Expression Extractor

Posted by Steve Eckhart <St...@wausaufs.com>.
I can't use Match No = 0 because I could get a different link for each of the three Regular Expression Extractors.  I need each part from the same link.

This would be fairly simple if I understood how to assign a variable directly. For example, suppose I have:

Var_1_g=3
Var_1_g0=href="pagerequest.aspx?a=7000&amp;b=104&amp;c=12047
Var_1_g1=7000
Var_1_g2=104
Var_1_g3=12047

What I would like to end up with is three output variables:

A = Var_1_g1 = 7000
B = Var_1_g2 = 104
C = Var_1_g3 = 12047

I can't figure out from the documentation how to set the value of a variable outside of a Regular Expression Extractor or a Random Variable.

Steve

-----Original Message-----
From: sebb [mailto:sebbaz@gmail.com] 
Sent: Friday, August 28, 2009 12:02 PM
To: JMeter Users List
Subject: Re: Help With Passing Multiple Variables From a Regular Expression Extractor

Or just use Match No = 0 and JMeter will choose a match at random.

On 28/08/2009, Deepak Shetty <sh...@gmail.com> wrote:
> Hi
>  You'd probably need to check the scoping rules for Random variable config
>  element. I think you've created everything as children of the HTTP request
>  right?
>
>  Depending on how easy difficult it is to extract the values i would try
>  Option 1
>  a. Each Parameter is extracted separately (so in your case you would have 4
>  Regex extractors , 1 per parameter)
>  b. Use __Random and __V to randomise the index and pick out the value
>  http://jakarta.apache.org/jmeter/usermanual/functions.html (I think this is
>  what you were trying)
>
>  Option 2
>  If its easier to extract all parameters for 1 type (e.g. they are the query
>  string of some url). In this case you only have 1 Regex (each result has all
>  parameters and you have multiple results that you want to randomise) , Use a
>  beanshell script or function to parse the parameters out and set them into
>  variables, and use random again...
>
>  regards
>  deepak
>
>
>  On Fri, Aug 28, 2009 at 6:36 AM, Steve Eckhart
>  <St...@wausaufs.com>wrote:
>
>
>  > I am having difficulty understanding how to pull multiple values from a
>  > Regular Expression Extractor and pass them along in my script.
>  >
>  > Basically, here's what I'm trying to accomplish:
>  >
>  > 1.     Submit a form which will return 0 or more links to other pages. Each
>  > link has four parameters which I need to pull out for later processing.
>  >
>  > 2.     Randomly select one of the links.
>  >
>  > 3.     Put the four parameters into four variables for use by another
>  > Controller.
>  >
>  > Here's what I tried (which doesn't seem to work):
>  >
>  > *         HTTP Request
>  >
>  > o    Regular Expression Extractor-Var (all of the Var on the page will be
>  > the same value)
>  >
>  > o    Random Variable from 1 to ${Var_matchNr} called Sample
>  >
>  > o    Regular Expression Extractor with Match No. set to ${Sample} for each
>  > of the other parameters.
>  >
>  > When I run this with a Debug Sampler, Sample is not getting set to
>  > anything.
>  >
>  > Is there a way to just set a variable to a value during processing? Is
>  > there a better way to do what I'm doing?
>  >
>  > Thanks,
>  >
>  > Steve Eckhart
>  > Business Analyst/Project Manager
>  >
>  > WAUSAU Financial Systems
>  > 14010 FNB PKWY STE500
>  > Omaha, NE 68154-5206
>  > Main: (402) 431-8810
>  > Direct line: (402) 715-9382
>  > Cellular: (402) 510-5387
>  > Email: steve.eckhart@wausaufs.com<blocked::mailto:
>  > steve.eckhart@wausaufs.com>
>  >
>  > Enterprise Payment Solutions.
>  > CONFIDENTIALITY NOTICE:  This electronic transmission (including files
>  > attached hereto) is intended only for the use of the individual or entity
>  > named above.  If the reader of this message is not the intended recipient,
>  > you are hereby notified that any disclosure, dissemination, copying,
>  > distribution or taking of any action in reliance on the contents of this
>  > confidential information is strictly prohibited.  If you have received this
>  > communication in error, please destroy it and immediately notify us by
>  > return email.  Thank you.
>  >
>

---------------------------------------------------------------------
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: Help With Passing Multiple Variables From a Regular Expression Extractor

Posted by sebb <se...@gmail.com>.
Or just use Match No = 0 and JMeter will choose a match at random.

On 28/08/2009, Deepak Shetty <sh...@gmail.com> wrote:
> Hi
>  You'd probably need to check the scoping rules for Random variable config
>  element. I think you've created everything as children of the HTTP request
>  right?
>
>  Depending on how easy difficult it is to extract the values i would try
>  Option 1
>  a. Each Parameter is extracted separately (so in your case you would have 4
>  Regex extractors , 1 per parameter)
>  b. Use __Random and __V to randomise the index and pick out the value
>  http://jakarta.apache.org/jmeter/usermanual/functions.html (I think this is
>  what you were trying)
>
>  Option 2
>  If its easier to extract all parameters for 1 type (e.g. they are the query
>  string of some url). In this case you only have 1 Regex (each result has all
>  parameters and you have multiple results that you want to randomise) , Use a
>  beanshell script or function to parse the parameters out and set them into
>  variables, and use random again...
>
>  regards
>  deepak
>
>
>  On Fri, Aug 28, 2009 at 6:36 AM, Steve Eckhart
>  <St...@wausaufs.com>wrote:
>
>
>  > I am having difficulty understanding how to pull multiple values from a
>  > Regular Expression Extractor and pass them along in my script.
>  >
>  > Basically, here's what I'm trying to accomplish:
>  >
>  > 1.     Submit a form which will return 0 or more links to other pages. Each
>  > link has four parameters which I need to pull out for later processing.
>  >
>  > 2.     Randomly select one of the links.
>  >
>  > 3.     Put the four parameters into four variables for use by another
>  > Controller.
>  >
>  > Here's what I tried (which doesn't seem to work):
>  >
>  > *         HTTP Request
>  >
>  > o    Regular Expression Extractor-Var (all of the Var on the page will be
>  > the same value)
>  >
>  > o    Random Variable from 1 to ${Var_matchNr} called Sample
>  >
>  > o    Regular Expression Extractor with Match No. set to ${Sample} for each
>  > of the other parameters.
>  >
>  > When I run this with a Debug Sampler, Sample is not getting set to
>  > anything.
>  >
>  > Is there a way to just set a variable to a value during processing? Is
>  > there a better way to do what I'm doing?
>  >
>  > Thanks,
>  >
>  > Steve Eckhart
>  > Business Analyst/Project Manager
>  >
>  > WAUSAU Financial Systems
>  > 14010 FNB PKWY STE500
>  > Omaha, NE 68154-5206
>  > Main: (402) 431-8810
>  > Direct line: (402) 715-9382
>  > Cellular: (402) 510-5387
>  > Email: steve.eckhart@wausaufs.com<blocked::mailto:
>  > steve.eckhart@wausaufs.com>
>  >
>  > Enterprise Payment Solutions.
>  > CONFIDENTIALITY NOTICE:  This electronic transmission (including files
>  > attached hereto) is intended only for the use of the individual or entity
>  > named above.  If the reader of this message is not the intended recipient,
>  > you are hereby notified that any disclosure, dissemination, copying,
>  > distribution or taking of any action in reliance on the contents of this
>  > confidential information is strictly prohibited.  If you have received this
>  > communication in error, please destroy it and immediately notify us by
>  > return email.  Thank you.
>  >
>

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


Re: Help With Passing Multiple Variables From a Regular Expression Extractor

Posted by Deepak Shetty <sh...@gmail.com>.
Hi
You'd probably need to check the scoping rules for Random variable config
element. I think you've created everything as children of the HTTP request
right?

Depending on how easy difficult it is to extract the values i would try
Option 1
a. Each Parameter is extracted separately (so in your case you would have 4
Regex extractors , 1 per parameter)
b. Use __Random and __V to randomise the index and pick out the value
http://jakarta.apache.org/jmeter/usermanual/functions.html (I think this is
what you were trying)

Option 2
If its easier to extract all parameters for 1 type (e.g. they are the query
string of some url). In this case you only have 1 Regex (each result has all
parameters and you have multiple results that you want to randomise) , Use a
beanshell script or function to parse the parameters out and set them into
variables, and use random again...

regards
deepak


On Fri, Aug 28, 2009 at 6:36 AM, Steve Eckhart
<St...@wausaufs.com>wrote:

> I am having difficulty understanding how to pull multiple values from a
> Regular Expression Extractor and pass them along in my script.
>
> Basically, here's what I'm trying to accomplish:
>
> 1.     Submit a form which will return 0 or more links to other pages. Each
> link has four parameters which I need to pull out for later processing.
>
> 2.     Randomly select one of the links.
>
> 3.     Put the four parameters into four variables for use by another
> Controller.
>
> Here's what I tried (which doesn't seem to work):
>
> *         HTTP Request
>
> o    Regular Expression Extractor-Var (all of the Var on the page will be
> the same value)
>
> o    Random Variable from 1 to ${Var_matchNr} called Sample
>
> o    Regular Expression Extractor with Match No. set to ${Sample} for each
> of the other parameters.
>
> When I run this with a Debug Sampler, Sample is not getting set to
> anything.
>
> Is there a way to just set a variable to a value during processing? Is
> there a better way to do what I'm doing?
>
> Thanks,
>
> Steve Eckhart
> Business Analyst/Project Manager
>
> WAUSAU Financial Systems
> 14010 FNB PKWY STE500
> Omaha, NE 68154-5206
> Main: (402) 431-8810
> Direct line: (402) 715-9382
> Cellular: (402) 510-5387
> Email: steve.eckhart@wausaufs.com<blocked::mailto:
> steve.eckhart@wausaufs.com>
>
> Enterprise Payment Solutions.
> CONFIDENTIALITY NOTICE:  This electronic transmission (including files
> attached hereto) is intended only for the use of the individual or entity
> named above.  If the reader of this message is not the intended recipient,
> you are hereby notified that any disclosure, dissemination, copying,
> distribution or taking of any action in reliance on the contents of this
> confidential information is strictly prohibited.  If you have received this
> communication in error, please destroy it and immediately notify us by
> return email.  Thank you.
>

RE: Help With a Null Variable

Posted by Steve Eckhart <St...@wausaufs.com>.
Deepak,

The following works:
	if(vars.get("BatchLink_g3") == null)
	{
	   vars.put("loopBatch","0");
	} 
	else
	{
	       vars.put("loopBatch", vars.get("BatchLink_g3"));
	}

Thanks for your help!

Steve

-----Original Message-----
From: Deepak Shetty [mailto:shettyd@gmail.com] 
Sent: Thursday, November 12, 2009 1:39 PM
To: JMeter Users List
Subject: Re: Help With a Null Variable

hi
that wont work both values get replaced . What i meant was that since your
variable might be a number or a sting (the literal string ${loopBatch} , you
need to use it as  a string everywhere

Something like this
//first condition is check not null
("${loopBatch}".indexOf("$") != -1) && (rest of condition like parse and
check the value)

I vaguely remember another way to do this , but ill need to go through some
of my notes and check.
regards
deepak


On Thu, Nov 12, 2009 at 11:17 AM, Steve Eckhart
<St...@wausaufs.com>wrote:

> Deepak,
>
> I tried setting the If Controller to
>        ${loopBatch} != "${loopBatch}"
> and checking the Interpret Condition as Variable Expression? checkbox.
>
> I no longer get the error when loopBatch is null. However, when
> loopBatch=132, I would expect the condition to evaluate to true and execute
> the steps in the If. Unfortunately, it didn't and continued with the steps
> after the if.
>
> What am I missing?
>
> -----Original Message-----
> From: Deepak Shetty [mailto:shettyd@gmail.com]
> Sent: Thursday, November 12, 2009 12:01 PM
> To: JMeter Users List
> Subject: Re: Help With a Null Variable
>
> hi
> you could do this at the beanshell level
> //check the number of brackets , this is pseudo code, also check that
> loopBatch always has a value that is the string //representation of an
> integer or an integer
>
> if(vars.get("BatchLink_g3")) == null ||
> "".equals(vars.get("BatchLink_g3")).trim())){
>   vars.put("loopBatch","0");
> } else {
>       vars.put("loopBatch", vars.get("BatchLink_g3"));
> }
>
>
> OR
>  You could do it as a javascript funtion (null means the value remains as
> ${loopBatch} and you'd have to pass it as a string so there be quotes
> around
> the ${loopBatch}
>
>
>
> regards
> deepak
>
>
>
>
> On Thu, Nov 12, 2009 at 9:38 AM, Steve Eckhart
> <St...@wausaufs.com>wrote:
>
> > I have a Regular Expression which is reading a variable from a web page.
>  I
> > need to test this value to see if I should perform the next step or
> perform
> > another search.
> >
> > Currently, I have the following in a BeanShell PostProcessor to set the
> > value of the variable:
> >
> >        vars.put("loopBatch", vars.get("BatchLink_g3"));
> >
> > If my search returned no results, a Debut PostProcessor will report
> > loopBatch=null. Then, the If Controller ${loopBatch} > 0 generates an
> error:
> >
> >        ERROR - jmeter.control.IfController: missing ) after argument list
> > (<cmd>#1)
> >
> > How can I test using a variable which might be null? I found a method of
> > the Class Abstract Property getIntValue() which would give me what I want
> (0
> > when the value is null), but I don't understand how to use getIntValue()
> in
> > a JMeter script.
> >
> > Is this the right way to proceed? Am I missing something? I don't know
> much
> > about the BeanShell command.
> >
> > Thank you for any help.
> >
> > ---------------------------------------------------------------------
> > 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
>
>

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


Re: Help With a Null Variable

Posted by Deepak Shetty <sh...@gmail.com>.
hi
that wont work both values get replaced . What i meant was that since your
variable might be a number or a sting (the literal string ${loopBatch} , you
need to use it as  a string everywhere

Something like this
//first condition is check not null
("${loopBatch}".indexOf("$") != -1) && (rest of condition like parse and
check the value)

I vaguely remember another way to do this , but ill need to go through some
of my notes and check.
regards
deepak


On Thu, Nov 12, 2009 at 11:17 AM, Steve Eckhart
<St...@wausaufs.com>wrote:

> Deepak,
>
> I tried setting the If Controller to
>        ${loopBatch} != "${loopBatch}"
> and checking the Interpret Condition as Variable Expression? checkbox.
>
> I no longer get the error when loopBatch is null. However, when
> loopBatch=132, I would expect the condition to evaluate to true and execute
> the steps in the If. Unfortunately, it didn't and continued with the steps
> after the if.
>
> What am I missing?
>
> -----Original Message-----
> From: Deepak Shetty [mailto:shettyd@gmail.com]
> Sent: Thursday, November 12, 2009 12:01 PM
> To: JMeter Users List
> Subject: Re: Help With a Null Variable
>
> hi
> you could do this at the beanshell level
> //check the number of brackets , this is pseudo code, also check that
> loopBatch always has a value that is the string //representation of an
> integer or an integer
>
> if(vars.get("BatchLink_g3")) == null ||
> "".equals(vars.get("BatchLink_g3")).trim())){
>   vars.put("loopBatch","0");
> } else {
>       vars.put("loopBatch", vars.get("BatchLink_g3"));
> }
>
>
> OR
>  You could do it as a javascript funtion (null means the value remains as
> ${loopBatch} and you'd have to pass it as a string so there be quotes
> around
> the ${loopBatch}
>
>
>
> regards
> deepak
>
>
>
>
> On Thu, Nov 12, 2009 at 9:38 AM, Steve Eckhart
> <St...@wausaufs.com>wrote:
>
> > I have a Regular Expression which is reading a variable from a web page.
>  I
> > need to test this value to see if I should perform the next step or
> perform
> > another search.
> >
> > Currently, I have the following in a BeanShell PostProcessor to set the
> > value of the variable:
> >
> >        vars.put("loopBatch", vars.get("BatchLink_g3"));
> >
> > If my search returned no results, a Debut PostProcessor will report
> > loopBatch=null. Then, the If Controller ${loopBatch} > 0 generates an
> error:
> >
> >        ERROR - jmeter.control.IfController: missing ) after argument list
> > (<cmd>#1)
> >
> > How can I test using a variable which might be null? I found a method of
> > the Class Abstract Property getIntValue() which would give me what I want
> (0
> > when the value is null), but I don't understand how to use getIntValue()
> in
> > a JMeter script.
> >
> > Is this the right way to proceed? Am I missing something? I don't know
> much
> > about the BeanShell command.
> >
> > Thank you for any help.
> >
> > ---------------------------------------------------------------------
> > 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: Help With a Null Variable

Posted by Steve Eckhart <St...@wausaufs.com>.
Deepak,

I tried setting the If Controller to 
	${loopBatch} != "${loopBatch}"
and checking the Interpret Condition as Variable Expression? checkbox.

I no longer get the error when loopBatch is null. However, when loopBatch=132, I would expect the condition to evaluate to true and execute the steps in the If. Unfortunately, it didn't and continued with the steps after the if.

What am I missing?

-----Original Message-----
From: Deepak Shetty [mailto:shettyd@gmail.com] 
Sent: Thursday, November 12, 2009 12:01 PM
To: JMeter Users List
Subject: Re: Help With a Null Variable

hi
you could do this at the beanshell level
//check the number of brackets , this is pseudo code, also check that
loopBatch always has a value that is the string //representation of an
integer or an integer

if(vars.get("BatchLink_g3")) == null ||
"".equals(vars.get("BatchLink_g3")).trim())){
   vars.put("loopBatch","0");
} else {
       vars.put("loopBatch", vars.get("BatchLink_g3"));
}


OR
 You could do it as a javascript funtion (null means the value remains as
${loopBatch} and you'd have to pass it as a string so there be quotes around
the ${loopBatch}



regards
deepak




On Thu, Nov 12, 2009 at 9:38 AM, Steve Eckhart
<St...@wausaufs.com>wrote:

> I have a Regular Expression which is reading a variable from a web page.  I
> need to test this value to see if I should perform the next step or perform
> another search.
>
> Currently, I have the following in a BeanShell PostProcessor to set the
> value of the variable:
>
>        vars.put("loopBatch", vars.get("BatchLink_g3"));
>
> If my search returned no results, a Debut PostProcessor will report
> loopBatch=null. Then, the If Controller ${loopBatch} > 0 generates an error:
>
>        ERROR - jmeter.control.IfController: missing ) after argument list
> (<cmd>#1)
>
> How can I test using a variable which might be null? I found a method of
> the Class Abstract Property getIntValue() which would give me what I want (0
> when the value is null), but I don't understand how to use getIntValue() in
> a JMeter script.
>
> Is this the right way to proceed? Am I missing something? I don't know much
> about the BeanShell command.
>
> Thank you for any help.
>
> ---------------------------------------------------------------------
> 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: Help With a Null Variable

Posted by Deepak Shetty <sh...@gmail.com>.
hi
you could do this at the beanshell level
//check the number of brackets , this is pseudo code, also check that
loopBatch always has a value that is the string //representation of an
integer or an integer

if(vars.get("BatchLink_g3")) == null ||
"".equals(vars.get("BatchLink_g3")).trim())){
   vars.put("loopBatch","0");
} else {
       vars.put("loopBatch", vars.get("BatchLink_g3"));
}


OR
 You could do it as a javascript funtion (null means the value remains as
${loopBatch} and you'd have to pass it as a string so there be quotes around
the ${loopBatch}



regards
deepak




On Thu, Nov 12, 2009 at 9:38 AM, Steve Eckhart
<St...@wausaufs.com>wrote:

> I have a Regular Expression which is reading a variable from a web page.  I
> need to test this value to see if I should perform the next step or perform
> another search.
>
> Currently, I have the following in a BeanShell PostProcessor to set the
> value of the variable:
>
>        vars.put("loopBatch", vars.get("BatchLink_g3"));
>
> If my search returned no results, a Debut PostProcessor will report
> loopBatch=null. Then, the If Controller ${loopBatch} > 0 generates an error:
>
>        ERROR - jmeter.control.IfController: missing ) after argument list
> (<cmd>#1)
>
> How can I test using a variable which might be null? I found a method of
> the Class Abstract Property getIntValue() which would give me what I want (0
> when the value is null), but I don't understand how to use getIntValue() in
> a JMeter script.
>
> Is this the right way to proceed? Am I missing something? I don't know much
> about the BeanShell command.
>
> Thank you for any help.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Help With a Null Variable

Posted by Steve Eckhart <St...@wausaufs.com>.
I have a Regular Expression which is reading a variable from a web page.  I need to test this value to see if I should perform the next step or perform another search.

Currently, I have the following in a BeanShell PostProcessor to set the value of the variable:

	vars.put("loopBatch", vars.get("BatchLink_g3"));

If my search returned no results, a Debut PostProcessor will report loopBatch=null. Then, the If Controller ${loopBatch} > 0 generates an error:

	ERROR - jmeter.control.IfController: missing ) after argument list (<cmd>#1)

How can I test using a variable which might be null? I found a method of the Class Abstract Property getIntValue() which would give me what I want (0 when the value is null), but I don't understand how to use getIntValue() in a JMeter script.

Is this the right way to proceed? Am I missing something? I don't know much about the BeanShell command.

Thank you for any help.

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