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

24 lines (19 loc) 1.1 kB
import {error} from "winston"; import waitForElementState from "./waitForElementState"; import {PageConfigTypes} from "../../../custom-types/pageConfig-types"; import logger from "../../reporting-helpers/logger"; import {browser, $, $$, expect} from '@wdio/globals' /** * @param method - only accepts 'add' or 'set' * @param add -> to append the text to the existing text * @param set -> cleans the existing text and writes new text */ export default async function (method: string, value: string, pageConfig: PageConfigTypes) { if (method.trim() !== 'add' && method.trim() !== 'set') throw new Error(`Invalid selection for "SetInputField" function. Valid selection is "add" OR "set"`); const command = (method.toLowerCase().trim() === 'add') ? 'addValue' : 'setValue'; if (!value) throw error(`Value for the input box "${pageConfig.elementKey}" is missing`) await waitForElementState(pageConfig, false, "Displayed", 0, 0); await $(pageConfig.selector)[command](value); logger.info(`"Action "${method}" is performed on element "${pageConfig.elementKey}"`) };