UNPKG

tia

Version:

Time is All (logs driven test engine with ExtJs support)

124 lines 4.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Waits for element with specified id. * * @param id * @param timeout * @param enableLog - enable/disable logging for this action. * * @returns {Promise} - Promise with WebElement (or rejected Promise). */ function waitForElementById(id, timeout, enableLog) { // eslint-disable-next-line no-param-reassign const idObj = gT.s.idToIdForLogObj(id); return gIn.wrap({ msg: `Waiting for element by id ${idObj.logStr} ... `, enableLog, act: () => gT.sOrig.driver.wait(gT.sOrig.until.elementLocated(gT.sOrig.by.id(idObj.id)), timeout), }); } exports.waitForElementById = waitForElementById; function waitForElementEnabledAndVisibleById(id, timeout, enableLog) { // eslint-disable-next-line no-param-reassign const idObj = gT.s.idToIdForLogObj(id); return gIn.wrap({ msg: `Waiting for element enabled and visible by id ${idObj.logStr} ... `, enableLog, act: async () => { const el = await gT.sOrig.driver.wait(gT.sOrig.until.elementLocated(gT.sOrig.by.id(idObj.id)), timeout); await gT.sOrig.driver.wait(gT.sOrig.until.elementIsVisible(el), timeout); await gT.sOrig.driver.wait(gT.sOrig.until.elementIsEnabled(el), timeout); }, }); } exports.waitForElementEnabledAndVisibleById = waitForElementEnabledAndVisibleById; /** * Waits for element with specified CSS class. * * @param className * @param timeout * @param enableLog - enable/disable logging for this action. * * @returns {Promise} - Promise with WebElement (or rejected Promise). */ function waitForElementByClassName(className, timeout, enableLog) { return gIn.wrap({ msg: `Waiting for element by class name : "${className}" ... `, enableLog, act: () => gT.sOrig.driver.wait(gT.sOrig.until.elementLocated(gT.sOrig.by.className(className)), timeout), }); } exports.waitForElementByClassName = waitForElementByClassName; /** * Waits for element with specified CSS selector. * * @param selector * @param timeout * @param enableLog - enable/disable logging for this action. * * @returns {Promise} - Promise with WebElement (or rejected Promise). */ function waitForElementByCssSelector(selector, timeout, enableLog) { return gIn.wrap({ msg: `Waiting for element by css selector : "${selector}" ... `, enableLog, act: () => gT.sOrig.driver.wait(gT.sOrig.until.elementLocated(gT.sOrig.by.css(selector)), timeout), }); } exports.waitForElementByCssSelector = waitForElementByCssSelector; /** * Waits for specified page title. * * @param title * @param timeout * @param enableLog - enable/disable logging for this action. * * @returns {Promise} - Promise resolved to waiting result. */ function waitForTitle(title, timeout, enableLog) { return gIn.wrap({ msg: `Waiting for windows title: "${title}" ... `, enableLog, act: () => gT.sOrig.driver.wait(gT.sOrig.until.titleIs(title), timeout), }); } exports.waitForTitle = waitForTitle; /** * Waits for specified URL. * @param url * @param timeout * @param enableLog - enable/disable logging for this action. * * @returns {Promise} - Promise resolved to waiting result. */ function waitForUrl(url, timeout, enableLog) { return gIn.wrap({ msg: `Waiting for URL: "${url}" ... `, enableLog, act: () => gT.sOrig.driver.wait(() => gT.sOrig.driver .getCurrentUrl() .then(actUrl => url === gIn.textUtils.collapseHost(actUrl)), timeout), }); } exports.waitForUrl = waitForUrl; /** * Waits for some URL which starts with specified urlPrefix. * * @param urlPrefix * @param timeout * @param enableLog - enable/disable logging for this action. * * @returns {Promise} - Promise resolved to waiting result. */ function waitForUrlPrefix(urlPrefix, timeout, enableLog) { return gIn.wrap({ msg: `Waiting for URL prefix: "${urlPrefix}" ... `, enableLog, act: () => gT.sOrig.driver.wait(() => gT.sOrig.driver .getCurrentUrl() .then(actUrl => gIn.textUtils.collapseHost(actUrl).startsWith(urlPrefix)), timeout), }); } exports.waitForUrlPrefix = waitForUrlPrefix; //# sourceMappingURL=sel-waits.js.map