Hello!
My colleague is currently doing a proof of concept with Katalon Studio.
He wants to mainly test his REST API and a little of Web UI.
We think we encountered a bug with the tool, as after reading many pages of documentation, we did not found what we were doing wrong
To be honest, should this problem not be solved, as this test is his main use case, we would abandon the POC (and try with another tool).
Environment
Operating System : Windows 10
Katalon Studio version 8.1.0
Quick Description of the problem
Verifying a response’s XML body text is failing, even though the keyword’s locator parameter was fetched using Ctrl+K shortcut in the “Response Body” view in the Object Repository (which displays the expected value of the response).
We noticed that the ResponseObject’s getResponseBodyContent method does not return all XML nodes but only ErrorCode node. Then, we tried to verify the ErrorCode text and it unexpectedly matched.
Our error logs :
09-06-2021 03:16:37 PM verifyElementText(response, "DocumentID", "A2")
Elapsed time: 0,259s
Unable to verify element text (Root cause: com.kms.katalon.core.exception.StepFailedException: Expected text is 'A2' but actual element text is: 1
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:50)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementTextKeyword$_verifyElementText_closure1.doCall(VerifyElementTextKeyword.groovy:52)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementTextKeyword$_verifyElementText_closure1.call(VerifyElementTextKeyword.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:74)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementTextKeyword.verifyElementText(VerifyElementTextKeyword.groovy:45)
at com.kms.katalon.core.webservice.keyword.builtin.VerifyElementTextKeyword.execute(VerifyElementTextKeyword.groovy:40)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:74)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.verifyElementText(WSBuiltInKeywords.groovy:253)
at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords$verifyElementText$1.call(Unknown Source)
at TestTNRInquiry.run(TestTNRInquiry:28)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:430)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:421)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:400)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:392)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:273)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1630934178960.run(TempTestCase1630934178960.groovy:25)
Steps to reproduce:
The test case is sending a POST request with a XML body to a REST API, fetching the response and then verifying the XML body of the response.
Test Case script (I removed the imports as there does not seem to be any issue with them):
response = WS.sendRequest(findTestObject('Stock-A25-XML-CAT')) // (1)
WS.verifyResponseStatusCode(response, 200) // (2)
WS.comment(response.getResponseText().toString()) // (3)
WS.verifyElementText(response, 'ErrorCode', '1') // (4)
WS.verifyElementText(response, 'DocumentID', 'A2') // (5)
The lines (3) and (4) were added for debugging purposes.
Line (3) returns, as expected, the full xml raw text:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:quote_A2 xmlns:ns2="http://www.reifen.net">
<DocumentID>A2
</DocumentID>
<Variant>5
</Variant>
<ErrorHead>
<ErrorCode>1
</ErrorCode>
</ErrorHead>
<CustomerReference>
<DocumentID>
</DocumentID>
</CustomerReference>
<BuyerParty>
<PartyID>233082
</PartyID>
<AgencyCode>92
</AgencyCode>
</BuyerParty>
<OrderLine>
<LineID>1
</LineID>
<OrderedArticle>
<ArticleIdentification>
<EANUCCArticleID>3528708756786
</EANUCCArticleID>
</ArticleIdentification>
<RequestedQuantity>
<QuantityValue>2
</QuantityValue>
</RequestedQuantity>
<Error>
<ErrorCode>940
</ErrorCode>
<ErrorText>Incorrect supplier material number (not known on supplier side)
</ErrorText>
</Error>
</OrderedArticle>
</OrderLine>
</ns2:quote_A2>
But, getResponseBodyContent would only return <ErrorCode>1</ErrorCode>
The line (4) is unexpedly succeeding, while the line (5) is unexpectedly failing with the error code above.
Thank you for your help!