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

40 lines (33 loc) 1.68 kB
import {Given, When} from "@cucumber/cucumber"; import setWindowSize from "../helpers/framework-helpers/action/setWindowSize"; import closeAllButFirstTab from "../helpers/framework-helpers/action/closeAllButFirstTab"; import closeLastOpenedWindow from "../helpers/framework-helpers/action/closeLastOpenedWindow"; import focusLastOpenedWindow from "../helpers/framework-helpers/action/focusLastOpenedWindow"; // import {sleep} from "@wdio/utils"; import refreshPage from "../helpers/framework-helpers/action/refreshPage"; import {browser} from "@wdio/globals"; Given(/^I have a screen that is ([\d]+) by ([\d]+) pixels$/, async (screenWidth: string, screenHeight: string) => { console.log(`I have a screen that is : ${screenWidth} and Height : ${screenHeight}`); await setWindowSize(screenWidth, screenHeight); }); Given(/^I have closed all except the first (?:window|tab)$/, async () => { console.log(`I have closed all except first (window|tab)`); await closeAllButFirstTab(); }); When(/^I close the last opened (?:window|tab)$/, async () => { console.log(`I close the last opened (window|tab)`); await closeLastOpenedWindow(); }); When(/^I focus on the last opened (?:window|tab)$/, async () => { console.log(`I focus on the last opened (window|tab)`); await focusLastOpenedWindow(); }); When(/^I wait "([^"]*)" seconds?$/, async (waitSeconds: string) => { console.log(`I wait ${waitSeconds} seconds`); // await sleep(parseInt(waitSeconds, 10) * 1000); await browser.pause(parseInt(waitSeconds, 10) * 1000); }); When(/^I refresh the page$/, async () => { console.log(`I refresh the page`); await refreshPage(); });