Forum Discussion

tester213243's avatar
tester213243
New Contributor
5 years ago
Solved

Contain assertion - how can I 'blank out' a part of element text which changes with every response

Hello fellow soap users, 

I am building a regression test. And the easiest way is ofcourse to make one contain-assertion of the complete response. However, there are elements that change everytime I execute. 

For example: 

       <ns1:RandomNumber>234</ns1:RandomNumber>  

Is there I way I can validate if the response contains something like: 
       <ns1:RandomNumber>XXX</ns1:RandomNumber>  

With the XXX that 'blank out' that part of the validation. So it only checks the presence of the positions, and not what it actually says there?

Kind regards

11 Replies

    • tester213243's avatar
      tester213243
      New Contributor

      Hi Rao, 

      Thanks for the quick reply, appreciate your time. 

      But how would that work in my example if i want to use the regular expressions?

      For example, apparently a dot should match any character or \d should match any digit. But if i do the following it doesn't work: 

       

      Response:

             <ns1:RandomNumber>234</ns1:RandomNumber> 

      Contain Assertion: 

             <ns1:RandomNumber>...</ns1:RandomNumber> 

      or   <ns1:RandomNumber>\d\d\d</ns1:RandomNumber> 

       

      • arunbharath's avatar
        arunbharath
        Contributor

        Hi tester213243

         

        Can you try <ns1:RandomNumber>[1-9][1-9][1-9]</ns1:RandomNumber> . hope it works

  • tester213243  :

     

    instead of contains assertion use Script assertion it will check the particular node value.

    User jsonSlurper to get the node value and assert like below

     

    assert nodeValue != ""

     

    and if you know the random value then assert like

     

    assert nodeValue == expectedValue

     

  • tester213243  : Have you got the chance to test the solutions provided. If solved then please mark as solve as it will help other help seekers :)