Question

I have a problem. I am using Regular Expression Extractor in Jmeter. I have two regex.

I can get the value from this.

Reference Name: as_fid_addtobasket

Regular Expression: <input type="hidden" name="as_fid" value="(.+?)" />

Template: $1$

But i can't get the value from this one.

> Reference Name: DynamicTempOrderProductGuid 
> 
> Regular Expression: <input data-val="true" data-val-required="The
> TempOrderProductGuid field is required."
> id="OrderProducts_1__TempOrderProductGuid"
> name="OrderProducts[1].TempOrderProductGuid" type="hidden"
> value="(.+?)" />
> 
> Template: $1$
> >

Here is my result. The second one doesn't get the value. Where is the thing i missed?

POST data: OrderProducts.index=1&OrderProducts%5B1%5D.TempOrderProductGuid=%24%7BDynamicTempOrderProductGuid%7D&OrderProducts%5B1%5D.Count=1&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.NameRec=Test+ama%C3%A7l%C4%B1d%C4%B1r.+L%C3%BCtfen+dikkate+almay%C4%B1n%C4%B1z&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.PhoneRec=05352233285&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.OSSendingReason=&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.OSReceiverAddressType=&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.CompanyNameRec=&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.AddressLineRec=Test+ama%C3%A7l%C4%B1d%C4%B1r.+L%C3%BCtfen+dikkate+almay%C4%B1n%C4%B1z&OrderProducts%5B1%5D.ProductCode=se213&OrderProducts%5B1%5D.TempOrderProductGuid=%24%7Btokentoken%7D&totalProducts=1&as_fid=efWZ0i4RGLmC2nBWk%2FA1

Was it helpful?

Solution

I would recommend using XPath Extractor instead as regular expressions are pretty dependent on layout, attributes order, spaces, etc. and can be a real headache to develop and test for non-experienced used. Especially multi-line ones.

XPath expression for extracting value from as_fid input will look like:

//input[@id='OrderProducts_1__TempOrderProductGuid']/@value

Some clues:

  1. If you're using JMeter 2.11 you'll be able to test your XPath expressions right in View Results Tree Listener
  2. You may need to check "Use Tidy" box in XPath Extractor if your HTML isn't XHTML compliant
  3. Check XPath Tutorial for language reference.

OTHER TIPS

Try this simpler regex for your second case:

<input.+?value="(.+?)"\s*/>

Demo

http://regex101.com/r/nI8nZ9

You can update the regex as the followings to get the valid DynamicTempOrderProductGuid

Reference Name: DynamicTempOrderProductGuid 
Regular Expression: name="(.+)"\stype="hidden"value="(.+)"
Template: $2$
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top