You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by moondance <oz...@yahoo.com> on 2011/08/10 21:58:07 UTC

Saving the reply in Jmeter

Hi,
I get the following reply from my service :
http://jmeter.512774.n5.nabble.com/file/n4687066/new_2.xml new_2.xml 
I want to save all the values ( the number of replies is unknown when I send
the request.

I want to save how many values were sent back and also all the values. This
should be done somehow in the post process so for the next request I can
build with the values I have.

Thanks
 Oren

--
View this message in context: http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4687066.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: Saving the reply in Jmeter

Posted by sebb <se...@gmail.com>.
On 11 August 2011 16:26, Bruce Ide <fl...@gmail.com> wrote:
> Using regexps seems to always boil down to debugging a regexp expression to
> have it give you what you want. First of all, check the response of whatever
> the regexp is attached to, in order to verify that it is, in fact, returning
> what you think you're looking for.
>
> If it is, then I usually find it helpful to start paring stuff off my
> regular expression until it works. You never know what the regexp isn't
> going to like. Set it up to match promiscuously, perhaps just (.*) to start
> and then start adding things until it breaks. Then look at why it's breaking
> on what it is.
>
> I always prefer the xpath extractor over the regexp extractor when I can use
> it, as it takes much less fiddling to make it work. Usually with the xpath
> extractor I just need to remember to click "use tidy" and I'm good.

JMeter 2.4 has a regex tester built into the Tree View Listener.

> --
> Bruce Ide
> FlyingRhenquest@gmail.com
>

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


Re: Saving the reply in Jmeter

Posted by Bruce Ide <fl...@gmail.com>.
Using regexps seems to always boil down to debugging a regexp expression to
have it give you what you want. First of all, check the response of whatever
the regexp is attached to, in order to verify that it is, in fact, returning
what you think you're looking for.

If it is, then I usually find it helpful to start paring stuff off my
regular expression until it works. You never know what the regexp isn't
going to like. Set it up to match promiscuously, perhaps just (.*) to start
and then start adding things until it breaks. Then look at why it's breaking
on what it is.

I always prefer the xpath extractor over the regexp extractor when I can use
it, as it takes much less fiddling to make it work. Usually with the xpath
extractor I just need to remember to click "use tidy" and I'm good.

-- 
Bruce Ide
FlyingRhenquest@gmail.com

Re: Saving the reply in Jmeter

Posted by moondance <oz...@yahoo.com>.
so here is the result :
Arguments.arguments=[, UserToken=, UserName=rvuser, Password=a123456,
UserNameCreate=, LookupResponse1=, ExternalToken=, UserId=,
ActivationToken=, LoginId1=, LoginId2=, LoginId3=, LoginId4=, LoginId5=,
LoginId6=, LoginId7=, LoginId8=, LoginId9=, LoginId10=, LoginToken1=,
LoginToken2=, LoginToken3=, LoginToken4=, LoginToken5=, LoginToken6=,
LoginToken7=, LoginToken8=, LoginToken9=, LoginToken10=, AdminToken=]

So it looks like it didn't extract the data any ideas ? 


--
View this message in context: http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4689718.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: Saving the reply in Jmeter

Posted by Bruce Ide <fl...@gmail.com>.
I'd drop in a debug sampler before your beanshell sampler and just make sure
your regex has extracted properly. You don't need to create the keyvals if
the regex has done its job correctly, but I'd guess it didn't actually
extract anything.

IIRC the regex processor will not create an array if you specify a default
value like that and it assigns the default. It'll put "5000" in keyval, not
keyval_1.

-- 
Bruce Ide
FlyingRhenquest@gmail.com

Re: Saving the reply in Jmeter

Posted by Oliver Lloyd <ol...@hotmail.com>.
If you just want a random match there is a substantially easier way to do
this. It's right there in the original regular expression extractor (even
written on the form itself) just select 0 for the Match No and you will
automatically get a random Value as the result. 

If you also want the count, well, you could just have two regexp extractors,
that'd be pretty simple. But it seems to me you actually only want to pick a
random value from the list and use it later in your script, right?

--
View this message in context: http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4689565.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: Saving the reply in Jmeter

Posted by moondance <oz...@yahoo.com>.
Well I thought that was the whole point of the regular expression to create
those variables do I need to create the "keyvalue" variable in the "User
Defined Variables" section ? 


Konstantin S. wrote:
> 
> When I was working with beanShell listener I had an issue when it was
> alone
> in the If controller. I don't remember what was exactly the problem if I
> remeber correctly there was something with nulls too. So I have to add
> debug
> sampler into If controller then BeanShell would work correct. No idea why.
> But maybe you have something of this sort.
> 
>                sb.append(vars.get(variableName));
> 
> are you sure this variable is known to your shell? why it generates nulls
> 




--
View this message in context: http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4689521.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: Saving the reply in Jmeter

Posted by "Konstantin S." <mk...@gmail.com>.
When I was working with beanShell listener I had an issue when it was alone
in the If controller. I don't remember what was exactly the problem if I
remeber correctly there was something with nulls too. So I have to add debug
sampler into If controller then BeanShell would work correct. No idea why.
But maybe you have something of this sort.

               sb.append(vars.get(variableName));

are you sure this variable is known to your shell? why it generates nulls

On Thu, Aug 11, 2011 at 4:04 PM, moondance <oz...@yahoo.com> wrote:

> So I did as you said for the value:
> Reference name : keyvalue
> regular expresion : <a:Value>(.+?)</a:Value>
> Template: $1$
> match No. : -1
> Default value :5000
>
> The I added a Preprocessor beanShell :
>
>
> StringBuilder sb = new StringBuilder();
>            Random generator = new Random();
>            int count = 5;
>
>            for (int i = 1; i < count; i = i + 1)
>            {
>                String variableName = "keyvalue_"+ i;
>
>                sb.append("\t\t<arr:guid>");
>                sb.append(vars.get(variableName));
>                sb.append("</arr:guid>\n");
>            }
>            System.out.println(sb.toString());
>            vars.put("Accounts",sb.toString());
>
> then in the WebService(SOAP) request Id this :
>  ${Accounts}
> but when I look at the soap request it has this :
>                <arr:guid>null</arr:guid>
>                <arr:guid>null</arr:guid>
>                <arr:guid>null</arr:guid>
>                <arr:guid>null</arr:guid>
>
> any ideas what I am doing wrong ?
>
> Thanks
>  Oren
>
>
>
>
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4689452.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: Saving the reply in Jmeter

Posted by moondance <oz...@yahoo.com>.
So I did as you said for the value:
Reference name : keyvalue
regular expresion : <a:Value>(.+?)</a:Value> 
Template: $1$ 
match No. : -1
Default value :5000

The I added a Preprocessor beanShell :


StringBuilder sb = new StringBuilder();
            Random generator = new Random();
            int count = 5;
           
            for (int i = 1; i < count; i = i + 1)
            {
                String variableName = "keyvalue_"+ i;
	
                sb.append("\t\t<arr:guid>");
                sb.append(vars.get(variableName));
                sb.append("</arr:guid>\n");
            }
            System.out.println(sb.toString());
            vars.put("Accounts",sb.toString());

then in the WebService(SOAP) request Id this :
 ${Accounts}
but when I look at the soap request it has this :
           	<arr:guid>null</arr:guid>
		<arr:guid>null</arr:guid>
		<arr:guid>null</arr:guid>
		<arr:guid>null</arr:guid>

any ideas what I am doing wrong ?

Thanks
 Oren




--
View this message in context: http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4689452.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: Re: Saving the reply in Jmeter

Posted by Adrian Speteanu <as...@gmail.com>.
On Thu, Aug 11, 2011 at 3:43 PM, Nermin Caluk <ne...@atlantbh.com> wrote:

> Match No = -1 will match ALL occurrences
>
> Example: say your regex is <code>(.+?)</code> and Match no is -1. If there
> are more than one occurrences of <code> this will match all of them, like
> ${EXTRACTED_CODE_1}, ${EXTRACTED_CODE_2}, ${EXTRACTED_CODE_3} etc. If there
> are 3 matches, than you will also get a variable like
> ${EXTRACTED_CODE_matchnr} with the value of 3, which is useful if you want
> to Loop through all of them.
>
> In the same example, if you would use Match no. = 2, this would match only
> the 2nd occurrence. Match no = 0 would match a random item.
>

Has its advantages, like the regExVariable_matchNr, but it complicates
things in the sense that you have to know what group to reference after - I
think its still best practice to avoid getting all occurrences in most
situations (because of memory, CPU), but its useful to know this is
possible.

Thanks all for solving this issue, last time I needed something like the OP
needed, I had to use the XPath extractor instead.


>
> Hope this helps,
> Nermin
>
>
>
> -----Original Message-----
> From: Adrian Speteanu [mailto:asp.adieu@gmail.com]
> Sent: 11. kolovoz 2011 14:29
> To: JMeter Users List
> Subject: Re: Re: Saving the reply in Jmeter
>
> Why are you all using Match No.: -1 ?
>
> On Thu, Aug 11, 2011 at 2:48 PM, <ra...@gmail.com> wrote:
>
> > :) lolz i alws be here in mail :)
> >
> >
> > On , Oliver Lloyd <ol...@hotmail.com> wrote:
> >
> >> Thanks Raj, where would we be without you.
> >>
> >
> >
> >
> >  --
> >>
> >
> >  View this message in context: http://jmeter.512774.n5.**
> >> nabble.com/Saving-the-reply-**in-Jmeter-tp4687066p4689158.**html<
> http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4689158.html
> >
> >>
> >
> >  Sent from the JMeter - User mailing list archive at Nabble.com.
> >>
> >
> >
> >
> >
>  ------------------------------**------------------------------**---------
> >>
> >
> >  To unsubscribe, e-mail: jmeter-user-unsubscribe@**jakarta.apache.org<
> jmeter-user-unsubscribe@jakarta.apache.org>
> >>
> >
> >  For additional commands, e-mail: jmeter-user-help@jakarta.**apache.org<
> 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: Re: Saving the reply in Jmeter

Posted by Nermin Caluk <ne...@atlantbh.com>.
Match No = -1 will match ALL occurrences 

Example: say your regex is <code>(.+?)</code> and Match no is -1. If there are more than one occurrences of <code> this will match all of them, like ${EXTRACTED_CODE_1}, ${EXTRACTED_CODE_2}, ${EXTRACTED_CODE_3} etc. If there are 3 matches, than you will also get a variable like ${EXTRACTED_CODE_matchnr} with the value of 3, which is useful if you want to Loop through all of them. 

In the same example, if you would use Match no. = 2, this would match only the 2nd occurrence. Match no = 0 would match a random item.

Hope this helps, 
Nermin



-----Original Message-----
From: Adrian Speteanu [mailto:asp.adieu@gmail.com] 
Sent: 11. kolovoz 2011 14:29
To: JMeter Users List
Subject: Re: Re: Saving the reply in Jmeter

Why are you all using Match No.: -1 ?

On Thu, Aug 11, 2011 at 2:48 PM, <ra...@gmail.com> wrote:

> :) lolz i alws be here in mail :)
>
>
> On , Oliver Lloyd <ol...@hotmail.com> wrote:
>
>> Thanks Raj, where would we be without you.
>>
>
>
>
>  --
>>
>
>  View this message in context: http://jmeter.512774.n5.**
>> nabble.com/Saving-the-reply-**in-Jmeter-tp4687066p4689158.**html<http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4689158.html>
>>
>
>  Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>
>
>
>  ------------------------------**------------------------------**---------
>>
>
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@**jakarta.apache.org<jm...@jakarta.apache.org>
>>
>
>  For additional commands, e-mail: jmeter-user-help@jakarta.**apache.org<jm...@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: Re: Saving the reply in Jmeter

Posted by Adrian Speteanu <as...@gmail.com>.
Why are you all using Match No.: -1 ?

On Thu, Aug 11, 2011 at 2:48 PM, <ra...@gmail.com> wrote:

> :) lolz i alws be here in mail :)
>
>
> On , Oliver Lloyd <ol...@hotmail.com> wrote:
>
>> Thanks Raj, where would we be without you.
>>
>
>
>
>  --
>>
>
>  View this message in context: http://jmeter.512774.n5.**
>> nabble.com/Saving-the-reply-**in-Jmeter-tp4687066p4689158.**html<http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4689158.html>
>>
>
>  Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>
>
>
>  ------------------------------**------------------------------**---------
>>
>
>  To unsubscribe, e-mail: jmeter-user-unsubscribe@**jakarta.apache.org<jm...@jakarta.apache.org>
>>
>
>  For additional commands, e-mail: jmeter-user-help@jakarta.**apache.org<jm...@jakarta.apache.org>
>>
>
>
>
>

Re: Re: Saving the reply in Jmeter

Posted by ra...@gmail.com.
:) lolz i alws be here in mail :)

On , Oliver Lloyd <ol...@hotmail.com> wrote:
> Thanks Raj, where would we be without you.



> --

> View this message in context:  
> http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4689158.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: Saving the reply in Jmeter

Posted by Oliver Lloyd <ol...@hotmail.com>.
Thanks Raj, where would we be without you.

--
View this message in context: http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4689158.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: Saving the reply in Jmeter

Posted by Rajiv Nanduani <ra...@gmail.com>.
Try this its works fine for me :)


          Reference Name: keyname
          Regexp: <a:Key>(.+?)</a:Key>
          Template: $1$
          Match No: -1
          Default Value: I am the default value

          Reference Name: keyvalue
          Regexp: <a:Value>(.+?)</a:Value>
          Template: $1$
          Match No: -1
          Default Value: I am the default value

On Thu, Aug 11, 2011 at 2:49 AM, Oliver Lloyd <ol...@hotmail.com>wrote:

> Use a
>
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Regular_Expression_Extractor
> regular expression extractor
>
> For the email:
> Reference Name: foobar
> Regexp: <a:KeyValueOfstringguid><a:Key>(.+?)<
> Template: $1$
> Match No: -1
> Default Value: I am the default value
>
> This gives you:
> ${foobar_matchNr} = the count of matches
> ${foobar_1} = the first match
> ${foobar_5) = the fifth match, etc.
> ${foobar} = "I am the default value"
> Use these at your leisure.
>
> For the Value string:
> Go figure.
>
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4687414.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
>
>


-- 

Regards

*RAJIV <http://testeverythingrajiv.com/>
KUMAR<http://rajivkumarnandvani.wordpress.com/>
NANDVANI <http://testeverythingqtp.blogspot.com>*

http://rajivkumarnandvani.wordpress.com
http://testeverythingqtp.blogspot.com/

Re: Saving the reply in Jmeter

Posted by Oliver Lloyd <ol...@hotmail.com>.
Use a 
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Regular_Expression_Extractor
regular expression extractor 

For the email:
Reference Name: foobar
Regexp: <a:KeyValueOfstringguid><a:Key>(.+?)<
Template: $1$
Match No: -1
Default Value: I am the default value

This gives you:
${foobar_matchNr} = the count of matches
${foobar_1} = the first match
${foobar_5) = the fifth match, etc.
${foobar} = "I am the default value"
Use these at your leisure.

For the Value string:
Go figure.

--
View this message in context: http://jmeter.512774.n5.nabble.com/Saving-the-reply-in-Jmeter-tp4687066p4687414.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