Forum Discussion

harry21's avatar
harry21
Occasional Contributor
7 years ago
Solved

Getting MissingMethodException while calling Groovy class in a script

Below is the groovy script which I would like to convert into reusable Groovy class   def resp = context.testCase.getTestStepByName(retrieveSequenceNumberAfter).getPropertyValue("ResponseAsXml") d...
  • nmrao's avatar
    7 years ago

    Below is the class for Script Library:

     

     

    package com.linos.readyapi.util.transaction
    
    class Utility {
    
        static def getData(response, element) {
          assert response, 'response is empty'
          def pXml = new XmlSlurper().parseText(response)
          pXml.'**'.findAll {it.name() == element}
        }
        
    }

     

    In the Script Assertion, use below statements:

     

    import static com.linos.readyapi.util.transaction.Utility.getData
    log.info "Details from response: ${getData(context.response, 'transaction_id')}"