setCookies
Sets one or more cookies for the 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#
Parameters#
| Name | Type | Details |
|---|---|---|
| cookie | Array.<WebDriver.Cookie>, WebDriver.Cookie | cookie object or object array. |
| cookie.name optional | String | The name of the cookie. |
| cookie.value optional | String | The cookie value. |
| cookie.path optional | String | The cookie path. Defaults to "/" if omitted when adding a cookie. |
| cookie.domain optional | String | The domain the cookie is visible to. Defaults to the current browsing context’s active document’s URL domain if omitted when adding a cookie. |
| cookie.secure optional | Boolean | Whether the cookie is a secure cookie. Defaults to false if omitted when adding a cookie. |
| cookie.httpOnly optional | Boolean | Whether the cookie is an HTTP only cookie. Defaults to false if omitted when adding a cookie. |
| cookie.expiry optional | Number | When the cookie expires, specified in seconds since Unix Epoch. Must not be set if omitted when adding a cookie. |
| cookie.sameSite optional | String | Whether the cookie applies to a SameSite policy. Defaults to None if omitted when adding a cookie. Can be set to either "Lax" or "Strict". |
Example#
setCookies.js