Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
14 years ago

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

  • RJanecek's avatar
    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's avatar
    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