0
votes

Regular ExpressionI am trying to write regular expression using Jmeter from the Request tab of the result tree from :Cookie Data:" section and script doesn't pull the value:

[View Results> Request> Cookie Data:[][1][1]

Here is the regular expression I have tried:

Name of created variable: csrfToken Regular Expression: CSRF-TOKEN=(.+?) Template: $1$ Match No.: 1 Default Value: Not Found

3

3 Answers

0
votes

Try with Regular Expression below

CSRF-TOKEN=(\w+)

1
votes

You don't need to write regular expressions, you can extract any Cookie value from JMeter's HTTP Cookie Manager

  1. Add the next line to user.properties file:

    CookieManager.save.cookies=true
    
  2. Restart JMeter to pick the property up
  3. Add HTTP Cookie Manager to your Test Plan
  4. That's it, you should be able to refer your CSRF-TOKEN cookie value as ${COOKIE_CSRF-TOKEN} where required. The same applies to the ${COOKIE_JSESSIONID}

More information: HTTP Cookie Manager Advanced Usage - A Guide

0
votes

Use this regular expression to get whole value of CSRF-TOKEN

CSRF-TOKEN=(.*)