Ask a Question

Using wildcards in Contains Assertion

SOLVED
EdTheTester
New Contributor

Using wildcards in Contains Assertion

Hi all

 

I am brand new to SoapUI and am trying to start with some basic coverage.  The problem I am currently having is I am trying to assert the contents of an XML response but it contains data that varies.  I had hoped I could use a wildcard to ignore the relevant section of the response but I can't see how I can do this.

 

Here is an example of the content I am trying to assert:

<option id="1" bid="1" rv="2" desc="Standard cover" monthly="£10.00" annual="£120.00">No</option>

<option id="2" bid="1" rv="2" desc="Better cover" monthly="£20.00" annual="£240.00">Yes</option>

 

The premium is what varies, I need to assert what comes before and after it in a single assert (I need to tie the Yes/No together with the option ID).  Can this be done?

 

Any help you can provide would be much appreciated.

 

Cheers

 

Ed

4 REPLIES 4
sanj
Super Contributor

Why dont you use regular expressions

You need to check the regular expressions 

 

Here is another link that has some info

https://community.smartbear.com/t5/SoapUI-Open-Source/Regular-expression-feature-in-Contains-Asserti...

 

regex.PNG

Thanks sanj

 

It looks like this will be exactly what I need!  

 

Apologies if this was a bit of a dumb question, I've only worked on automation in C# using selenium up until yesterday which is a bit different.

You can also try XPath Match Assertion with wildcards

https://www.soapui.org/functional-testing/validating-messages/validating-xml-messages.html#1-1-Wildc...

 

e.g. XPath expression //option[@id='1']

expected result with wildcards <option id="1" bid="1" rv="2" desc="Standard cover" monthly="*" annual="*">No</option>

 

Thanks Paul

 

This also looks like a good solution.  

 

I think looking at the way these work that using the Xpath should be simplest way forward as the missing variables are not what I am testing.  Reading up on the RegEx use, it looks like that would be particularly useful if I need to verify the data type that would be in the variable.

 

So thank you both, you have been a great help.

 

Ed

cancel
Showing results for 
Search instead for 
Did you mean: