UNPKG

chrec-core

Version:

ChRec's core business logic and model for testing HTML locator robustness

38 lines (37 loc) 1.79 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const selenium_webdriver_1 = require("selenium-webdriver"); const html_element_action_1 = require("../html-element-action"); class WaitForAddedHtmlElement extends html_element_action_1.HtmlElementAction { constructor(testResults, image, locators, boundingBox, timeout, id) { super(testResults, image, locators, boundingBox, id); this.timeout = timeout; } testElement(driver, element) { return __awaiter(this, void 0, void 0, function* () { const seleniumLocator = this.getSeleniumLocator(); if (seleniumLocator) { yield driver.wait(selenium_webdriver_1.until.elementLocated(seleniumLocator), this.timeout); } else { throw new Error(`${this.constructor.name}: No recommended Locator`); } }); } getSeleniumLocator() { const recommendedLocator = this.recommendedLocator(); if (recommendedLocator) { return recommendedLocator.toSeleniumLocator(); } return null; } } exports.WaitForAddedHtmlElement = WaitForAddedHtmlElement;