Verify Element property value keeps failing


#1

I have set up a grab from our Soap service that produces the response (in Part)

<env:Envelope xmlns:env=“http://schemas.xmlsoap.org/soap/envelope/”>

env:Header/

env:Body

<ns0:modemMTAPollResponse xmlns:ns0="pulse.suddenlink.com/ws/house-call">

  <modemMTAPollResult>

    <modemCmtsMac/>

    <modemDhcpServerIp>172.24.120.93

    </modemDhcpServerIp>

    <modemFoundOnCmts>true

    </modemFoundOnCmts>

    <modemHasMta>true

    </modemHasMta>

    <modemIsPollable>true

    </modemIsPollable>...  

In the test itself I have:

response = WS.sendRequest(findTestObject(‘WHC SOAP/modemMTAPoll’, [(‘MAC’) : ‘083E5DF9E7C0’]))

WS.verifyResponseStatusCode(response, 200, FailureHandling.STOP_ON_FAILURE)

WS.verifyElementPropertyValue(response, ‘ns0:modemMTAPollResponse.modemMTAPollResult.modemIsPollable’, ‘true’)

I get the following Error:

09-13-2018 05:54:13 PM - [FAILED] - Unable to verify element property value (Root cause: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

Script1.groovy: 1: unexpected token: ns0 @ line 1, column 5.

def ns0:modemMTAPollResponse = new XmlSlurper().parseText(xmlText);return ns0:modemMTAPollResponse.modemMTAPollResult.@modemIsPollable

   ^

1 error

)

I have tried the locator a number of different ways and why I drop the first element it tells me that element is not found.

I am stumped and am now banging my head against my desk. Can anyone offer some insight? I fear its my own inability to understand something fundamental in the locator.


#2

Andrew,

You seem to have spotted a weak point in Katalon Studio with respect to XML Namespace in XML Response.

In Andrew’s case, the SOAP response body contains nodes with XML Namespace (xmlns:ns0=“pulse.suddenlink.com/ws/house-call”). On the other hand, Katalon Document https://docs.katalon.com/display/KD/Handle+Response+Messages describes a case where SOAP response body contains nodes without XML Namesapece.

With or Without XML-Namespace, this difference is quite significant for application which digests XML documents.

The following line is, I am sure, very problematic:

   def ns0:modemMTAPollResponse = new XmlSlurper().parseText(xmlText);
       ^

This message indicates that Katalon naively assumes that it can use the XML Element name (ns0:modemMTAPollResponse) as a variable name in Groovy. But colon character ( : ) is not valid as a component of variable name in Groovy. Therefore compilation error occurs.


#3

Andrew,

Your SOAP service is responding this way:

 <env:Body>
    <ns0:modemMTAPollResponse xmlns:ns0="pulse.suddenlink.com/ws/house-call">        <modemMTAPollResult>

To me, this response looks odd. I guess, your SOAP service might be still in development and could have some fault.

Is it possible to change your SOAP service so that it responds in the following way?

 <env:Body>
    <modemMTAPollResponse>        <modemMTAPollResult>

Or

 <env:Body>
    <modemMTAPollResponse xmlns="pulse.suddenlink.com/ws/house-call">        <modemMTAPollResult>

Or

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Header/>
  <env:Body>
    <ns0:modemMTAPollResponse xmlns:ns0="pulse.suddenlink.com/ws/house-call">
      <ns0:modemMTAPollResult>
        <ns0:modemCmtsMac/>
        <ns0:modemDhcpServerIp>172.24.120.93
        </ns0:modemDhcpServerIp>
        <ns0:modemFoundOnCmts>true
        </ns0:modemFoundOnCmts>
        <ns0:modemHasMta>true
        </ns0:modemHasMta>
        <ns0:modemIsPollable>true
        </ns0:modemIsPollable>...

#4

I found that by default XMLSlurper is not XML-Namespace aware. This can be turned on by declaring namespaces with the declareNamespace Method.

It is likely that Katalon is calling XMLSlurper without calling declareNamespace method.

Assuming that the XML-Namespace xmlns=“pulse.suddenlink.com/ws/house-call” is important, then the following format of SOAP response would be best friendly to Katalon:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">  <env:Header/>  <env:Body>    <modemMTAPollResponse xmlns="pulse.suddenlink.com/ws/house-call">      <modemMTAPollResult>        <modemCmtsMac/>        <modemDhcpServerIp>172.24.120.93        </modemDhcpServerIp>        <modemFoundOnCmts>true        </modemFoundOnCmts>        <modemHasMta>true        </modemHasMta>        <modemIsPollable>true        </modemIsPollable>...

I suppose you can work-around the compilation error caused by a collon (:slight_smile: character in variable name.

Anyway, I mean, you need to change your SOAP service in order to test it with Katalon Studio. :wink:


#5

Andrew,

Do you really need XML Namespace “pulse.suddenlink.com/ws/house-call” applied to the SOAP response? Just I doubt it.

I would suggest to you to discuss with your development team if it is necessary or not.