Recent Posts

LightBlog
Responsive Ads Here

Thursday, September 13, 2018

In Selenium what is the difference between driver.close() and driver.quit() ?

        There are two WebDriver commands driver.quit() and driver.close(), In Selenium WebDriver for the closing browser session,

    driver.close() is used if you want to close the current tab which is being used, Quitting the browser if it's the last window currently open , Close the current window .

    driver.Quit(): closing every associated window,is used when you want to close the complete browser Quits this driver object.
   
 The difference is very simple.

 1. Driver.close() only close single web browser that is open by the web driver but
    Driver.quit() closes all the web browser.

 2. Driver.close will close only the current instance and
    Driver.quit will close all instances associated with the driver object.
   
 3. Close method closes the current window in focus. The web-driver session will still be available but ,
    Quit method closes all the windows opened by WebDriver in the particular session. Any references to webdriver throws an exception. The webdriver session gets killed.
   
 4. Both have different objective quit() command closes all the browser windows and terminate a WebDriver session and
    close() command closes the browser window which is currently active.

    When there is more than one browser window opened during any Automation both will differ in their functionality .
The close() and quit() commands work in the way when the automation process opens only a single browser window.



No comments:

Post a Comment