Forum Discussion

Prudential_UK_A's avatar
Prudential_UK_A
Frequent Contributor
16 years ago

Xpath Match for multiple nodes

Hi,
I have a situation where I get a set of results elements back, each of which should contain the same birthDate(for example). When I use an Xpath Match assertion and use either //birthDate or //rootElement/*/birthDate, it matches the required birthdate if any of the elements match, not all.
how do I get it check ALL elements match the Expected result?
Regards
Peter
  • Hello,

    I think the easiers way to make sure that all the values are equal to something is to instead make sure that none of the values are different from it:

    Ensure that no birthDate exists which has a value different from 1900-01-01 (So this means that they all must be equal to it) :

    not(exists(//ns1:birthDate[text()!='1900-01-01']))

    true


    Another way of doing this is counting the number of birthDates that are the correct value, and make sure it is equal to the total number of birthDates.

    Regards,
    Dain
    eviware.com
  • Hi!

    you could do something like

    not(exists(//ns1:birthDate[text()!='${DataSource#expectedBirthDate}']))

    where expectedBirthDate is a property in the DataSource step.

    Does that help?

    regards,

    /Ole
    eviware.com