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 (21 loc) • 1.49 kB
text/typescript
import {Then, When} from "@cucumber/cucumber";
import handleModal from "../helpers/framework-helpers/action/handleModal";
import setPromptText from "../helpers/framework-helpers/action/setPromptText";
import checkModal from "../helpers/framework-helpers/check/checkModal";
import checkModalText from "../helpers/framework-helpers/check/checkModalText";
When(/^I (accept|dismiss) the (alertbox|confirmbox|prompt)$/, async (action: 'accept' | 'dismiss', modalType: 'alertbox' | 'confirmbox' | 'prompt') => {
console.log(`I ${action} the ${modalType}`);
await handleModal(action);
});
When(/^I enter "([^"]*)?" into the alert prompt$/, async (promptText: string) => {
console.log(`I enter ${promptText} into the alert prompt`);
await setPromptText(promptText);
});
Then(/^I expect that a (alertbox|confirmbox|prompt) is( not)? opened$/, async (modalType: 'alertbox' | 'confirmbox' | 'prompt', falseCase: boolean) => {
console.log(`I expect that a ${modalType} is ${falseCase ? 'not' : ''} opened `);
await checkModal(falseCase);
});
Then(/^I expect that a (alertbox|confirmbox|prompt)( not)? contains the text "([^"]*)?"( ignoring-case)?$/, async (modalType: 'alertbox' | 'confirmbox' | 'prompt', falseCase: boolean, expectedText: string, ignoreCase: boolean) => {
console.log(`I expect that a ${modalType} ${falseCase ? 'not' : ''} contains the text ${ignoreCase ? 'ignoring case' : ''}`);
await checkModalText(falseCase, expectedText, ignoreCase);
});