Error getting a node on SOAP UI's test case XPATH

可紊 提交于 2019-12-12 14:41:00

问题


I had been stuck while playing with the SOAP UI getting started tutorial because i can't produce an assertion condition for a simple testing. I'm Using the XPATH method to test the following SOAP message:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/">
         <GetCityWeatherByZIPResult>
            <Success>false</Success>
            <ResponseText>City could not be found in our weather data. Please contact CDYNE for more Details.</ResponseText>
            <State/>
            <City/>
            <WeatherStationCity/>
            <WeatherID>-1</WeatherID>
            <Description/>
            <Temperature/>
            <RelativeHumidity/>
            <Wind/>
            <Pressure/>
            <Visibility/>
            <WindChill/>
            <Remarks/>
         </GetCityWeatherByZIPResult>
      </GetCityWeatherByZIPResponse>
   </soap:Body>
</soap:Envelope> 

I'm using the following Xpath expression:

declare namespace i='http://www.w3.org/2001/XMLSchema-instance';
//i:GetCityWeatherByZIPResult[1]/i:Success[1]

and this is the error:

XPathContains assertion failed for path [declare namespace i='http://www.w3.org/2001/XMLSchema-instance';
//i:GetCityWeatherByZIPResult[1]/i:Success[1]] : Exception:Missing content for xpath [declare namespace i='http://www.w3.org/2001/XMLSchema-instance';
//i:GetCityWeatherByZIPResult[1]/i:Success[1]] in Response

回答1:


Using defined namespaces in SoapUI XPath assertions unnecessarily complicates things, and in some cases outright does not work. Start with just //*:GetCityWeatherByZIPResult/*:Success for your XPath, and work up from there as needed.



来源:https://stackoverflow.com/questions/24831248/error-getting-a-node-on-soap-uis-test-case-xpath

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!