Como fechar a janela do navegador filho no Selenium WebDriver usando Java
Aqui estou com algum problema desde há muito tempo. E eu não consegui descobrir isso, alguém pode querer me ajudar? ... quando eu vou mudar de nova janela, depois de completar a tarefa de novas janelas. Quero fechar essa nova janela e mudar a janela antiga
então aqui eu escrevi 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
Acima eu escrevi códigodriver.quit()
oudriver.close()
. Mas estou recebendo erro. Alguém pode me ajudar...?
org.openqa.selenium.remote.SessionNotFoundException: O FirefoxDriver não pode ser usado depois que quit () for chamado.