Forum Discussion

paulie's avatar
paulie
Occasional Contributor
10 years ago

Grid value may not exist in xpath assertion

I've an xpath match assertion where I check that the expected result is equal to the sum of some values from a Grid datasource e.g.
${DataSource#Billed1} + ${DataSource#Billed2}


However, some of the values in the datasource may be left blank. Is there a regular expression or some other way that I get it to ignore the blank values without having to use a groovy script. I could explicitly see the values to 0 in the Grid but if there was a neater solution it'd be great.

Thanks.

1 Reply

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    You can use script assertion and parse the Xpath value so try this,
    add a script assertion and the following script

    import com.eviware.soapui.support.XmlHolder

    if (${DataSource#Billed1} != null && ${DataSource#Billed2} != null){

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

    def holder = new XmlHolder( response)
    log.info holder["//XPATH node or /Xpath"]
    assert holder["//XPATH node or /Xpath"] == ${DataSource#Billed1} + ${DataSource#Billed2}

    }




    Thanks,
    Jeshtha