1

I'm implementing codeception with help of buildbot and phantomjs.

This all works just fine, buildbot fires up codeception when a commit is made, and I have phantomjs running in the background accepting connections from codeception with de WebDriver.

The problem however is that phantomjs is saving cookies, so my first test, which is logging in, always fails because the user is already logged in.

How can I make phantomjs reset it's cookies after each test run?

I tried restarting phantomjs and this fixes the issue, but I don't know how to do this with buildbot. Plus it seems like overkill for this specific problem..

Richard Deurwaarder
  • 2,023
  • 1
  • 26
  • 40

1 Answers1

9

There are 2 methods to clear cookies:

  1. page.clearCookies() - remove cookies only for the current WebPage

  2. phantom.clearCookies() - remove all cookies globally for all WebPages

You can read more here.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
Vitaly Slobodin
  • 1,359
  • 12
  • 10
  • but how do I call these from codeception? I use the WebDriver, and tried to call both, but neither are defined – Richard Deurwaarder Oct 22 '13 at 13:17
  • 1
    AH. I missed that you're using Codeception. In that case, you can use: `$I->executeInSelenium(function(\WebDriver $webdriver) { $webdriver->manage()->deleteAllCookies(); }); ` – Vitaly Slobodin Oct 22 '13 at 14:11