WontonJon
WontonJon

Reputation: 413

How to clear session using selenium and phantomJS

I have a series of automated tests that use selenium, specifically Geb with Spock. When I run all my tests cases one after another using a chromedriver, my tests run fine. Each test method gets a new session and therefore start with a fresh browser each time. This is not the case when using phantomJS. If a test method happens to fail when using phantomJS, all following test cases will fail because the session was not reset. I can see this happening because the screenshots taken at the end of each test method.

I have tried researching this issue and have discovered it has been a known issue for a couple of years now. Some say it was fixed in phantomjs 2.1 but I'm currently using version 2.1.1, which is the most recent version.

I have also tried using driver.manage().deleteAllCookies(); with no luck, as other threads have mentioned.

Is there a workaround anyone is aware of?

Upvotes: 1

Views: 465

Answers (1)

gWay
gWay

Reputation: 1245

have you tried webdriver's quit method?

Upvotes: 1

Related Questions