Codeception: "Unable to set Cookie" with phantomjs on loadSessionSnapshot
Hello,
I’m using Codeception (2.1.7) with phantomjs (2.1.1) and I’m using loadSessionSnapshot
to avoid login on every test with the following code in my AcceptanceTester
:
public function login()
{
if ($this->loadSessionSnapshot('login'))
return;
$this->amOnPage('/en');
$this->fillField('login', '***');
$this->fillField('password', '***');
$this->click('#btn-login');
$this->saveSessionSnapshot('login');
}
but when I have multiple tests with $I->login();
, on second call, tests are crashing with :
[Facebook\WebDriver\Exception\UnableToSetCookieException] {"errorMessage":"Unable to set Cookie"...
I tried to move the amOnPage
call of my login
method to be sure that the browser is started but problem is the same…
Thanks for your help !
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 16
- Comments: 28 (5 by maintainers)
Commits related to this issue
- use selenium instead of phantomJS due an unresolved error Codeception/Codeception#2900 — committed to Coinsence/coinsence-docker by craxrev 4 years ago
I had this issue and was not able to resolve it. Using PhantomJS 2.1. It is apparently a known issue that has been fixed, but the fix has not been officially released:
https://github.com/ariya/phantomjs/issues/14047
–
My solution was to switch away from PhantomJS to Selenium Server, using a docker file. I already had docker set up and running so my set up was very fast (15 minutes):
Per documentation on selenium headless testing with docker: http://codeception.com/docs/modules/WebDriver#Headless-Selenium-in-Docker
I created a very simple docker-compose file:
Modified my acceptance test yml:
Running tests based on this is very simple now:
Everything works with sessions and cookies as expected. Skipped the mess of configuring selenium, web drivers and installing various browsers:
Test Output:
Was trying PhantomJS 2.1.1 and Codeception 2.2.5.
Ended up just using PhantomJS 1.9.8 and my code that calls setCookie seems to work fine.
I built phantomjs from master
Still having the same issue (Codeception 2.2.1 (Phar))
According to this, the problem may be fixed in the development version of phantomjs 2.2.0. (Though I have not verified.)
I thought that I was experiencing the same thing as @tomvo:
However, I realized this was just an illusion. The screenshot shows the logged-in version of the web app, yes, but only because the first test logged in and the browser still has that old page loaded. It is not really logging in.
+1 with codeception 2.1.8 and phantomJs 2.1.1
PhantomJS 1.9.8 works for me too
Getting this error for Yii2 framework, Codeception v2.2.3, PhantomJS v2.1.1, PHP 5.4.16
I’m also receiving this error but looking at the screenshots Selenium generates, the session has been loaded after all. I also use it in a login flow and it shows the logged-in version of the application in the screenshot. So not sure why Webdriver throws this error.
edit: not using codecoverage, just a simple
saveSessionSnapshot()
in one test and anotherloadSessionSnapshot()
in the next tests.