You need to switch to the frame before finding the element within the context OF the frame.
internetExplorerDriver.switchTo().frame("f1");
internetExplorerDriver.findElement(By.xpath("//frame[@name='f2']"))
質問
I'm testing a web page with Java and Selenium API. The web page is done like this :
<html>
<head>
</head>
<frameset name="f1">
<html>
<frameset name="f2">
</frameset>
</html>
</frameset>
</html>
Using internetExplorerDriver.findElement(By.xpath("//frame[@name='f1']"))
the good element is retrieved. But when I do internetExplorerDriver.findElement(By.xpath("//frame[@name='f2']"))
it tells that element can't be found. When I look to children of f1 with f1.findElements(By.xpath("*")).size();
I obtain a 0, no children are found.
How this could be solved ? Does the web page has to be changed and remove the sub html markup ? Thanks in advance.
Regards, Jean Ducrot
解決
You need to switch to the frame before finding the element within the context OF the frame.
internetExplorerDriver.switchTo().frame("f1");
internetExplorerDriver.findElement(By.xpath("//frame[@name='f2']"))