UNPKG

webdriverio

Version:

Next-gen browser and mobile automation test framework for Node.js

21 lines (16 loc) 619 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getCookies; async function getCookies(names) { const namesList = typeof names !== 'undefined' && !Array.isArray(names) ? [names] : names; if (typeof namesList === 'undefined') { return this.getAllCookies(); } if (namesList.every(obj => typeof obj !== 'string')) { throw new Error('Invalid input (see https://webdriver.io/docs/api/browser/getCookies.html for documentation.'); } const allCookies = await this.getAllCookies(); return allCookies.filter(cookie => namesList.includes(cookie.name)); }