0

I have a webService that returns certain values.

<BasicPersons>
           <id>4</id>
           <firstName>Patricia</firstName>
           <middleName>A</middleName>
           <lastName>Cluss</lastName>
        </BasicPersons>
        <BasicPersons>
           <id>5</id>
           <firstName>Benjamin</firstName>
           <middleName>L</middleName>
           <lastName>Handen</lastName>
        </BasicPersons>
        <BasicPersons>
           <id>6</id>
           <firstName>Ellen</firstName>
           <lastName>Frank</lastName>
        </BasicPersons>
        <BasicPersons>

I know what some of those values will be but i don't know the order of the nodes. I want to assert that one of the "basicPersons" node contain firstname=Benjamin. How can i do it?

Adi Mor
  • 2,145
  • 5
  • 25
  • 44

2 Answers2

0

You do not need to know the order of nodes, just */BasicPersons[firstName='Benjamin'] -- it searches every child of basicPerson where text is exactly Benjamin.

upd: some helpful link Using XPATH to search text containing

upd2: thank you guys for editing, I've missed firstname tag

Community
  • 1
  • 1
olyv
  • 3,699
  • 5
  • 37
  • 67
  • i know that, but what assert should i use in soapui – Adi Mor Jan 04 '14 at 17:35
  • Add assertion to the request -> Property Content -> XPath match (http://www.soapui.org/Functional-Testing/xpath-and-xquery-assertions.html) or if need some additional actions use Script Assertion (http://www.soapui.org/Functional-Testing/script-assertions.html). – olyv Jan 04 '14 at 19:22
0

You could use an XPath assertion like:

exists(//*:BasicPersons[contains(*:firstName, 'Benjamin')])
SiKing
  • 10,003
  • 10
  • 39
  • 90