Set a cookie, specified as a cookie JSON object, with properties as defined here.

Usage

                    .cookies.set(cookie, [callback])
                

Example

module.exports = {
  'set a cookie': function (browser) {
    browser
      .cookies.set({
        name: "test_cookie",
        value: "test_value",
        path: "/", // (Optional)
        domain: "example.org", // (Optional)
        secure: false, // (Optional)
        httpOnly: false, // (Optional)
        expiry: 1395002765 // (Optional) time in seconds since midnight, January 1, 1970 UTC
      });
  },

  'set a cookie with ES6 async/await': async function (browser) {
    await browser.cookies.set({
      name: 'test_cookie',
      value: 'test_value',
      domain: 'example.org', // (Optional)
      sameSite: 'Lax' // (Optional)
    });
  }
};

Parameters

Name Type description
cookie object

The cookie object.

callback
Optional
function

Optional callback function to be called when the command finishes.

See also