PhantomJS and Selenium Webdriver - How to clear session PhantomJS and Selenium Webdriver - How to clear session selenium selenium

PhantomJS and Selenium Webdriver - How to clear session


The fact that PhantomJS keeps sessions between tests is a known problem in GhostDriver, the Selenium Webdriver implementation in PhantomJS.

I suppose that this problem will be fixed with the PhantomJS 2 release. The bug is already fixed in GhostDriver 1.1.1, but there is no PhantomJS version which includes this GhostDriver version.


I know that Selenium Grid has a "cleanSession" option if you use GhostDriver. Also, I am pretty sure the regular WebDriver class has a option for this on a local WebDriver instance:

driver.manage().deleteAllCookies();


The version 2.0 of PhantomJS fix this issue. If you have a Linux Enviroment, you need clone the sources and compile, like this:

git clone git://github.com/ariya/phantomjs.gitcd phantomjsgit checkout 2.0./build.sh

More info here