如何在Selenium2中实现关键字"Unselect Frame"?



我正在尝试使用selenium-webdriver实现关键字"取消选择框架",但不知道如何使其适用于所有框架。

以下示例不起作用:

/**
 *  Sets the top frame as the current frame.
 * 
 */
public void unselectFrame(){
    try {
        WebElement element = getElement("//body");
        driver.switchTo().frame(element);
    } catch (Exception e) {
         //exception
    }
}

如有任何帮助,将不胜感激。

你的意思是跳出框架吗?在这种情况下,这应该有效:

driver.switchTo().defaultContent();

最新更新