Forum Discussion

Aman85's avatar
Aman85
Occasional Contributor
8 years ago

Complex Assertion parameterization

Hi,   How do i assert the airport name where airport code is ANR from the response below.I do not want to use the index but a dynamic value. Say there are 10 records listed.How do i assert which b...
  • nmrao's avatar
    8 years ago

    Looks you are using Script Assertion.

     

    Here is the script:

     

    //Define expected airport name
    def expAirportName = 'ANTWERP DEURNE'
    
    def dataSet = new XmlSlurper().parseText(context.response).'**'.find{ it.name() == 'GetAirportInformationByCountryResult'} as String
    def airportName = new XmlSlurper().parseText(dataSet).'**'.find{ it.name() == 'AirportCode' && it == 'ANR'}.parent().CityOrAirportName.text()
    log.info "Airport name is ${airportName} where code is ANR"
    
    assert expAirportName == airportName, 'Does not match with expected value'