Retrieve a single cookie visible to the current page.

The cookie is returned as a cookie JSON object, with properties as defined here.

Usage

                    .cookies.get(name, [callback])
                

Example

module.exports = {
  'get a cookie': function (browser) {
    browser
      .cookies.get('test_cookie', function (result) {
        const cookie = result.value;
        this.assert.equal(cookie.name, 'test_cookie');
        this.assert.equal(cookie.value, '123456');
      });
  },

  'get a cookie with ES6 async/await': async function (browser) {
    const cookie = await browser.cookies.get('test_cookie');
    browser.assert.equal(cookie.name, 'test_cookie');
    browser.assert.equal(cookie.value, '123456');
  }
};

Parameters

Name Type description
name string

The cookie name.

callback
Optional
function

Callback function which is called with the result value.

Returns

Type description
object | null

The cookie object with properties as defined here, or null if the cookie wasn't found.

See also