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
16 lines (12 loc) • 760 B
text/typescript
import {PageConfigTypes} from "../../../custom-types/pageConfig-types";
import {browser, $, $$, expect} from '@wdio/globals'
/**
* @param selectionType - only accepts 'value' or 'text'
* @param value -> to select the option by value of the element
* @param dismiss -> to select the option by text
*/
export default async function (selectionType: string, data: string, pageConfig: PageConfigTypes) {
if (selectionType.trim() !== 'value' && selectionType.trim() !== 'text')
throw new Error(`Invalid selection for "selectOption" function. Valid selection is "value" OR "text"`);
(selectionType === 'text') ? await $(pageConfig.selector).selectByVisibleText(data) : await $(pageConfig.selector).selectByAttribute(selectionType, data);
};