2011-06-02 83 views
1

我需要使用JMeter的XPath來測試一下,我有一個響應文本的XPath assertionfor在JMeter的SOAP Web服務

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <ns2:createIndexResponse xmlns:ns2="http://webservice.example.com/"> 
     <example> 
      <name>foer</name> 
     </example> 
     </ns2:createIndexResponse> 
    </soap:Body> 
</soap:Envelope> 

,我需要測試,如果名稱是等於弗爾,我使用的XPath斷言作爲/example/name/entry[@key='name']/text()='foer'但我得到:

No Nodes Matched `/example/name/entry[@key='name']/text()='foer' 

回答

3

在您的示例XML沒有entry元素,沒有@key屬性。加上example元素不是根元素。

試試這個,而不是隻是檢測是否存在:

//example/name/text() = "foer" 

或選擇example元素:

//example[name/text() = "foer"] 
+0

我想了JMeter的斷言的XPath表達式將'//例子/名稱/ text()=「foer」' – McDowell 2011-06-02 10:03:22