I am instantiating the PhantomJSDriver in C# with this code:
Driver = new PhantomJSDriver();
And cleaning it up with this:
Driver.Dispose();
Driver = null;
Should the process exit or stay in memory? If it is supposed to stay in memory, visible in the Windows 7 task manager, can I kill it programmatically? Should I?
Answering straight,
Driver.Dispose();
shouldn't be used to clean up theWebDriver
instance. For a proper cleanup we must be usingDriver.Quit();
.Driver.Dispose();
: I think got deprecated.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.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 onDriver.Dispose();
,Driver.Close();
andDriver.Quit();