0

This is my html

<input name="__RequestVerificationToken" type="hidden" value="A9y6Ndf7Q2XP2Yz6zhaVChoIvpQGUrZRTvu9D_HnHnUcFBVInerxCjU4vpOXQYVhFwnzl-zAzkvtto7BLAVVr">

I want to extract value in jmeter Regular Expression Extractor.enter image description here

This is my regx window but when i post it i will not get expected token it is something like this __RequestVerificationToken=%24%7Bauth_token%7D.

Aliaksandr Belik
  • 12,725
  • 6
  • 64
  • 90
MaTya
  • 782
  • 6
  • 11

2 Answers2

1

Try using $1$ as a Template, it should resolve your issue.

Looking into your request I can see that you're sending %24%7Bauth_token%7D which being decoded looks like ${auth_token} so you use case is not correct.

You need 2 requests:

  1. GET request to get the page and extract RequestVerificationToken and store it to auth_token variable.
  2. POST Request which will use auth_token variable.

See Using Regular Expressions in JMeter guide for more details.

By the way, you can use combination of Debug Sampler and View Results Tree listener to see if there are any matches. It should be more convenient w.r.t. groups and variables.

In general, it isn't recommended to use Regular Expressions to parse HTML. I would suggest to use XPath Extractor instead. Relevant XPath expression will look like:

//input[@name='__RequestVerificationToken']/@value

Few things to notice:

  • If you page isn't XHTML compliant you'll need to check Use Tidy box in XPath Extractor
  • JMeter 2.11 provides nice XPath Tester right in View Results Tree Listener
Community
  • 1
  • 1
Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • for every page "__RequestVerificationToken" will different so how i takecare that. i m using mvc4 & for each page there will be new token for example in login page token=123 & after login token=223 – MaTya Feb 05 '14 at 08:56
0

We need to set the following Regular Expression Extractor values to extract the auth token values

Reference Name : Auth_Token
Regular Expression : <input\sname="__RequestVerificationToken"\stype="hidden"\svalue="(.+)">
Template : $1$
Match No : 1
Default values : NOT FOUND TOKENS