Forum Discussion

ryanshoward's avatar
Occasional Contributor
9 years ago

Contains assertion using Regex failing

Hi, I'm trying to implement some assertions using regex but I cannot get it working properly   in my soap response I have an element which looks like this:   <UploadResult>BOPS201511001CDIS-7</U...
  • nmrao's avatar
    9 years ago

    Both of your regular expressions matches intended string, however, you might be experiencing failure.

    It is because:

    1. that is only matching partial string, but not entire response
    2. if you are providing value in the content, special characters needs to be escaped

    Below regex should work i.e., match anything before and after original regex(which you mentioned)



    You may also use Property Expansion, then no need to escape.


    Define Test Case level custom property, say REGEX_CONTENT with value



    Use ${#TestCase#REGEX_CONTENT} as content in Contains Assertion.