@progress/kendo-e2e
Version:
Kendo UI end-to-end test utilities.
97 lines • 4.32 kB
JavaScript
"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.TimePicker = void 0;
const ui_component_1 = require("./ui-component");
const selenium_1 = require("../selenium");
const const_1 = require("./const");
class TimePicker extends ui_component_1.UIComponent {
constructor(browser, locator = TimePicker.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);
});
}
selectedTime() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.browser.findChild(yield this.popup(), 'li.k-list-item.k-selected');
});
}
input() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild('input.k-input-inner');
});
}
timeButton() {
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');
});
}
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.timeButton()).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.TimePicker = TimePicker;
TimePicker.SELECTOR = const_1.SELECTORS.TIMEPICKER;
//# sourceMappingURL=timepicker.js.map