setCookie

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

1
browser.setCookie(cookie);

Parameters

Param Type Details
cookie Object cookie object

Example

setCookie.js
1
2
3
4
5
6
7
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' }]
});

Uses