UNPKG

@progress/kendo-e2e

Version:

Kendo UI end-to-end test utilities.

146 lines 6.36 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 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) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TimeDurationPicker = void 0; const ui_component_1 = require("./ui-component"); const selenium_1 = require("../selenium"); class TimeDurationPicker extends ui_component_1.UIComponent { constructor(browser, locator = TimeDurationPicker.SELECTOR, parentElement) { super(browser, locator, parentElement); this.parentElement = parentElement; } popupSelector() { return __awaiter(this, void 0, void 0, function* () { let id = yield (yield this.root()).getAttribute("aria-controls"); if (id === null) { const childAriaControls = yield this.findChild("[aria-controls]"); id = yield childAriaControls.getAttribute("aria-controls"); } return selenium_1.By.xpath(`//div[contains(@class, "k-popup") and .//*[contains(@id, "${id}")]]`); }); } popup() { return __awaiter(this, void 0, void 0, function* () { const popup = yield this.popupSelector(); return yield this.browser.find(popup); }); } timeItem(column, row) { return __awaiter(this, void 0, void 0, function* () { const col = (yield this.browser.findChildren(yield this.popup(), '.k-time-list-wrapper'))[column]; return (yield this.browser.findChildren(col, 'ul.k-reset li.k-item'))[row]; }); } timeItemValue(column, row) { return __awaiter(this, void 0, void 0, function* () { return yield (yield this.timeItem(column, row)).getText(); }); } pickTime(column, row) { return __awaiter(this, void 0, void 0, function* () { const item = yield this.timeItem(column, row); yield item.click(); yield this.browser.sleep(100); }); } getShortcutButton(index) { return __awaiter(this, void 0, void 0, function* () { return (yield this.browser.findChildren(yield this.popup(), '.k-actions-start .k-button'))[index]; }); } set() { return __awaiter(this, void 0, void 0, function* () { const button = yield this.browser.findChild(yield this.popup(), '.k-time-accept'); yield button.click(); yield this.waitToCollapse(); }); } cancel() { return __awaiter(this, void 0, void 0, function* () { const button = yield this.browser.findChild(yield this.popup(), '.k-time-cancel'); yield button.click(); yield this.waitToCollapse(); }); } input() { return __awaiter(this, void 0, void 0, function* () { return yield this.findChild('.k-input-inner:not([style~="none;"])'); }); } getSelectionStart() { return __awaiter(this, void 0, void 0, function* () { const input = yield this.input(); return parseInt(yield this.browser.getProperty(input, "selectionStart")); }); } getSelectionEnd() { return __awaiter(this, void 0, void 0, function* () { const input = yield this.input(); return parseInt(yield this.browser.getProperty(input, "selectionEnd")); }); } time() { return __awaiter(this, void 0, void 0, function* () { return yield this.findChild('.k-button'); }); } inputValue() { return __awaiter(this, void 0, void 0, function* () { return yield (yield this.input()).getAttribute('value'); }); } isValid() { return __awaiter(this, void 0, void 0, function* () { const validationSpan = yield this.findChild('.k-input-validation-icon'); return (yield validationSpan.getAttribute('class')).includes('k-hidden'); }); } type(text_1) { return __awaiter(this, arguments, void 0, function* (text, { typeFromBeginning = true } = {}) { const input = yield this.input(); if (typeFromBeginning) { const rect = yield input.getRect(); yield this.browser.driver.actions({ async: false, bridge: true }) .move({ origin: input, x: 5 - rect.width / 2, y: 5 - rect.height / 2 }) .click() .perform(); } else { yield input.click(); } yield this.browser.wait(selenium_1.EC.hasFocus(input), { timeout: 3000, message: 'Failed to focus input.' }); yield this.browser.sendKey(text); }); } expand() { return __awaiter(this, void 0, void 0, function* () { yield (yield this.time()).click(); yield this.waitToExpand(); }); } waitToExpand() { return __awaiter(this, void 0, void 0, function* () { const popup = yield this.popupSelector(); yield this.browser.wait(selenium_1.EC.isVisible(popup), { timeout: 5000, message: "Failed to expand popup." }); yield this.browser.waitForAnimation(popup, { timeout: 3000, pollTimeout: 50 }); }); } waitToCollapse() { return __awaiter(this, void 0, void 0, function* () { const popup = yield this.popupSelector(); yield this.browser.wait(selenium_1.EC.notVisible(popup), { timeout: 5000, message: "Failed to collapse popup." }); yield this.browser.sleep(100); // Wait for animation timeout }); } } exports.TimeDurationPicker = TimeDurationPicker; TimeDurationPicker.SELECTOR = '.k-timedurationpicker'; //# sourceMappingURL=timedurationpicker.js.map