Javascript test : Selenium cookies data url
You can't set a cookie using the Chrome driver until the page is fully loaded. Use selenium to wait for the page to load and then set cookies.
You will need open page before add cookie:
$capabilities = DesiredCapabilities::chrome();$host = 'http://localhost:4444/wd/hub'; // this is the default$this->webDriver = RemoteWebDriver::create($host, $capabilities, 5000);$this->urnOpen('/');$cookie = array();$cookie['name'] = 'NAME';$cookie['value'] = 'VALUE';$this->webDriver->manage()->addCookie($cookie);