You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Deepak Shetty <sh...@gmail.com> on 2009/08/28 18:26:20 UTC

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

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 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