cancel
Showing results for 
Search instead for 
Did you mean: 

Assertion tricky problem

Super Contributor

Assertion tricky problem

Hello,
In one of my respones I get something like
           
             
                  101
                  3
                  1
                  TVObject
             

             
                  102
                  4
                  1
                  TVObject
             

             
                  100
                  2
                  1
                  TVObject
             

           


However, the order is not always the same. so the next time i call my method is could look like
           
             
                  101
                  3
                  1
                  TVObject
             

             
                  100
                  2
                  1
                  TVObject
             

             
                  102
                  4
                  1
                  TVObject
             

           


How can I create an assertion such that order will be ignored. As long as I have the 3 Ratings in my response, I want the assertion to pass.

Thanks

Ali
1 REPLY 1
Super Contributor

Re: Assertion tricky problem

Hi!

hmm.. there is no easy way currently, you could start by using the new wildcard feature in 1.7.5 and specifying an xpath assertion that should match


             
                  *
                  *
                  1
                  TVObject
             

             
                  *
                  *
                  1
                  TVObject
             

             
                  *
                  *
                  1
                  TVObject
             

           


then you would have to create a seperate assertion for checking for each of the RatingItemId and corresponding AverageRating value..

count(//Ratings/Rating[RatingItemId/text() = '101' and AverageRating/text() = '3'] ) +
count(//Ratings/Rating[RatingItemId/text() = '102' and AverageRating/text() = '4'] ) +
count(//Ratings/Rating[RatingItemId/text() = '100' and AverageRating/text() = '2'] )

which should match

3

(you could also bake in all subelements to Rating in this xpath and skip the above wildcard assertion)

Hope this helps!

regards,

/Ole
eviware.com
New Here?
Join us and watch the welcome video:
Top Kudoed Authors