Java 如何实现关键字";“取消选择帧”;硒2?

Java 如何实现关键字";“取消选择帧”;硒2?,java,selenium-webdriver,Java,Selenium Webdriver,我试图用SeleniumWebDriver实现关键字“unselectFrame”,但不知道如何使它对所有帧都通用 以下示例不起作用: /** * Sets the top frame as the current frame. * */ public void unselectFrame(){ try { WebElement element = getElement("//body"); driver.switchTo().frame(el

我试图用SeleniumWebDriver实现关键字“unselectFrame”,但不知道如何使它对所有帧都通用

以下示例不起作用:

/**
 *  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();