Contain assertion - how can I 'blank out' a part of element text which changes with every response
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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>
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi tester213243
Can you try <ns1:RandomNumber>[1-9][1-9][1-9]</ns1:RandomNumber> . hope it works
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @arunbharath
No unfortunately that doesnt work either.
There are many numbers in my response but if i just create a contain-assertion with [1-9] it fails.
Also if i check the box 'Use token as regular expression'.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Instead of contains, use XPath assertion and provide the node, then use regular expression. If you are expecting 3 digits, try like
\d{3}
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you can use regular expression .* to check if field is not null
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓
Thanks and Regards,
Himanshu Tayal
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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 🙂
Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓
Thanks and Regards,
Himanshu Tayal
