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 to assert that the response contains either:
<status>OK</status>
or
<status>WARNING</status>
Phrased as a regular expression I would describe this as:
<status>((OK)|(WARNING))</status>
... but if I enter that into the content field of a "Contains assertion" the assertion NEVER matches.
I also tried:
.*<status>((OK)|(WARNING))</status>.*
... but same result: no match. :-(
I verified that regexp with a tool (RegEx-Buddy) and that regexp *does* match the above strings.
So, what am I missing here? How can one specify a reg-exp that does match in a contains assertion?
- 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.