簡體   English   中英

Jmeter中的XML路徑聲明

[英]XML Path Assertion in Jmeter

我想在XPath Assertions一個值( ActualCode )。 我對JSON路徑聲明有豐富的經驗,但對XML而言是全新的。 我如何在這里斷言“ ActualCode”值?

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
 <S:Body>
  <ns2:CreateValidCode xmlns:ns2="http://www.example.net/lmsglobal/ws/v1/extint/types" xmlns="http://www.example.net/lmsglobal/xsd/v1/types" xmlns:ns3="http://www.example.net/lmsglobal/ws/v1/extint/notification/types">
     <ns2:ValidCode>ActualCode</ns2:ValidCode>
     <ns2:State>1</ns2:State>
  </ns2:CreateValidCode>

  1. 在某個地方(例如在JMeter.s的“ bin”文件夾中)創建一個.properties文件,即namespaces.properties
  2. 將以下行添加到namespaces.properties文件

     S=http://schemas.xmlsoap.org/soap/envelope/ ns2=http://www.example.net/lmsglobal/ws/v1/extint/types 
  3. 將下一行添加到user.properties文件,它也位於JMeter的“ bin”文件夾下

     xpath.namespace.config=namespaces.properties 
  4. 重新啟動JMeter來拾取屬性
  5. XPath斷言添加為返回XML以上的請求的子項
  6. 勾選Use Namespaces
  7. 將以下查詢放入“ XPath斷言”輸入中:

     //ns2:ValidCode/text()='ActualCode' 

應該是這樣。

有用的材料:

演示:

XPath命名空間演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM