這裏我長期以來遇到了一些問題。而我無法弄清楚,有人願意幫助我嗎? ...當我要完成新窗口的任務後切換新窗口。我想關閉新window.and切換舊的窗口,如何在使用Java的Selenium WebDriver中關閉子瀏覽器窗口
所以我在這裏寫的代碼:
// 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。
哇類文件!這是我不知道的技巧 – 8090PZ