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
54 lines (47 loc) • 1.88 kB
text/typescript
import type {RectReturn} from '@wdio/protocols';
import {PageConfigTypes} from "../../../custom-types/pageConfig-types";
import {CustomExpect} from "../../common-helpers/custom-expect";
import {browser, $, $$, expect} from '@wdio/globals'
/**
* Check the dimensions of the given element
* @param {pageObject} selector Element selector
* @param {String} falseCase Whether to check if the dimensions match or
* not
* @param {String} expectedSize Expected size
* @param {String} dimension Dimension to check (broad or tall)
*/
export default async function (pageConfig: PageConfigTypes, falseCase: boolean, expectedSize: string, dimension: 'broad' | 'tall'
) {
/**
* The size of the given element
* @type {Object}
*/
// @ts-expect-error
const elementSize = await $(pageConfig.selector).getSize() as RectReturn;
/**
* Parsed size to check for
* @type {Int}
*/
const intExpectedSize = parseInt(expectedSize, 10);
/**
* The size property to check against
* @type {Int}
*/
let originalSize = elementSize.height;
/**
* The label of the checked property
* @type {String}
*/
let label = 'height';
if (dimension === 'broad') {
originalSize = elementSize.width;
label = 'width';
}
if (falseCase) {
// expect(originalSize).not.toBe(intExpectedSize);
CustomExpect.expectNotToBe(originalSize, intExpectedSize, `Actual dimension and expected dimension is matching for element "${pageConfig.pageId}.${pageConfig.elementKey}"`)
} else {
// expect(originalSize).toBe(intExpectedSize);
CustomExpect.expectToBe(originalSize, intExpectedSize, `Actual dimension and expected dimension is not matching for element "${pageConfig.pageId}.${pageConfig.elementKey}"`)
}
};