cancel
Showing results for 
Search instead for 
Did you mean: 

XPATH assertion fails with SoapUI NG

SOLVED
yakari
New Contributor

XPATH assertion fails with SoapUI NG

Hi together,

 

I want to migrate our projects from SoapUI Pro 5.1.2 to SoapUI NG. Within SoapUI NG the following XPATH assertion fails, which passes within 5.1.2.

 

As result of a REST request I check the returned codes, that have always different order.

 

<codeCategories>
   <codeCategory>A</codeCategory>
   <codeCategory>B</codeCategory>
   <codeCategory>C</codeCategory>
</codeCategories>

 

XPATH Assertion example

Expression

//codeCategories[1]//codeCategory

Expected result

B

 

Returned error

XPathContains comparison failed for path [//codeCategories[1]//codeCategory], expecting [B], actual was [[A,B,C]]

Why does the assertion under SoapUI NG fail with the returned error?

 

Thanks to all

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
PJat
Contributor

Re: XPATH assertion fails with SoapUI NG

It's because of a bug fix in Ready! API to be able to match mutliple values returned by an XPath. As you can see your XPath expression returns multiple values but expected value is only one. Please change the XPath expression to : //codeCategories[1]//codeCategory[2] or change the expected value to [A,B,C].

View solution in original post

PJat
Contributor

Re: XPATH assertion fails with SoapUI NG

Yes, you can use wildcards - so expected value in your case can be '*B*'.

 

@nmrao We should definitely include it in SoapUI OS - I will bring this up with @MattiH (SoapUI OS Product Owner).

View solution in original post

6 REPLIES 6
PJat
Contributor

Re: XPATH assertion fails with SoapUI NG

It's because of a bug fix in Ready! API to be able to match mutliple values returned by an XPath. As you can see your XPath expression returns multiple values but expected value is only one. Please change the XPath expression to : //codeCategories[1]//codeCategory[2] or change the expected value to [A,B,C].

View solution in original post

nmrao
Community Hero

Re: XPATH assertion fails with SoapUI NG

Very nice to know @PJat.

Just curious to know if this will be part of SoapUI OS as well? Possibly in any upcoming release?


Regards,
Rao.
yakari
New Contributor

Re: XPATH assertion fails with SoapUI NG

Hi,

 

thanks for the answer. But that does not really solve the problem. The results differ each time and could be [C,A,B] and the next time [B,C,A]. So how should the assertion then be? Is there a possibility to sort the results before the assertion or use wildcards?

 

Thanks

yakari

PJat
Contributor

Re: XPATH assertion fails with SoapUI NG

Yes, you can use wildcards - so expected value in your case can be '*B*'.

 

@nmrao We should definitely include it in SoapUI OS - I will bring this up with @MattiH (SoapUI OS Product Owner).

View solution in original post

yakari
New Contributor

Re: XPATH assertion fails with SoapUI NG

@PJat Thanks this works.

gcampan
Occasional Contributor

Re: XPATH assertion fails with SoapUI NG

+1 for this, would be glad when a solution is found

 

@smartBear team: this aslo happens with the tests being run with Testrunner under Jenkins, FYI

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors