Forum Discussion

hngnango's avatar
hngnango
Occasional Contributor
8 years ago

error "unexpected end of file after null " into assertion script in Ready API 2.1

Hi I am getting this error "unexpected end of file after null " into assertion script .

My script is correct, however I still getting  this error ,so I am wondering what is the root cause of this error ?

 

Here is my script

mport com.eviware.soapui.support.XmlHolder
def log = this.log

// retrieve the field from response
def response = context.expand('${#getBank Request#response}')
def holder = new XmlHolder(response)

// expected Bankmane for input file
def expectedBankName = context.expand('${StartLoop#ExpectedBankName}')

// actual bank name from response
def actualBankName = holder.getNodeValue("//ns1:bezeichnung/test()")

// Print Actual status and expected status in the log
log.info " Expected Bank name is -> " + expectedBankName
log.info " Actual Bank name is -> " + actualBankName


if (actualBankname && expectedBankName){
content.testCase.setPropertyValue("result","Pass")
}
else {
content.testCase.setPropertyValue("result","Fail")
}

// Find the time by response to come

log.info "Time taken by response is ->" + content.testCase.teststeps["getBank Request"].testrequest.response.timetaken
def timetaken = context.testcase.testSteps["getBank Request"].testrequest.response.timetaken
def timetakeninsec = timetaken/1000

//set the time taken and actual status as test level property so the datasyn can write them in text result in excell fine
content.testCase.setPropertyValue("time",String.valueof(timetakeinsec))

  • Try changing this line:

    def response = context.expand('${#getBank Request#response}')



    To this line:

    def response = context.expand( '${getBank Request#Response}' )

    The lower-case r on response needs to be capitalized. 

  • I usually get around this by using a wildcard for the namespace, since in my test-beds the namespaces can fluctuate through environments.

     

    Instead of:

    def actualBankName = holder.getNodeValue("//ns1:bezeichnung/text()")

     

    Try this:

     

    def actualBankName = holder.getNodeValue("//*:bezeichnung/text()")
  • groovyguy's avatar
    groovyguy
    Community Hero

    Try changing this line:

    def response = context.expand('${#getBank Request#response}')



    To this line:

    def response = context.expand( '${getBank Request#Response}' )

    The lower-case r on response needs to be capitalized. 

    • hngnango's avatar
      hngnango
      Occasional Contributor

      Thank You.

      I updated accordingly…

      Not obvious  for me 😊

       

      Now I am getting  below error message

       

      net.sf.saxon.trans.XPathException: XPath syntax error at char 18 on line 2 in {\n//ns1:bezeichnung/text}: Prefix ns1 has not been declared

       

      because of this line

       

      def actualBankName = holder.getNodeValue("//ns1:bezeichnung/text()")

       

      when I  declared name space like this  declare name space ns1:"http://thomas-bayer.com/blz/" it does not fix  my issue

       

      Do  you have any idea ?

       

      Thank again

      • groovyguy's avatar
        groovyguy
        Community Hero

        I usually get around this by using a wildcard for the namespace, since in my test-beds the namespaces can fluctuate through environments.

         

        Instead of:

        def actualBankName = holder.getNodeValue("//ns1:bezeichnung/text()")

         

        Try this:

         

        def actualBankName = holder.getNodeValue("//*:bezeichnung/text()")