mmoser18
8 years agoFrequent Contributor
Contains assertion with option "Use Token as regular expression" not working
I reported a similar case a while ago but never got a response there - so again: The "Contains Assertion" with "Use token as regular expression" is not working! E.g. I have a case where I need t...
- 8 years ago
I guess your response body is multiline? In this case <status>(OK|WARNING)</status> alone won't work because the regex needs to match the entire response body.
Try this:
(?s).*<status>(OK|WARNING)</status>.*
(?s) is the flag that enables . to match line breaks, so that the pattern can match a multiline response.
Alternatively, you can use the XPath Match assertion with this expression:
matches(//status/text(), 'OK|WARNING')
and expected result = true.