Cómo cerrar la ventana del navegador secundario en Selenium WebDriver usando Java
Aquí estoy teniendo algún problema desde hace mucho tiempo. Y no pude darme cuenta de eso, ¿alguien podría ayudarme? ... cuando voy a cambiar de ventana nueva, después de completar la tarea de ventanas nuevas. Quiero cerrar esa nueva ventana. Y cambiar la ventana antigua.
Así que aquí escribí como código:
// 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
Arriba escribí el códigodriver.quit()
odriver.close()
. Pero me estoy equivocando. Alguien puede ayudarme...?
org.openqa.selenium.remote.SessionNotFoundException: el FirefoxDriver no se puede usar después de llamar a quit ().