@progress/kendo-e2e
Version:
Kendo UI end-to-end test utilities.
47 lines • 2.38 kB
JavaScript
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.ComboBox = void 0;
const selenium_1 = require("../selenium");
const const_1 = require("./const");
const dropdown_1 = require("./dropdown");
class ComboBox extends dropdown_1.DropDown {
constructor(browser, locator = const_1.SELECTORS.COMBOBOX, rootElement) {
super(browser, locator, rootElement);
}
type(text_1) {
return __awaiter(this, arguments, void 0, function* (text, { typeFromBeginning = false } = {}) {
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);
});
}
isFocused() {
return __awaiter(this, void 0, void 0, function* () {
const focused = yield this.browser.driver.switchTo().activeElement();
const isKeyboardFocused = (yield (yield this.input()).getId()) === (yield focused.getId());
const isVisuallyFocused = (yield (yield this.root()).getAttribute('class')).includes(const_1.STATES.FOCUSED);
return isVisuallyFocused && isKeyboardFocused;
});
}
}
exports.ComboBox = ComboBox;
//# sourceMappingURL=combobox.js.map
;