jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gareth Western <jme...@garethwestern.com>
Subject Regex to extract hidden input AND url parameter
Date Thu, 26 Jan 2006 15:58:18 GMT
Hi All,

I'm trying to write a regular expression to extract the value for a variable
from each HTML response in my test script. This value is dynamically generated
for each page, and can either be a hidden input (ie in a form) or a parameter
on the end of a link.

The variable name is always: org.apache.struts.taglib.html.TOKEN

The value has variable length, but is always a series of alphanumeric
characters.

I've been working on this regex using the Jakarta ORO demonstration applet at:
http://jakarta.apache.org/oro/demo.html

The example text i've been using for the ORO applet is:

<input type="hidden" name="foobar" value="bazbar" />
<input type="hidden" name="org.apache.struts.taglib.html.TOKEN" value="token1"/>
<a href="myAction.do?org.apache.struts.taglib.html.TOKEN=token2&myName=Gareth"
/>
<a href="myAction.do?org.apache.struts.taglib.html.TOKEN=token3" />
<a href="myAction.do?foo=bar&org.apache.struts.taglib.html.TOKEN=token4" />

Finally, the regular expression is as follows:
org\.apache\.struts\.taglib\.html\.TOKE(?=N['"][\s]value=['"]([^'"]+))|(?=N=([^&'"]+))

I removed the "N" from the token to prevent the regex matching all parameters in
a URL (e. "Gareth" from
"org.apache.struts.taglib.html.TOKEN=token2&myName=Gareth")

The only problem remaining, as you can see if you run the regex and the sample
text in the applet, is that each "half" of the regex (ie the half to check
hidden inputs, and the half to check the URLs) returns two matches, therefore I
can't know which "match no" to specify for the Regular Expression Extractor in
JMeter.

Thanks very much if you're still reading this far, and even bigger thanks if you
can help me out!

Regards,

Gareth

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


Mime
View raw message