I need to extract a CSRF token from a webpage, then log it via BeanShell. The latter part is working thanks to the help I received in this thread, but now I need to figure out how to get ${token} to populate with the right data.
Note: I know the Regular Expression Extractor is not the preferred method, but I have to stay within the parameter of the exercise, in this case.
First, I have a HTTP Request set to perform a GET against www.blazedemo.com/register.
Second, I checked the response data shown in the response tree to find the CSRF token:
<!-- CSRF Token -->
<meta name="csrf-token" content="4ZCKKqQgwJH5lT5dQSeAwgeyOr7plAe7IOVRGmQm">
I have a Regex Extractor setup to grab it:
In case it fails to do so, I have default set as "NOT_FOUND".
Finally, I have a post processor logging whatever value is given to ${token}.
I find the following in my log:
2017-10-31 15:12:31,975 INFO o.a.j.u.BeanShellTestElement: The token is: NOT_FOUND