Ask a Question

I am trying to assert in groovy that any value appears in this tag in the response. A wildcard

tomptomp
Occasional Contributor

I am trying to assert in groovy that any value appears in this tag in the response. A wildcard

I am trying to assert in groovy that any value appears in this tag in the response and creating a wildcard in a RegEx in groovy is killing me:

 

GivenName>AnyValue<

 

 

 

def response = context.expand( '${GetPersonnelRetrievalType#Response#declare namespace s=\'http://schemas.xmlsoap.org/soap/envelope/\'; //s:Envelope[1]}' )


def SearchParameter1 = context.expand( '${#TestCase#SearchParameter1}' )

 

I tried:
assert response.contains(SearchParameter1 + ">" {/./} +"<")

assert response.contains(SearchParameter1 + ">" {/*/} +"<")

assert response.contains(SearchParameter1 + ">" {/.+/} +"<")

assert response.contains(SearchParameter1 + ">" /.+/ +"<")

 

ad infinitum.

 

Help!

2 REPLIES 2
MarcusJ
Moderator

Re: I am trying to assert in groovy that any value appears in this tag in the response. A wildcard

Hi,

 

Is there a particular reason you need to use a Groovy script to do this?  You can do this easily using an XPath assertion.

 

http://readyapi.smartbear.com/features/get_data/xpath/assertion

 

Regards,

Marcus

SmartBear Support



Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
tomptomp
Occasional Contributor

Re: I am trying to assert in groovy that any value appears in this tag in the response. A wildcard

Because XPath expressions include the other elements of the XML and namespace specifics which in my scenario will change from response to response.

 

I suppose I could use the built in 'Contains' assertion but I would still need to insert a RegEx wildcard into it, which I cannot figure out

cancel
Showing results for 
Search instead for 
Did you mean: