UNPKG

@qavajs/steps-playwright

Version:

qavajs steps to interact with playwright

31 lines 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@qavajs/core"); /** * Set cookie * @param {string} cookie - cookie name * @param {string} value - value to set * @example I set 'userID' cookie 'user1' * @example I set 'userID' cookie '$userIdCookie' */ (0, core_1.When)('I set {value} cookie as {value}', async function (cookie, value) { const cookieValue = await value.value(); const cookieObject = typeof cookieValue === 'object' ? cookieValue : { value: cookieValue }; if (!cookieObject.url && !cookieObject.domain && !cookieObject.path) { cookieObject.url = this.playwright.page.url(); } await this.playwright.context.addCookies([{ name: await cookie.value(), ...cookieObject }]); }); /** * Save cookie value to memory * @param {string} cookie - cookie name * @param {string} key - memory key * @example I save value of 'auth' cookie as 'authCookie' */ (0, core_1.When)('I save value of {value} cookie as {value}', async function (cookie, key) { const cookieName = await cookie.value(); const cookies = await this.playwright.context.cookies(); const cookieValue = cookies.find((c) => c.name === cookieName); key.set(cookieValue); }); //# sourceMappingURL=cookies.js.map