I have an application using spring security , but when I am trying to login from Jmeter it always returns the login page. The jmeter scripts are loaded from jmeter.
Asked
Active
Viewed 1,345 times
1 Answers
1
Your test flow is not correct, it missing the first request, you should build your scenario as follows:
Open login page (HTTP GET Request)
- Extract the
_csrftoken value using a suitable JMeter Post-Processor
- Extract the
Replace hard-coded (recorded?) value of the
_csrfparameter with the JMeter Variable holding the value of the CSRF token.
More information: How to Load Test CSRF-Protected Web Sites
Dmitri T
- 159,985
- 5
- 83
- 133
-
Hi Dmitri T, I have tried adding the first request as get login and the post-precessor, but still facing the same issue: [1]: https://i.stack.imgur.com/DWg9E.png [1]: https://i.stack.imgur.com/9q0Mb.png [1]: https://i.stack.imgur.com/Qp3K6.png – theNoobProgrammer Feb 19 '19 at 11:14
-
I don't think you have this token in the [HTTP response headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers), my expectation is that you should switch the Regular Expression Extractor to look into `Body` instead. Also be informed that u[sing regular expressions to parse HTML is not the best idea](https://stackoverflow.com/a/1732454/2897748), [CSS Selector Extractor](https://www.blazemeter.com/blog/how-use-cssjquery-extractor-jmeter) will fit better. – Dmitri T Feb 19 '19 at 11:54

