Skip to content

Commit 4ae8025

Browse files
committed
Merge branch '2.5' into 2.6
2 parents 1d3e7fc + 8563a98 commit 4ae8025

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/Codeception/Module/WebDriver.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,14 @@ public function setCookie($cookie, $value, array $params = [])
816816
$params['domain'] = $urlParts['host'];
817817
}
818818
}
819+
// #5401 Supply defaults, otherwise chromedriver 2.46 complains.
820+
$params = array_filter($params);
821+
$params += [
822+
'path' => '/',
823+
'expiry' => time() + 86400,
824+
'secure' => false,
825+
'httpOnly' => false,
826+
];
819827
$this->webDriver->manage()->addCookie($params);
820828
$this->debugSection('Cookies', json_encode($this->webDriver->manage()->getCookies()));
821829
}
@@ -3089,7 +3097,7 @@ public function loadSessionSnapshot($name)
30893097
}
30903098

30913099
foreach ($this->sessionSnapshots[$name] as $cookie) {
3092-
$this->webDriver->manage()->addCookie($cookie);
3100+
$this->setCookie($cookie->getName(), $cookie->getValue(), $cookie->toArray());
30933101
}
30943102
$this->debugSection('Snapshot', "Restored \"$name\" session snapshot");
30953103
return true;

tests/web/WebDriverTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Codeception\Step;
44
use Codeception\Util\Stub;
5+
use Facebook\WebDriver\Cookie;
56
use Facebook\WebDriver\Remote\DesiredCapabilities;
67
use Facebook\WebDriver\Remote\RemoteWebDriver;
78
use Facebook\WebDriver\WebDriverBy;
@@ -671,17 +672,17 @@ public function testSaveSessionSnapshotsExcludeInvalidCookieDomains()
671672
$fakeWdOptions = Stub::make('\Facebook\WebDriver\WebDriverOptions', [
672673
'getCookies' => Stub::atLeastOnce(function () {
673674
return [
674-
[
675+
Cookie::createFromArray([
675676
'name' => 'PHPSESSID',
676677
'value' => '123456',
677678
'path' => '/',
678-
],
679-
[
679+
]),
680+
Cookie::createFromArray([
680681
'name' => '3rdParty',
681682
'value' => '_value_',
682683
'path' => '/',
683684
'domain' => '.3rd-party.net',
684-
]
685+
]),
685686
];
686687
}),
687688
]);

0 commit comments

Comments
 (0)