jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak Shetty <shet...@gmail.com>
Subject Re: BeanShell PostProcessor and vars issue
Date Wed, 06 Oct 2010 21:01:10 GMT
hi
the JMeter RegEx extractor supports this - you simply need to specify Match
No as -1. In the ForEach you can specify the name that you gave the regex
(You might need to go to BeanShell if you have some advanced needs)

regards
deepak


On Wed, Oct 6, 2010 at 1:54 PM, Paul Loy <keteracel@gmail.com> wrote:

> yeah, it was just a quick test using the sampler. I now do it in a bean
> shell using Pattern and Matcher with a while around Matcher.find().
>
> Cheers,
>
> Paul.
>
> On Wed, Oct 6, 2010 at 9:30 PM, Deepak Shetty <shettyd@gmail.com> wrote:
>
> > > I then (for the sake of doing it simply) have 15 RegEx PostProcessors
> to
> > extract each link from the results.
> > Just to confirm you know you can use a regex to extract 15
> values(assuming
> > this is possible) directly and loop over them right?
> >
> > On Wed, Oct 6, 2010 at 4:09 AM, Paul Loy <keteracel@gmail.com> wrote:
> >
> > > Hi All,
> > >
> > > I have the following in JMeter
> > >
> > > |
> > > |-- HTTP Request Sampler (search)
> > > |   |
> > > |   --- RegEx PostProcessors (x15)
> > > |
> > > |-- ForEach
> > > |   |
> > > |   --- HTTP Request Sampler (page)
> > > |       |
> > > |       |-- RegEx PostProcessor (extracts $_something)
> > > |       |
> > > |       --- BeanShell PostProcessor
> > > |
> > > |-- HTTP Request Sampler (using $_somelist)
> > >
> > > The first HTTP request performs a search that gets a list of 10 items.
> I
> > > then (for the sake of doing it simply) have 15 RegEx PostProcessors to
> > > extract each link from the results. For each of those links I then
> > extract
> > > some other information via another HTTP Request. The idea is then to
> > create
> > > a list of some of these items that I use in the final HTTP Request. My
> > > BeanShell PostProcessor should do this. Here is the code I have in
> there:
> > >
> > > String thing = (String) vars.get("_something");
> > > Object list_obj = vars.get("_somelist");
> > > String list = null;
> > >
> > > if (list_obj == null) {
> > >    log.info("new list");
> > >    list = thing;
> > > }
> > > else {
> > >    log.info("concat list");
> > >    java.util.Random random = new
> > > java.util.Random(System.currentTimeMillis());
> > >
> > >    int rand = random.nextInt(100);
> > >
> > >    if (rand < 40) {
> > >      list = (String) list_obj;
> > >      list += "%2C" + thing;
> > >    }
> > > }
> > >
> > > vars.put("_somelist", list);
> > >
> > > When I run this, I get the following Logging:
> > >
> > > 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *new
> list*
> > > 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *concat
> > list*
> > >
> > > 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *new
> list*
> > > 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement:* concat
> > list*
> > >
> > > 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *new
> list*
> > > 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *concat
> > list*
> > >
> > > 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *new
> list*
> > > 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *concat
> > list*
> > >
> > > 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *new
> list*
> > > 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *concat
> > list*
> > > 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *concat
> > list*
> > > 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *concat
> > list*
> > >
> > > 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *new
> list*
> > > 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *concat
> > list*
> > >
> > > 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *new
> list*
> > >
> > > It does indeed loop through 15 times, but seemingly arbitrarily it
> thinks
> > > that var _somelist is null and so starts a new list.
> > >
> > > Any thoughts?
> > >
> > > Thanks in advance,
> > >
> > > Paul.
> > >
> > > --
> > > ---------------------------------------------
> > > Paul Loy
> > > paul@keteracel.com
> > > http://uk.linkedin.com/in/paulloy
> > >
> >
>
>
>
> --
> ---------------------------------------------
> Paul Loy
> paul@keteracel.com
> http://uk.linkedin.com/in/paulloy
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message