setCookies
Sets a cookie for current page. Make sure you are on the page that should receive the cookie. You can't set a cookie for an arbitrary page without being on that page.
Usage
browser.setCookies(cookie, cookie.name, cookie.value, cookie.path, cookie.domain, cookie.secure, cookie.httpOnly, cookie.expiry)
Parameters
Param | Type | Details |
---|---|---|
cookie optional | param | cookie object |
cookie.name optional | param | The name of the cookie |
cookie.value optional | param | The cookie value |
cookie.path optional | param | (Optional) The cookie path |
cookie.domain optional | param | (Optional) The domain the cookie is visible to |
cookie.secure optional | param | (Optional) Whether the cookie is a secure cookie |
cookie.httpOnly optional | param | (Optional) Whether the cookie is an httpOnly cookie |
cookie.expiry optional | param | (Optional) When the cookie expires, specified in seconds since midnight, January 1, 1970 UTC |
Example
it('should set a cookie for the page', function () {
browser.url('/')
browser.setCookie({name: 'test', value: '123'});
var cookies = browser.getCookie();
console.log(cookies); // outputs: [{ name: 'test', value: '123', domain: 'www.example.com' }]
});