2017-08-01 36 views
2

我已經創建了Web服務項目。以下是我的測試用例的腳本,用於驗證如圖所示documentation元素文本:Katalon Studio:如何爲啓用了MTOM的SOAP Web服務創建VerifyElementText測試用例?

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject 
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS 

def response = WS.sendRequest(findTestObject('ProductById')) 
WS.verifyElementText(response, "Product.Reference", "MyReference") 

當我運行這個測試情況下,我得到的錯誤:[FAILED] - Unable to verify element text (Root cause: org.xml.sax.SAXParseException: Content is not allowed in prolog.)

然後我用:com.kms.katalon.core.util.KeywordUtil#logInforesponse.responseText,我已收到,這是:

--uuid:4e39ea48-6560-46b7-a30c-201dfaf98f51 
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"; 
Content-Transfer-Encoding: binary 
Content-ID: <[email protected]> 

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getProductResponse xmlns:ns2="http://mycompany.com/"><Product><Reference>VW3A8306R</Reference></Product></ns2:getProductResponse></soap:Body></soap:Envelope> 
--uuid:4e39ea48-6560-46b7-a30c-201dfaf98f51-- 

Web服務我測試MTOM啓用。這就是爲什麼響應文本是這種格式。

如何在這種情況下創建測試用例?

回答

3

您可以拆分內容,然後繼續使用該內容。以下是在這種情況下Katalon Studio腳本以幫助您:

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject 
    import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS 

    def response = WS.sendRequest(findTestObject('ProductById')) 
    response.responseText = (response.responseText =~ '<soap:Envelope.* 
    </soap:Envelope>')[0] 
    WS.verifyElementText(response, "getProductResponse.Product.Reference", 
    "MyPreference") 
相關問題