2014-05-21 128 views
1

下面的屏幕是iframe的HTML代码。无法点击iframe中的元素

前两个红色标记的对象可以由Webdriver标识,但最后标记的(这是一个按钮)不能被Webdriver点击。我试过用不同的方式点击它(比如点击id,名称等)。但我仍然无法点击提交按钮。

请帮我点击框内的提交按钮。 enter image description here

+1

有代码,您是如何执行点击?如何发布错误? – SiKing

回答

3

您需要使用switchTo().frame()才能访问frameiframe中的内容。

driver.switchTo().frame("name"); // where name is the name of the iframe i.e. name="frameName", you would use framename 
driver.switchTo().frame(0);  // You can switch to the frame by index 
driver.switchTo().frame(element); // You can switch to the frame by a WebElement reference 

在您的特定情况下,你可以使用:

driver.switchTo().frame("InstantSgn"); 

切换出帧的你的iframe范围内完成后:

driver.switchTo().defaultContent();