java - findelements(by.xpath()) returning only one index of my list -
the line of code have here is:
list<webelement> element = driver.findelements(by.xpath("*")); for(int i=0; i<element.size(); i++) { system.out.println(i + element.get(i).gettext()); } for reason when iteratiing through list gives me elements in 1 index of list. in other words size of element 1.
how can return elements multiple indexes of list?
if driver positioned @ root of document, * going match 1 element, 1 @ top. if want select of elements in entire document, correct xpath that:
list<webelement> element = driver.findelements(by.xpath("//*")); note string value of html element combination of text contains, plus text of descendants, way down recursively. example in this:
<p> <b>here bold <i>italic</i> text.</b> here normal text. </p> the string value of p element is:
here bold italic text. here normal text. the string value of b element is:
here bold italic text. and string value of i element is: italic.
so if going select of elements , print out content, going encounter repetition.
Comments
Post a Comment