@progress/kendo-e2e
Version:
Kendo UI end-to-end test utilities.
108 lines • 4.47 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.Pager = void 0;
const ui_component_1 = require("./ui-component");
const const_1 = require("./const");
const selenium_1 = require("../selenium");
const dropdownlist_1 = require("./dropdownlist");
class Pager extends ui_component_1.UIComponent {
constructor(browser, locator = Pager.SELECTOR, parentElement) {
super(browser, locator, parentElement);
this.parentElement = parentElement;
}
selectedPage() {
return __awaiter(this, void 0, void 0, function* () {
const element = yield this.findChild(`.${const_1.STATES.SELECTED}`);
return yield this.browser.getText(element);
});
}
firstPage() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild(Pager.FIRST);
});
}
lastPage() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild(Pager.LAST);
});
}
previousPage() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild(Pager.PREVIOUS);
});
}
nextPage() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild(Pager.NEXT);
});
}
pageButtons() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChildren(`.k-pager-numbers .k-button`);
});
}
pageButton(index) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild(`.k-pager-numbers .k-button:nth-of-type(${index})`);
});
}
pageButtonByText(text) {
return __awaiter(this, void 0, void 0, function* () {
const defaultLocator = `.//button[.='${text}']`;
const mvcLocator = `.//a[.='${text}']`;
return yield this.findChild(selenium_1.By.xpath(`${defaultLocator}|${mvcLocator}`));
});
}
input() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild(Pager.INPUT);
});
}
setInputValue(value) {
return __awaiter(this, void 0, void 0, function* () {
yield this.browser.click(yield this.input());
yield this.browser.wait(selenium_1.EC.hasFocus(yield this.input()), { timeout: 3000, message: 'Failed to focus pager input.' });
yield this.browser.sendControlKeyCombination('a');
yield this.browser.sleep(10);
yield this.browser.sendKey(selenium_1.Key.BACK_SPACE);
yield this.browser.sleep(10);
yield this.browser.sendKey(value);
yield this.browser.sleep(10);
yield this.browser.sendKey(selenium_1.Key.ENTER);
});
}
dropDownList() {
return __awaiter(this, void 0, void 0, function* () {
return new dropdownlist_1.DropDownList(this.browser, Pager.DROPDOWN_LIST, yield this.root());
});
}
info() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild(Pager.PAGER_INFO);
});
}
infoText() {
return __awaiter(this, void 0, void 0, function* () {
return yield (yield this.info()).getText();
});
}
}
exports.Pager = Pager;
Pager.SELECTOR = const_1.SELECTORS.PAGER;
Pager.FIRST = ".k-pager-first";
Pager.PREVIOUS = ".k-pager-nav[aria-label='Go to the previous page']";
Pager.NEXT = ".k-pager-nav[aria-label='Go to the next page']";
Pager.LAST = ".k-pager-last";
Pager.INPUT = ".k-pager-input input";
Pager.DROPDOWN_LIST = const_1.SELECTORS.DROPDOWN_LIST;
Pager.PAGER_INFO = ".k-pager-info";
//# sourceMappingURL=pager.js.map