Reputation: 3
In application I'm testing the authenticity token is changed after user logs in - so I have to extract the token twice (once while login in, second after login). I use the Regular Expression Extractor.
At first time (during login) it works fine.
At second time (after login) it does not extract the new token - subsequent POST is sending given Reference Name (from Regular Expression Extractor) instead of extracted token.
I use different reference names in both extractors. Both pages have the same source and the tokens are defined in the same way:
<meta content="authenticity_token" name="csrf-param" />
<meta content="g/bsiegqqexUreoJdRbogKSpw6ZJ7O86fEUPESolrpc=" name="csrf token" />
So I use the same regular expression in both cases:
name="authenticity_token".*value="(.+)"
But, as I said, it works only for the first token.
Any help appreciated and thanks in advance
Upvotes: 0
Views: 612
Reputation: 168002
Simply don't use regular expressions to parse HTML. Any slight markup change in response, line break, whitespace, attributes order change, etc. and you get nothing.
You have two pretty PostProcessors designed for working with HTML response types:
Relevant configuration will look like:
meta[name=csrf token]
content
//meta[@name='csrf token']/@content
Use Tidy (tolerant parser)
boxUpvotes: 1