I use Selenium Webdriver (Java) and PhantomJS to test a complex JS managed website. My problem is that the PhantomJS browser maintains a session between the two tests, which leads to errors in the test setup.
If I run tests with Firefox, everything works fine because Firefox uses a clean session for each test case.
My first attempt to solve the problem was to simply clear the local storage using JS injection. Cookies are deleted using the Selenium API driver.manage().deleteAllCookies();
But running JavaScript without visiting the page is prohibited. Therefore, starting the browser with "about: empty" leads to an error.
So how to configure my phantomjs webdriver to clean up the session?
I use phantomjs and webdriver because selenium grid services were not stable enough. Therefore, I run my phantomjs example as follows:
phantomjs --webdriver=1234
java selenium testing phantomjs ghostdriver
schlingel
source share