15

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.enter image description here

Is there a way to close it as well?

3 Answers 3

38

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().

Sign up to request clarification or add additional context in comments.

Comments

7

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();

Comments

4

Always use Driver.Quit(); to close WebDriver and browser

Driver.Quit();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.