2013-08-30 39 views
1

我做的測試案例上的soapUI,對一些步驟,我會用一個REST的追求,並把XML代碼在下面的窗格中,像的soapUI - 使用Groovy

<dataList> 
    <data> 
     3.1416 
    </data> 
    <data> 
     5.11 
    </data> 
</dataList> 

但我embbed XML的請求需要獲取響應並將結果存儲在響應的XML文本中,以驗證Web服務正在執行正確的操作,然後使用收到的結果發送更多請求。

謝謝大家!

+0

你嘗試過什麼?這是一個很常見的操作,你已經問過,我想可能以前在stackoverflow中回答過? –

+0

其實我不知道如何從響應中獲取數值(令人尷尬:$) – ulitosCoder

+0

如果你不知道那麼最好的地方是[http://www.soapui.org](http ://www.soapui.org)查看左邊的菜單。這是一個開始的好地方。 –

回答

1

Groovy腳本測試步驟與您的測試套件如下所說:

def grUtils = new com.eviware.soapui.support.GroovyUtils(context) 
def holder = grUtils.getXmlHolder(
       context.expand('${TestStep#Response#//node}')) 

println holder.getXml() 

//where TestStep = Your test Step where you get the response 
//node = The xml node you want to pick. In your case it is "dataList" 
+0

表達式$ {TestStep#Response#dataLis}'出現錯誤org.apache.xmlBeans .XmlException:錯誤:意外的元素:CDATA – ulitosCoder

2

我可以解決這個使用屬性和產權轉讓

  1. 一個屬性添加到的TestCase的自定義屬性選項卡

  2. 添加屬性轉移步驟

    2.1 As源選擇與在是響應所述測試步驟的結果存儲

    2.2在下拉屬性選擇ResponseAsXml的列表

    2.3文本是源的寫的XML標籤等的路徑: /數據列表/數據

    2.4作爲目標選擇其中的溶液中加入(1)

    2.5自定義屬性作爲目標屬性選擇名稱的自定義屬性添加的測試用例。

非常感謝大家對你的提示答案:) 只要我有更好的聲譽我會後一些照片。

enter image description here enter image description here