Ask a Question

Xpath OR assertion

alibaba82
Super Contributor

Xpath OR assertion

Hello,
I have a content assertion for an element where it is possible to have true to false value. How can I create a OR type of assertion ? I tried using 'true OR false' in the 'expected result but that does not work.

Thanks

Ali
2 REPLIES 2
RJanecek
Regular Contributor

you can use script assertion:

def content = ... // content of element
if ( content.equals("true") | content.equals("false") ) assert true
else assert false
SmartBear_Suppo
SmartBear Alumni (Retired)

Hello,

You can use a script assertion as stated above, or you can change the XPath Expression to do the logic instead of the expected result, for example:

XPath Expression

declare namespace sam='http://www.soapui.org/sample/';
//sam:loginResponse[1]/sessionid[1]/text()="5549610890627010" or
//sam:loginResponse[1]/sessionid[1]/text()="5549610890627013"


Expected Result

true


The above example asserts that the session id is either 5549610890627010 or 5549610890627013, you can apply the same principle to asserting "true" or "false".

Regards,
Dain
eviware.com

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: