Forum Discussion

tomptomp's avatar
tomptomp
Occasional Contributor
8 years ago

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

    • tomptomp's avatar
      tomptomp
      Occasional Contributor

      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