在 SOAP UI 的测试用例 XPATH 上获取节点时出错 [英] Error getting a node on SOAP UI's test case XPATH

查看:25
本文介绍了在 SOAP UI 的测试用例 XPATH 上获取节点时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在玩 SOAP UI 入门教程时遇到了困难,因为我无法为简单的测试生成断言条件.我正在使用 XPATH 方法来测试以下 SOAP 消息:

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> 

我正在使用以下 Xpath 表达式:

I'm using the following Xpath expression:

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

这是错误:

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

推荐答案

在 SoapUI XPath 断言中使用定义的命名空间会不必要地使事情复杂化,并且在某些情况下完全不起作用.从 XPath 的 //*:GetCityWeatherByZIPResult/*:Success 开始,然后根据需要从那里开始工作.

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.

这篇关于在 SOAP UI 的测试用例 XPATH 上获取节点时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆