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

38 lines (30 loc) 1.11 kB
/** * Check if the given URL was opened in a new window * @param {String} expectedUrl The URL to check for */ /* eslint-disable no-unused-vars */ import {CustomExpect} from "../../common-helpers/custom-expect"; import {browser, $, $$, expect} from '@wdio/globals' export default async function (expectedUrl: string, obsolete: never) { /* eslint-enable no-unused-vars */ /** * All the current window handles * @type {Object} */ const windowHandles = await browser.getWindowHandles(); CustomExpect.expectNotToHaveLength(windowHandles, 1, 'A popup was not opened'); /** * The last opened window handle * @type {Object} // */ const lastWindowHandle = windowHandles.slice(-1); // Make sure we focus on the last opened window handle browser.switchToWindow(lastWindowHandle[0]); /** * Get the URL of the current browser window * @type {String} */ const windowUrl = await browser.getUrl(); CustomExpect.expectToContain(windowUrl, expectedUrl, "The popup has a incorrect getUrl"); await browser.closeWindow(); };