Difference between webdriver.Dispose(), .Close() and .Quit()

Difference between webdriver.Dispose(), .Close() and .Quit()

Of the three methods, dispose() is only used in C# tests and means the exact same thing as quit(). That is, it will close all the windows currently opened by the WebDriver and safely end the session. 



Close() is different in that it only closes the currently focused window. It is best to use this when there are multiple windows being used, in order to close only one of the windows when we are finished using it.

// Switch to the newly opened tab
var windowHandle2 = driver.WindowHandles[1];

// Retrieve the title from the new tab

// Close the current focused tab

Leave a reply

Your email address will not be published. Required fields are marked*

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.