UNPKG

tlc-core-automation-framework-v3-wdio-v9

Version:

Background: - We are following multi-layer automation framework architecture using webdriver.io + cucumber + typescript This core framework has been implemented with generic utility functions and cucumber steps, which can be easily consumed by another fra

26 lines (22 loc) 1.1 kB
/** * Check the content of a cookie against a given value * @param {String} name The name of the cookie * @param {String} falseCase Whether or not to check if the value matches * or not * @param {String} expectedValue The value to check against */ import {CustomExpect} from "../../common-helpers/custom-expect"; import {browser, $, $$, expect} from '@wdio/globals' export default async function (name: string, falseCase: boolean, expectedValue: string) { /** * The cookie retrieved from the browser object * @type {Object} */ const cookie = (await browser.getCookies(name))[0]; CustomExpect.expectToBe(cookie.name, name, `Expected cookie name is "${name}", but actual cookie name is "${cookie.name}"`) if (falseCase) { CustomExpect.expectNotToContain(cookie.value, expectedValue, `Cookie value "${cookie.value}" contains "${expectedValue}"`) } else { CustomExpect.expectToContain(cookie.value, expectedValue, `Cookie value "${cookie.value}" does not contain "${expectedValue}"`) } };