Thursday, 18 February 2016

Difference between quit() and close() in selenium

Difference between quit() and close() in selenium:
======================================
driver.close() and driver.quit() are two different methods for closing the browser session in Selenium WebDriver.

driver.close – It closes the the browser window on which the focus is set.
driver.quit – It basically calls driver.dispose method which in turn closes all the browser windows and ends the WebDriver session gracefully.
Basically quit( ) WebDriver command is generally used to shut down the WebDrivers instance. Hence it closes all the Browser windows that are opened by the Selenium Automation.

You should use driver.quit whenever you want to end the program. It will close all opened browser window and terminates the WebDriver session. If you do not use driver.quit at the end of program, WebDriver session will not close properly and files would not be cleared off memory. This may result in memory leak errors.

No comments:

Post a Comment