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

26 lines (21 loc) 1.19 kB
import {ConfigHelper} from "../../common-helpers/config-helper"; import {PageConfigTypes} from "../../../custom-types/pageConfig-types"; import {CustomExpect} from "../../common-helpers/custom-expect"; import {browser, $, $$, expect} from '@wdio/globals' export default async function (elementType: string, pageConfig: PageConfigTypes, falseCase: boolean) { let text const elem = await $(pageConfig.selector); await elem.waitForDisplayed(); if (elementType.trim() !== 'button' && elementType.trim() !== 'element' && elementType.trim() !== 'field') throw new Error(`Invalid selection for "CheckIsEmpty" function. Valid selection is "button | element | field"`); if (elementType.trim() == 'button' || elementType.trim() == 'element') { text = await elem.getText(); } else if (elementType == 'field') { text = await elem.getValue(); } if (falseCase) { CustomExpect.expectNotToBe(text, '', `Text/Value of element "${pageConfig.pageId}.${pageConfig.elementKey} is EMPTY"`) } else { CustomExpect.expectToBe(text, '', `Text/Value of element "${pageConfig.pageId}.${pageConfig.elementKey} is not EMPTY"`) } };