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

33 lines (30 loc) 1.39 kB
import {CustomExpect} from "../../common-helpers/custom-expect"; import {browser, $, $$, expect} from '@wdio/globals' /** * Check the text of a modal * (alertbox, confirmbox or prompt) * @param {String} falseState Whether to check if the text matches or not * @param {String} expectedText The text to check against * @param ignoreCaseCheck */ // export default async function (modalType: 'alertbox' | 'confirmbox' | 'prompt', falseState: boolean, expectedText: string) { export default async function (falseState: boolean, expectedText: string, ignoreCaseCheck = false) { try { /** * The text of the current modal * @type {String} */ let modalText: string = await browser.getAlertText(); if (ignoreCaseCheck) { modalText = modalText.toLowerCase(); expectedText = expectedText.toLowerCase(); } if (falseState) { CustomExpect.expectNotToEqual(modalText, expectedText, `Modal's expected text "${expectedText}" equals to actual text "${modalText}"`); } else { CustomExpect.expectToEqual(modalText, expectedText, `Modal's expected text "${expectedText}" is not equal to actual text "${modalText}"`); } } catch (e) { throw new Error(`An ALERT was not opened when it should have been opened`); } };