Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close browser completely with selenium C# webdriver

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?

like image 839
Salvador Dali Avatar asked Nov 20 '13 20:11

Salvador Dali


2 Answers

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();
like image 103
Ghanshyam Singh Avatar answered Nov 11 '22 20:11

Ghanshyam Singh


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

like image 34
JimEvans Avatar answered Nov 11 '22 18:11

JimEvans