@progress/kendo-e2e
Version:
Kendo UI end-to-end test utilities.
57 lines • 2.73 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.AutoComplete = void 0;
const selenium_1 = require("../selenium");
const const_1 = require("./const");
const dropdown_1 = require("./dropdown");
class AutoComplete extends dropdown_1.DropDown {
constructor(browser, locator = AutoComplete.SELECTOR, rootElement) {
super(browser, locator, rootElement);
}
type(text_1) {
return __awaiter(this, arguments, void 0, function* (text, { clear = true } = {}) {
yield (yield this.input()).click();
const focused = selenium_1.EC.hasFocus(yield this.findChild("input"));
yield this.browser.wait(focused, { timeout: 3000, message: "Failed to focus input element!" });
if (clear && (yield this.getValue()) !== "") {
yield this.browser.sendControlKeyCombination("a");
yield this.browser.sendKey(selenium_1.Key.BACK_SPACE);
}
yield this.browser.sendKey(text);
});
}
clearValue() {
return __awaiter(this, void 0, void 0, function* () {
yield this.browser.driver
.actions({ async: true, bridge: true })
.move({ origin: yield this.root() })
.perform();
const clearButton = yield this.clear();
yield clearButton.click();
});
}
getValue() {
return __awaiter(this, void 0, void 0, function* () {
return yield (yield this.input()).getAttribute("value");
});
}
isFocused() {
return __awaiter(this, void 0, void 0, function* () {
const isVisuallyFocused = (yield (yield this.root()).getAttribute("class")).includes(const_1.STATES.FOCUSED);
const isKeyboardFocused = this.browser.hasFocus(yield this.input());
return isVisuallyFocused && isKeyboardFocused;
});
}
}
exports.AutoComplete = AutoComplete;
AutoComplete.SELECTOR = const_1.SELECTORS.AUTOCOMPLETE;
//# sourceMappingURL=autocomplete.js.map
;