Ask a Question

adding assertions in soap ui to validate xml response tags with database values

SOLVED
vineethwip
New Contributor

adding assertions in soap ui to validate xml response tags with database values

hi,

 

I am new to soap ui.can someone help me with adding assertions in soapui to do automated testing of validation of xml response with database values

 

attached is sample request and response

5 REPLIES 5
PaulMS
Super Contributor

You can start with a JDBC request to query database values and XPath assertions to compare the result to XML response.

https://community.smartbear.com/t5/SoapUI-Pro/Compare-Results-of-Soap-Response-with-JDBC-Response/td...

I am unable to get the element from response using xpath

 

declare namespace ns='https://ams-un-service-ams-ist.cf.wgdc-drn-01.cloud.uk.hsbc/amss.hsbc.com/counterparty-risk-list';
//ns:counter_party_risk_list[1]/ns:counter_party_risk[1]

 

its giving invalid xpath match

 

Do I need to provide header and authentication also in namespace declaration?

JHunt
Community Hero

 

These are all as examples of Script assertions you can add.

 

new XmlSlurper()
.parseText (messageExchange.responseContentAsString)
.counter_party_risk
.with { assert it.size() == 8 }
new XmlSlurper()
.parseText (messageExchange.responseContentAsString)
.counter_party_risk[1]
.with { assert it.alert_id == '1767159' }
new XmlSlurper()
.parseText (messageExchange.responseContentAsString)
.counter_party_risk
.collect { risk -> risk.counter_party_name }
.with { assert it == ['45XVQ V7I 45XVQ U0CW2 X2T',
                      'N45VU2TT8 40 S2T I2V8 QY2TC2',
                      '2QWQ WQV2U QV SCAS 70ZQ440 V7I',
                      'N W EQ7QA IC78 OA22 40 ZQTP',
                      'N0TI2V2R 2QW72AT 2CA0X2 N5IIV2',
                      'WQZZ GGD 9L9L9L GGD QV AQZ52 W',
                      'TQ750TQV 7AQI5TS I2Y2V0X5T',
                      'QV 0CO0CP 40'] }
new XmlSlurper()
.parseText (messageExchange.responseContentAsString)
.counter_party_risk
.collect { risk -> risk.total_score }
.each { assert !( it.toFloat() > 2 ) }

 

 

PaulMS
Super Contributor

Did you click the Declare button under the XPath expression header to add namespace declaration?

 

A wildcard could be used to skip the declaration if that causes a problem

//*:counter_party_risk_list[1]/*:counter_party_risk[1]

 

https://www.soapui.org/docs/functional-testing/validating-messages/validating-xml-messages.html

 

 

Thanks PaulMS,wildcard declaration helped

cancel
Showing results for 
Search instead for 
Did you mean: