0

I am trying to send a POST request to my login url from JMeter:

enter image description here

In order to do inject csrf token, I am using regular expression extractor, which looks like this:

enter image description here

I can confirm that regular expression is working:

enter image description here

However, ${token} is not being replaced:

enter image description here

What could be wrong?

P.S. How request is structured:

enter image description here

Jahongir Rahmonov
  • 13,083
  • 10
  • 47
  • 91

1 Answers1

1
  1. Regular Expression extractor (as well as any other Post-Processors) follow Scoping Rules so you need to place it as a child of the request which returns this value
  2. Using regular expressions to parse HTML is not the best idea (they are too fragile and sensitive to any markup change), I would recommend switching to CSS/JQuery Extractor instead, the relevant configuration should be as simple as:

    • Reference Name: token
    • CSS/JQuery Expression: input[name=csrfmiddlewaretoken]
    • Attribute: value
Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thank you for your answer. I posted an updated. I think I put extractor as a child. Can you please take a look – Jahongir Rahmonov Jul 11 '17 at 14:59
  • You misunderstand "correlation" concept. Your test should look as follows: 1. Open Login Page (GET request). 2 Extract CSRF token 3. Perform Login (POST request) providing credentials and the token. See [How to Load Test CSRF-Protected Web Sites](https://www.blazemeter.com/blog/how-load-test-csrf-protected-web-sites) for more details. – Dmitri T Jul 11 '17 at 15:14
  • It makes total sense now. Thank you. – Jahongir Rahmonov Jul 11 '17 at 15:39