kevman
13 years agoOccasional Contributor
Loop in assertion to check multiple nodes??
Hi,
I'm trying to create an assertion that the following response, which returns multiple nodes and need an assertion that if there is one node with specific user returned, then considered as pass. (In this case, if I have a user, 'bbb' in response, then pass.)
The number and order of users returned are random, so I couldn't use fixed XPath content check, like
assert '.../ns1:name[0]/text()'=aaa,
assert '.../ns1:name[1]/text()'=bbb
assert '.../ns1:name[2]/text()'=ccc
What I've tried is, make a loop like this, but never works. Is there any way to make this kind of assertion working?
for (i=0;i<count;i++){
assert '.../ns1:name/text()'
}
===Response===
{Users:
{User: [
{userid:aaa,
name:naa,
score:saa},
{userid:bbb,
name:nbb,
score:sbb},
{userid:ccc,
name:ncc,
score:scc},
....]}
I'm trying to create an assertion that the following response, which returns multiple nodes and need an assertion that if there is one node with specific user returned, then considered as pass. (In this case, if I have a user, 'bbb' in response, then pass.)
The number and order of users returned are random, so I couldn't use fixed XPath content check, like
assert '.../ns1:name[0]/text()'=aaa,
assert '.../ns1:name[1]/text()'=bbb
assert '.../ns1:name[2]/text()'=ccc
What I've tried is, make a loop like this, but never works. Is there any way to make this kind of assertion working?
for (i=0;i<count;i++){
assert '.../ns1:name/text()'
}
===Response===
{Users:
{User: [
{userid:aaa,
name:naa,
score:saa},
{userid:bbb,
name:nbb,
score:sbb},
{userid:ccc,
name:ncc,
score:scc},
....]}