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

31 lines (26 loc) 1.51 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' /** * Check the offset of the given element * @param {String} selector Element selector * @param {String} falseCase Whether to check if the offset matches * or not * @param {String} expectedPosition The position to check against * @param {String} axis The axis to check on (x or y) */ export default async function (pageConfig: PageConfigTypes, falseCase: boolean, expectedPosition: string, axis: 'x' | 'y') { /** * Get the location of the element on the given axis * @type {[type]} */ // @ts-ignore if (axis.toLowerCase().trim() !== ('x' || 'y')) throw new Error(`Invalid selection for "CheckOffSet" function. Valid selection is "x" OR "y"`); const location = await $(pageConfig.selector).getLocation(axis); if (falseCase) CustomExpect.expectNotToEqual(location, parseFloat(expectedPosition), `Expected location of element "${pageConfig.pageId}.${pageConfig.elementKey}" is matching with actual location`) else CustomExpect.expectToEqual(location, parseFloat(expectedPosition), `Expected location of element "${pageConfig.pageId}.${pageConfig.elementKey}" is not matching with actual location`) };