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

70 lines (56 loc) 2.97 kB
import {When} from "@cucumber/cucumber"; import openUrl from "../helpers/framework-helpers/action/openUrl"; import {ParseData} from "../helpers/common-helpers/parse-data"; import {ConfigHelper} from "../helpers/common-helpers/config-helper"; import {browserHelper} from "../helpers/common-helpers/browser-helper"; import moveToFrame from "../helpers/framework-helpers/action/moveToFrame"; import moveToParentFrame from "../helpers/framework-helpers/action/moveToParentFrame"; import {PageConfigTypes} from "../custom-types/pageConfig-types"; let pageConfig: PageConfigTypes; When(/^I navigate to "(.*)" from common.env file$/, async (environmentUrl: string) => { // console.log(`I navigate to ${environmentUrl} from common.env file`); console.log(`I navigate to ${environmentUrl} from common.env file`); await openUrl(`${ParseData.getEnvData(environmentUrl.toUpperCase())}`); }); When(/^I navigate to baseURL from WDIO Config file$/, async () => { console.log(`I navigate to baseURL from WDIO Config file`); await openUrl('/'); }); When(/^I navigate to url "(.*)"$/, async (website: string) => { console.log(`I navigate to url ${website}`); await openUrl(`${website}`); }); //make sure you have env variable with the name of the main website When(/^I navigate to "(.*)" page directly from "(.*)" website$/, async (pageId: string, hostName: string) => { console.log(`I navigate to ${pageId} page directly from ${hostName} website`); await browserHelper.navigateToPageFromHost(pageId, hostName) }); //make sure you have defined the baseURL as env variable When(/^I navigate to the "(.*)" page$/, async (pageId: string) => { console.log(`I navigate to ${pageId} page`); await browserHelper.navigateToPageFromHost(pageId) }); //used to access a link from externally When(/^I navigate to deeplink "(.*)"$/, async (deepLink: string) => { console.log(`Navigation using deeplink : ${deepLink}`); await browserHelper.navigateUsingDeepLink(deepLink); }); When(/^I am( not)? on the "(.*)" page$/, async (falseCase: boolean, pageId: string) => { console.log(`Checking if user is ${falseCase ? 'not' : ''} on the "${pageId}" page now`); await browserHelper.currentPage(pageId, falseCase); // await browserHelper.currentPage(pageId); }); When(/^I am exactly( not)? on the "(.*)" page$/, async (falseCase: boolean, pageId: string) => { console.log(`I am exactly ${falseCase ? 'not' : ''} on the ${pageId} page`); await browserHelper.exactPage(pageId, falseCase) // await browserHelper.exactPage(pageId) }); When(/^I switch into "(.*)" iFrame$/, async (frameLocator: string) => { console.log(`I switch into ${frameLocator} iFrame`); pageConfig = ConfigHelper.getPageConfig(frameLocator); await moveToFrame(pageConfig); }); When(/^I return back from iFrame to the parent$/, async () => { console.log(`I return back from iFrame to the parent`); await moveToParentFrame(); });