在我切换到新窗口并完成任务后,我想关闭那个新窗口并切换到旧窗口,
所以在这里我写了像代码:
// Perform the click operation that opens new window
String winHandleBefore = driver.getWindowHandle();
// Switch to new window opened
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle);
}
// Perform the actions on new window
driver.findElement(By.id("edit-name")).clear();
WebElement userName = driver.findElement(By.id("edit-name"));
userName.clear();
try
{
driver.quit();
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("not close");
}
driver.switchTo().window(winHandleBefore);// Again I want to start code this old window
上面我写了代码driver.quit()
或driver.close()
. 但我收到错误。有谁能够帮我...?
org.openqa.selenium.remote.SessionNotFoundException:调用 quit() 后无法使用 FirefoxDriver。