Reputation: 222969
I am doing some automated testing with Selenium C# Webdriver. And after finishing the tests I want to close the browser.
I initialize the driver with the following:
var driver = new ChromeDriver();
And then after doing something I am closing it with
driver.Close();
The browser is correcly closes, but there is a window which starts this browser which is still hanging.
Is there a way to close it as well?
Upvotes: 15
Views: 36713
Reputation: 1381
This will close browser window as well as Chrome Driver prompt
ChromeOptions options = new ChromeOptions();
options.addArguments("no-sandbox");
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com/");
driver.close();
driver.quit();
Upvotes: 7
Reputation: 204
Always use Driver.Quit(); to close WebDriver and browser
Driver.Quit();
Upvotes: 4
Reputation: 27496
driver.Close()
is intended to close popup browser windows, such as those opened by clicking on a link that triggers a window.open()
call in JavaScript. To be absolutely certain all resources are released and cleaned up by a driver, use driver.Quit()
.
Upvotes: 38