I am using chrome development tool to find working xpath for the elements to use in webdriver.
I am facing the same issue. the descendant word doesn't work.The XML looks like in case of iframes
<iframe id="..." name="..." title="..." src="..." onLoad="...">
#document
<!DOCTYPE html>
<html dir="..">
<head>
<body...>
..
<div class="xxx">`enter code here`
</html>
So when i try to execute the xpath $x("//iframe[@id='abcdFrame']") it gives me iframe successfully.
but when i try to execute $x("//iframe[@id='abcdFrame']//html")
or
$x("//iframe[@id='abcdFrame']/descendent::html")
or
$x("//iframe[@id='abcdFrame']/descendant::node()/html")
it just returns null. Can anybody please 'help..
Thanks.
List<WebElement> frameset = driver.findElements(By.tagName("iframe"));
for (WebElement framename : frameset)
logger.info("frameid: " + framename.getAttribute("name"));
driver.switchTo().frame("frameName"); //or frameidonce you are done with frame, switch back to default content driver.switchTo().defaultContent();