How to send cookies with selenium webdriver?
Create cookies using the Java API as follows:
Cookie ck = new Cookie("name", "value");
driver.manage().addCookie(ck);
Create cookies using the Python API as follows:
driver.add_cookie({'name': 'foo', 'value': 'bar'})
For those that need to set more detailed information on Cookie
besides name
and value
you can use:
Cookie cookie = new Cookie.Builder("name", "value")
.domain(".mydomain.com")
.expiresOn(new Date(2015, 10, 28))
.isHttpOnly(true)
.isSecure(false)
.path("/mypath")
.build();
driver.manage().addCookie(cookie);