xpathwildcardsoapui

SoapUI XPath assertion with wildcards


Is there a way to use a wildcard inside an assertion in a XPath test with SoapUI?

I took a look at SoapUI's documentation and they say you can do something like this

<path1>
  <path2>*</path2>
</path1>

I checked the 'Allow Wildcards' checkbox.

My question is : I want to assert my date starts with 2012-08-22 but i dont care about the minutes and seconds. I guess my the expression should be something like 2012-08-22* but it doesn't work.


Solution

  • What you are doing sounds like it should work. Here is a quick example i cooked up using a rest service from http://www.geonames.org/export/web-services.html#timezone. I'm using the demo they have supplied

    http://api.geonames.org/timezone?lat=47.01&lng=10.2&username=demo output is

    <geonames>
       <timezone tzversion="tzdata2012c">
          <countryCode>AT</countryCode>
          <countryName>Austria</countryName>
          <lat>47.01</lat>
          <lng>10.2</lng>
          <timezoneId>Europe/Vienna</timezoneId>
          <dstOffset>2.0</dstOffset>
          <gmtOffset>1.0</gmtOffset>
          <rawOffset>1.0</rawOffset>
          <time>2012-07-25 04:39</time>
          <sunrise>2012-07-25 05:50</sunrise>
          <sunset>2012-07-25 21:00</sunset>
       </timezone>
    </geonames>
    

    If you do an xpath match on the result and use the select from current button you get

    //geonames/timezone/time

    2012-07-25 04:39

    If you update this to

    //geonames/timezone/time

    2012-07-25*

    this will work fine and when updating the rest request with a new lat and lng the assertion will still pass since it is not checking the time. If this doesn't help, please supply your full assertion and maybe i could help more.

    *note: for soap requests, make sure to declare the namespace and then use the proper format

    //ns1:message