Forum Discussion

sabereshcp's avatar
sabereshcp
Contributor
15 years ago

Assertions using groovy script

Hi Ole,

I have a doubt whether we can add assertions like (xpath,contains,not contains etc.,) in groovy script to assert the response from the server dynamically.

If yes, please share a code snippet used to carry out the same.It would of great help.

Thanks in Advance,
Saberesh C P

1 Reply

  • Beno_Iskratel's avatar
    Beno_Iskratel
    Frequent Contributor
    simple code from one of my projects:
    comparing 2 parameters from 2 different soap responses.

    def request = context.expand( '${modifySubscriberSupplementaryServiceSet_id - supp#Request#declare namespace urn=\'urn:iskratel-si:itnbsp-1-0\'; //urn:modifySubscriberSupplementaryServiceSetRequest[1]/subscriber[1]/@supplSrvSetId}' )
    def response = context.expand( '${getSubscriberSupplementaryServiceSet_id - supp#Response#declare namespace ns1=\'urn:iskratel-si:itnbsp-1-0\'; //ns1:getSubscriberSupplementaryServiceSetResponse[1]/subscriber[1]/param[1]/@supplSrvSetId}' )

    assert request==response

    i hope it helps,
    beno