Reputation: 121
I have this code :
ReadOnlyCollection<IWebElement> questions = driver.FindElements(By.XPath("//fieldset[@data-seleniumrp='Question']"));
foreach (IWebElement question in questions)
{
ReadOnlyCollection<IWebElement> repdispo = question.FindElements(By.XPath("//input[@data-selenium-positionquestion]"));
}
my collection "questions" have 11 elements, that right ! for each "question" normaly i have 4 elements ... but with this code , i have 44 results ( all elements in page ) in "repdispo" ...
how get only childrend element and not all element ?
Upvotes: 1
Views: 1618
Reputation: 89285
I really suspect the problem is in the XPath inside the foreach
loop. You need to add .
at the beginning of //
axis to make it relative to current question
element :
".//input[@data-selenium-positionquestion]"
Upvotes: 2