Close browser completely with selenium c # webdriver

I am doing automated testing using Selenium C # Webdriver. And after completing the tests, I want to close the browser.

I initialize the driver as follows:

var driver = new ChromeDriver(); 

Then, after doing something, I close it

 driver.Close(); 

The browser closes correctly, but there is a window that launches this browser, which is still hanging. enter image description here

Is there any way to close it?

+6
source share
3 answers

driver.Close() designed to close browser pop-ups, such as open ones, by clicking on the link that calls window.open() in JavaScript. To be absolutely sure that all resources are freed and cleared by the driver, use driver.Quit() .

+19
source

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

Driver.Quit();

+3
source

This will close the browser window as well as the 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(); 
0
source

Source: https://habr.com/ru/post/958517/


All Articles