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
32 lines (26 loc) • 1.66 kB
text/typescript
import {Given, When} from "@cucumber/cucumber";
import checkCookieContent from "../helpers/framework-helpers/check/checkCookieContent";
import checkCookieExists from "../helpers/framework-helpers/check/checkCookieExists";
import setCookie from "../helpers/framework-helpers/action/setCookie";
import deleteCookies from "../helpers/framework-helpers/action/deleteCookies";
import setLocalStorage from "../helpers/framework-helpers/action/setLocalStorage";
Given(/^the cookie "([^"]*)?" contains( not)? the value "([^"]*)?"$/, async (name: string, falseCase: boolean, expectedValue: string) => {
console.log(`the cookie ${name} contains ${falseCase ? 'not' : ''} the value ${expectedValue}`);
await checkCookieContent(name, falseCase, expectedValue);
});
Given(/^the cookie "([^"]*)?" does( not)? exist$/, async (name: string, falseCase: boolean) => {
console.log(`the cookie ${name} does ${falseCase ? 'not' : ''} exists`);
await checkCookieExists(name, falseCase);
});
When(/^I set a cookie "([^"]*)?" with the content "([^"]*)?"$/, async (cookieName: string, cookieContent: string) => {
console.log(`I set a cookie ${cookieName} with the content ${cookieContent}`);
await setCookie(cookieName, cookieContent);
});
When(/^I delete the cookies "([^"]*)?"$/, async (cookieName?: string | string[]) => {
console.log(`I delete the cookies ${cookieName}`);
await deleteCookies(cookieName);
});
Given(/^I set local storage for key "([^"]*)" value flag to be "([^"]*)"$/, async (key: string, value: object) => {
console.log(`I set local storage for key ${key} value flag to ${value}`);
await setLocalStorage(key, value)
});