tags:

views:

68

answers:

1

Jmeter is not extracting correctly the value with the reg ex. When I play with this reg ex (NAME="token" \s value="([^"]+?)") in reg ex coach with the following html everything work fine but when adding the reg with a reg ex extrator to the request he doesn't found the value even if it's the same html in output.

<HTML>< script type="text/javascript" >
function dostuff(no, applicationID)
{
    submitAction('APPS_NAME' , 'noSelected=' + no + '&applicationID=' + applicationID);
}< /script>

<FORM NAME="baseForm" ACTION="" METHOD="POST">
  <input type="hidden" NAME="token" value="fc95985af8aa5143a7b1d4fda6759a74" >

    <div id="loader" align="center">
     <div>
         <strong style="color: #003366;">Loading...</strong>
     </div>
     <img src="images/initial-loader.gif" align="top"/>
 </div>

   <BODY ONLOAD="dostuff('69489','test');">

From the reg ex extractor

reference name: token

Regex: (NAME="token" \s value="([^"]+?)")

template : $2$

match no.:1

Default value: wrong-token

The request following my the POST of the previous code is returning : POST data: token=wrong-token

in the next request in the tree viewer.

But when I check a the real request in a proxy the token is there.

Note : I tried the reg ex without the bracket and doesn't worked either.

Do anybody have a idea whats wrong here ? Why jmeter can't find my token with the reg ex extrator ?

+1  A: 

Your regex looks for the text NAME="token", followed by a space, followed by a space, tab or newline, followed by a space, followed by the text value=", followed by one or more non-quote characters, followed by another ".

If it doesn't find that in the string it's looking at (and your text sample doesn't match), it fails.

What are you really trying to do? It looks like you're parsing HTML with regex. Not a good idea.

Tim Pietzcker
I'm trying to extract the value of the token to a jmeter variable so that the next request will be able to have the value. More info on that here http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Regular_Expression_ExtractorI'm trying to get the value after value= between quote.
Chris
Thanks for your input Tim it helped me to find out what was the problem. It's seem that reg ex coach ignore the space in my reg ex but not jmeter. I found a tool on the jakarta-oro site (http://jakarta.apache.org/oro/demo.html) that use the same matching pattern and I was able to found a reg ex that work. The actual reg ex that work is (NAME="token".value="([^"]+?)")
Chris