title: PhantomJS and Selenium Webdriver - How to clear session
body: <p>I'm using Selenium Webdriver (Java) and PhantomJS to test a complex JS driven website. My problem is, that the PhantomJS browser keeps the session between two tests which leads to errors in the test setup.</p>
  
  <p>If I run the tests with Firefox everything works fine because Firefox uses a clean session for every test case. </p>
  
  <p>My first attempt to solve the problem was to just clear the local storage by JS injection. Cookies are deleted by the Selenium exposed <code>API driver.manage().deleteAllCookies();</code> </p>
  
  <p>But executing JavaScript without visiting a page is not allowed. So starting the browser at "about:blank" leads to an error.</p>
  
  <p>So, how do I configure my phantomjs webdriver to clear the session?</p>
  
  <p>I'm using phantomjs and webdriver because the selenium-grid services turned out to be not stable enough. So I start my phantomjs instance like that:</p>
  
  <pre><code>phantomjs --webdriver=1234
  </code></pre>