You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Robert Heinerman <r....@3united.com> on 2006/04/19 17:12:03 UTC

Regular Expression Extractor

Hi,

we are using jmeter 2.1.1.

I use a regular expression extractor to parse an id, which is used for 
the next request, and a name which is used for response assertion. The 
regex for the name includes the extracted id.
 
Everything works fine, as long each tread is looped only once. When 
looping more often, I think JMeter confuses the extracted
ids from this loop and the loop before. Is there any bug known? Is there 
any configuration?

Example:

clusterID6
<a href="clusteridx?.*id=(\d.*?)">
$1$
0

clusterName6
<a href="clusteridx\?.*id=${clusterID6}">(.*?)<
$1$
0

clusterID6 is used for the next request, ClusterName6 is used as 
response assertion for this next request, which sometimes fails if 
threads are looped more than once. Maybe the regex are not correct, my 
knowledge about regex is limited.

Another question is: what is the template field in the regular 
expression extractor exactly? Didn't found any documentation.

Thank you for every help,
BR
rob  

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


Re: Regular Expression Extractor

Posted by sebb <se...@gmail.com>.
On 19/04/06, sebb <se...@gmail.com> wrote:
> On 19/04/06, Robert Heinerman <r....@3united.com> wrote:
> > Hi,
> >
> > we are using jmeter 2.1.1.
>
> Good.
>
> > I use a regular expression extractor to parse an id, which is used for
> > the next request, and a name which is used for response assertion. The
> > regex for the name includes the extracted id.
> >
> > Everything works fine, as long each tread is looped only once. When
>                                                       thread ?
> > looping more often, I think JMeter confuses the extracted
> > ids from this loop and the loop before. Is there any bug known? Is there
> > any configuration?
>
> Works OK for me.
> What are the symptoms you are seeing?
>
> Remember that the Regex Extractor is applied to EVERY sample in scope.
>
> > Example:
> >
> > clusterID6
> > <a href="clusteridx?.*id=(\d.*?)">
> > $1$
> > 0
> >
> > clusterName6
> > <a href="clusteridx\?.*id=${clusterID6}">(.*?)<
> > $1$
> > 0
>
> What are you trying to match against?
> Please give an example, and say what you want to extract.
>
> > clusterID6 is used for the next request, ClusterName6 is used as
> > response assertion for this next request, which sometimes fails if
> > threads are looped more than once. Maybe the regex are not correct, my
> > knowledge about regex is limited.
> >
> > Another question is: what is the template field in the regular
> > expression extractor exactly? Didn't found any documentation.
>
> file:///D:/eclipseworkspaces/Jmeter-dev/workspace/jmeter_B2-1/printable_docs/usermanual/component_reference.html#Regular_Expression_Extractor

Sorry, that should have been:

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

> Says:
>
> The syntax to refer to a group is: '$1$' to refer to group 1, '$2$' to
> refer to group 2, etc. $0$ refers to whatever the entire expression
> matches.
>

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


Re: Regular Expression Extractor

Posted by sebb <se...@gmail.com>.
Why not match both the fields in the one RE?
For example:

VAR
<a href="clusteridx\?.*id=(\d+)">(.+?)<

This will set

VAR_g1=1001
VAR_g2=Alternative

S.
On 20/04/06, Robert Heinerman <r....@3united.com> wrote:
> We have found a work around:
>
> The problem was, that both regex extractors where added to one HTTP
> request and that the second regex uses the result of the first regex.
> This works only for the first loop, at following loops maybe the
> ${clusterID6} variable is saved at the end of the request and so the
> value of the last loop may be used.
>
> Don't know the reason exactly, but if this one HTTP request is split up
> in two requests and each uses one regex extractor, everything works fine.
>
> BR
> rob
>
> Robert Heinerman schrieb:
> > Sorry, I have provided to less information.
> >
> > I have more than one of the following links on a page:
> > <a
> > href="clusteridx?l=en&amp;r=54262&amp;meta=genres&amp;id=1001">Alternative</a>
> >
> > <a
> > href="clusteridx?l=en&amp;r=35682&amp;meta=genres&amp;id=1002">Blues</a>
> > ...
> >
> > The first regex should parse anyone of the IDs e.g. "1002":
> >
> > clusterID6
> > <a href="clusteridx?.*id=(\d.*?)">
> > $1$
> > 0
> >
> > The second regex should parse the linktext of the link with the ID
> > parsed before, e.g. "Blues"
> > clusterName6
> > <a href="clusteridx\?.*id=${clusterID6}">(.*?)<
> > $1$
> > 0
> >
> > Then I use the ID for the next request, and the name as respone
> > assertion.
> >
> > The symtomps which lead to belive that JMeter confuses IDs from this
> > and the last loop is, that threads which loop more than once might
> > have the following text in the assertion results:
> >
> > GET
> > http://wap.napsterdemo.ericsson-mediasuite.com/content/wap2/dyn/clusteridx?id=1014&meta=genres&l=en&af=napster
> >
> > User-Agent: SonyEricssonW810i
> > X-SuppressDTD: true
> >
> > Cookie Data:
> > JSESSIONID=-OaErqqv4u_sJFe2Qq
> >
> >         Test failed, text expected to contain /Blues/
> >
> > In the case that the test fails like that, the ID and Name doesn't fit
> > togehter, maybe the regex are wrong.
> > Some tests work, some fail and I can't see any reason for that. I can
> > only say for sure that these tests never fail in the first loop.
> > Thank you for your help
> > BR
> > rob
> >
> >
> > sebb schrieb:
> >> On 19/04/06, Robert Heinerman <r....@3united.com> wrote:
> >>
> >>> Hi,
> >>>
> >>> we are using jmeter 2.1.1.
> >>>
> >>
> >> Good.
> >>
> >>
> >>> I use a regular expression extractor to parse an id, which is used for
> >>> the next request, and a name which is used for response assertion. The
> >>> regex for the name includes the extracted id.
> >>>
> >>> Everything works fine, as long each tread is looped only once. When
> >>>
> >>                                                        thread ?
> >>
> >>> looping more often, I think JMeter confuses the extracted
> >>> ids from this loop and the loop before. Is there any bug known? Is
> >>> there
> >>> any configuration?
> >>>
> >>
> >> Works OK for me.
> >> What are the symptoms you are seeing?
> >>
> >> Remember that the Regex Extractor is applied to EVERY sample in scope.
> >>
> >>
> >>> Example:
> >>>
> >>> clusterID6
> >>> <a href="clusteridx?.*id=(\d.*?)">
> >>> $1$
> >>> 0
> >>>
> >>> clusterName6
> >>> <a href="clusteridx\?.*id=${clusterID6}">(.*?)<
> >>> $1$
> >>> 0
> >>>
> >>
> >> What are you trying to match against?
> >> Please give an example, and say what you want to extract.
> >>
> >>
> >>> clusterID6 is used for the next request, ClusterName6 is used as
> >>> response assertion for this next request, which sometimes fails if
> >>> threads are looped more than once. Maybe the regex are not correct, my
> >>> knowledge about regex is limited.
> >>>
> >>> Another question is: what is the template field in the regular
> >>> expression extractor exactly? Didn't found any documentation.
> >>>
> >>
> >> file:///D:/eclipseworkspaces/Jmeter-dev/workspace/jmeter_B2-1/printable_docs/usermanual/component_reference.html#Regular_Expression_Extractor
> >>
> >>
> >> Says:
> >>
> >> The syntax to refer to a group is: '$1$' to refer to group 1, '$2$' to
> >> refer to group 2, etc. $0$ refers to whatever the entire expression
> >> matches.
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
>

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


Re: Regular Expression Extractor

Posted by Robert Heinerman <r....@3united.com>.
We have found a work around:

The problem was, that both regex extractors where added to one HTTP 
request and that the second regex uses the result of the first regex.
This works only for the first loop, at following loops maybe the 
${clusterID6} variable is saved at the end of the request and so the 
value of the last loop may be used.

Don't know the reason exactly, but if this one HTTP request is split up 
in two requests and each uses one regex extractor, everything works fine.

BR
rob

Robert Heinerman schrieb:
> Sorry, I have provided to less information.
>
> I have more than one of the following links on a page:
> <a 
> href="clusteridx?l=en&amp;r=54262&amp;meta=genres&amp;id=1001">Alternative</a> 
>
> <a 
> href="clusteridx?l=en&amp;r=35682&amp;meta=genres&amp;id=1002">Blues</a>
> ...
>
> The first regex should parse anyone of the IDs e.g. "1002":
>
> clusterID6
> <a href="clusteridx?.*id=(\d.*?)">
> $1$
> 0
>
> The second regex should parse the linktext of the link with the ID 
> parsed before, e.g. "Blues"
> clusterName6
> <a href="clusteridx\?.*id=${clusterID6}">(.*?)<
> $1$
> 0
>
> Then I use the ID for the next request, and the name as respone 
> assertion.
>
> The symtomps which lead to belive that JMeter confuses IDs from this 
> and the last loop is, that threads which loop more than once might 
> have the following text in the assertion results:
>
> GET 
> http://wap.napsterdemo.ericsson-mediasuite.com/content/wap2/dyn/clusteridx?id=1014&meta=genres&l=en&af=napster 
>
> User-Agent: SonyEricssonW810i
> X-SuppressDTD: true
>
> Cookie Data:
> JSESSIONID=-OaErqqv4u_sJFe2Qq
>
>         Test failed, text expected to contain /Blues/
>
> In the case that the test fails like that, the ID and Name doesn't fit 
> togehter, maybe the regex are wrong.
> Some tests work, some fail and I can't see any reason for that. I can 
> only say for sure that these tests never fail in the first loop.
> Thank you for your help
> BR
> rob
>
>
> sebb schrieb:
>> On 19/04/06, Robert Heinerman <r....@3united.com> wrote:
>>  
>>> Hi,
>>>
>>> we are using jmeter 2.1.1.
>>>     
>>
>> Good.
>>
>>  
>>> I use a regular expression extractor to parse an id, which is used for
>>> the next request, and a name which is used for response assertion. The
>>> regex for the name includes the extracted id.
>>>
>>> Everything works fine, as long each tread is looped only once. When
>>>     
>>                                                        thread ?
>>  
>>> looping more often, I think JMeter confuses the extracted
>>> ids from this loop and the loop before. Is there any bug known? Is 
>>> there
>>> any configuration?
>>>     
>>
>> Works OK for me.
>> What are the symptoms you are seeing?
>>
>> Remember that the Regex Extractor is applied to EVERY sample in scope.
>>
>>  
>>> Example:
>>>
>>> clusterID6
>>> <a href="clusteridx?.*id=(\d.*?)">
>>> $1$
>>> 0
>>>
>>> clusterName6
>>> <a href="clusteridx\?.*id=${clusterID6}">(.*?)<
>>> $1$
>>> 0
>>>     
>>
>> What are you trying to match against?
>> Please give an example, and say what you want to extract.
>>
>>  
>>> clusterID6 is used for the next request, ClusterName6 is used as
>>> response assertion for this next request, which sometimes fails if
>>> threads are looped more than once. Maybe the regex are not correct, my
>>> knowledge about regex is limited.
>>>
>>> Another question is: what is the template field in the regular
>>> expression extractor exactly? Didn't found any documentation.
>>>     
>>
>> file:///D:/eclipseworkspaces/Jmeter-dev/workspace/jmeter_B2-1/printable_docs/usermanual/component_reference.html#Regular_Expression_Extractor 
>>
>>
>> Says:
>>
>> The syntax to refer to a group is: '$1$' to refer to group 1, '$2$' to
>> refer to group 2, etc. $0$ refers to whatever the entire expression
>> matches.
>>
>> ---------------------------------------------------------------------
>> 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: Regular Expression Extractor

Posted by Robert Heinerman <r....@3united.com>.
Sorry, I have provided to less information.

I have more than one of the following links on a page:
<a 
href="clusteridx?l=en&amp;r=54262&amp;meta=genres&amp;id=1001">Alternative</a>
<a href="clusteridx?l=en&amp;r=35682&amp;meta=genres&amp;id=1002">Blues</a>
...

The first regex should parse anyone of the IDs e.g. "1002":

clusterID6
<a href="clusteridx?.*id=(\d.*?)">
$1$
0

The second regex should parse the linktext of the link with the ID parsed before, e.g. "Blues" 

clusterName6
<a href="clusteridx\?.*id=${clusterID6}">(.*?)<
$1$
0

Then I use the ID for the next request, and the name as respone assertion.

The symtomps which lead to belive that JMeter confuses IDs from this and the last loop is, that threads which loop more than once might have the following text in the assertion results:

GET http://wap.napsterdemo.ericsson-mediasuite.com/content/wap2/dyn/clusteridx?id=1014&meta=genres&l=en&af=napster
User-Agent: SonyEricssonW810i
X-SuppressDTD: true

Cookie Data:
JSESSIONID=-OaErqqv4u_sJFe2Qq

		Test failed, text expected to contain /Blues/

In the case that the test fails like that, the ID and Name doesn't fit 
togehter, maybe the regex are wrong.
Some tests work, some fail and I can't see any reason for that. I can 
only say for sure that these tests never fail in the first loop.
Thank you for your help
BR
rob


sebb schrieb:
> On 19/04/06, Robert Heinerman <r....@3united.com> wrote:
>   
>> Hi,
>>
>> we are using jmeter 2.1.1.
>>     
>
> Good.
>
>   
>> I use a regular expression extractor to parse an id, which is used for
>> the next request, and a name which is used for response assertion. The
>> regex for the name includes the extracted id.
>>
>> Everything works fine, as long each tread is looped only once. When
>>     
>                                                        thread ?
>   
>> looping more often, I think JMeter confuses the extracted
>> ids from this loop and the loop before. Is there any bug known? Is there
>> any configuration?
>>     
>
> Works OK for me.
> What are the symptoms you are seeing?
>
> Remember that the Regex Extractor is applied to EVERY sample in scope.
>
>   
>> Example:
>>
>> clusterID6
>> <a href="clusteridx?.*id=(\d.*?)">
>> $1$
>> 0
>>
>> clusterName6
>> <a href="clusteridx\?.*id=${clusterID6}">(.*?)<
>> $1$
>> 0
>>     
>
> What are you trying to match against?
> Please give an example, and say what you want to extract.
>
>   
>> clusterID6 is used for the next request, ClusterName6 is used as
>> response assertion for this next request, which sometimes fails if
>> threads are looped more than once. Maybe the regex are not correct, my
>> knowledge about regex is limited.
>>
>> Another question is: what is the template field in the regular
>> expression extractor exactly? Didn't found any documentation.
>>     
>
> file:///D:/eclipseworkspaces/Jmeter-dev/workspace/jmeter_B2-1/printable_docs/usermanual/component_reference.html#Regular_Expression_Extractor
>
> Says:
>
> The syntax to refer to a group is: '$1$' to refer to group 1, '$2$' to
> refer to group 2, etc. $0$ refers to whatever the entire expression
> matches.
>
> ---------------------------------------------------------------------
> 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: Regular Expression Extractor

Posted by sebb <se...@gmail.com>.
On 19/04/06, Robert Heinerman <r....@3united.com> wrote:
> Hi,
>
> we are using jmeter 2.1.1.

Good.

> I use a regular expression extractor to parse an id, which is used for
> the next request, and a name which is used for response assertion. The
> regex for the name includes the extracted id.
>
> Everything works fine, as long each tread is looped only once. When
                                                       thread ?
> looping more often, I think JMeter confuses the extracted
> ids from this loop and the loop before. Is there any bug known? Is there
> any configuration?

Works OK for me.
What are the symptoms you are seeing?

Remember that the Regex Extractor is applied to EVERY sample in scope.

> Example:
>
> clusterID6
> <a href="clusteridx?.*id=(\d.*?)">
> $1$
> 0
>
> clusterName6
> <a href="clusteridx\?.*id=${clusterID6}">(.*?)<
> $1$
> 0

What are you trying to match against?
Please give an example, and say what you want to extract.

> clusterID6 is used for the next request, ClusterName6 is used as
> response assertion for this next request, which sometimes fails if
> threads are looped more than once. Maybe the regex are not correct, my
> knowledge about regex is limited.
>
> Another question is: what is the template field in the regular
> expression extractor exactly? Didn't found any documentation.

file:///D:/eclipseworkspaces/Jmeter-dev/workspace/jmeter_B2-1/printable_docs/usermanual/component_reference.html#Regular_Expression_Extractor

Says:

The syntax to refer to a group is: '$1$' to refer to group 1, '$2$' to
refer to group 2, etc. $0$ refers to whatever the entire expression
matches.

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