WebElement body = browser.findElement(By.xpath("//body"));
body.findElement(By.xpath("")); // I want to get all child elements
// inside body, but nothing deeper.
Example document.
<html>
<body>
<div>
</div>
<span>
<table>
</table>
</span>
</body>
</html>
Expected result is div
and span
. I have no controll over the documents and they vary greatly.
("*")
gives all the child elements of the context node. So use:
body.findElement(By.xpath("*"));