PhantomJS web driver stays in memory

Answering straight, Driver.Dispose(); shouldn’t be used to clean up the WebDriver instance. For a proper cleanup we must be using Driver.Quit();.

  1. Driver.Dispose();: I think got deprecated.
  2. Driver.Close();: It is used to close the current page or the browser (if it is the only page/tab) which is having the focus.
  3. Driver.Quit();: It is used to call the /shutdown endpoint and subsequently the web driver instance is destroyed completely closing all the pages/tabs/windows.

Hence calling the Driver.Quit() method is the only way to guarantee that sessions are properly terminated.

In this discussion you can find a detailed analysis on Driver.Dispose();, Driver.Close(); and Driver.Quit();

Leave a Comment