Hi all,
I have a problem with WS.verifyElementText.
I try to validate a response in “text/xml; charset=utf-8” format, but it seems to me that Katalon tries to parse it with a json parser instead of xml.
The functionality is documented here:
Handle Response Messages | Katalon Docs
This is the code:
WS.comment('Check if Service Simulator is Empty')
isempty_response = WS.sendRequest(findTestObject('Tools/ServiceSimulator/Recorder/IsEmpty'))
WS.verifyResponseStatusCode(isempty_response, 200, FailureHandling.CONTINUE_ON_FAILURE)
WS.verifyElementText(isempty_response, 'IsEmptyResponse.IsEmptyResult', 'true')
The response looks like this:
Response ContentType:
text/xml; charset=utf-8
Response Body:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><ActivityId CorrelationId="70353019-b5cb-4159-8f09-96494bcafc3e" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">00000000-0000-0000-0000-000000000000</ActivityId></s:Header><s:Body><IsEmptyResponse xmlns="http://tempuri.org/"><IsEmptyResult>true</IsEmptyResult></IsEmptyResponse></s:Body></s:Envelope>
This is the error message thrown by Katalon:
08-31-2022 08:43:30 AM verifyElementText(isempty_response, "IsEmptyResponse.IsEmptyResult", "true")
Elapsed time: 0,093s
Unable to verify element text (Root cause: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
The current character read is '<' with an int value of 60
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><ActivityId CorrelationId="70353019-b5cb-4159-8f09-96494bcafc3e" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">00000000-0000-0000-0000-000000000000</ActivityId></s:Header><s:Body><IsEmptyResponse xmlns="http://tempuri.org/"><IsEmptyResult>true</IsEmptyResult></IsEmptyResponse></s:Body></s:Envelope>
^
at Script1.run(Script1.groovy:1)
at com.kms.katalon.core.webservice.helper.WebServiceCommonHelper.parseAndExecuteExpressionForJson(WebServiceCommonHelper.java:212)
Do you know what my mistake is? I thought that Katalon will recognize the response format by response header?
Thank you in advance for your help
greetings
Jan