@progress/kendo-e2e
Version:
Kendo UI end-to-end test utilities.
108 lines • 4.89 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.Menu = void 0;
const selenium_1 = require("../selenium");
const const_1 = require("./const");
const ui_component_1 = require("./ui-component");
class Menu extends ui_component_1.UIComponent {
constructor(browser, locator = Menu.SELECTOR, rootElement) {
super(browser, locator, rootElement);
}
isShown() {
return __awaiter(this, void 0, void 0, function* () {
try {
return yield (yield this.root()).isDisplayed();
}
catch (_a) {
return false;
}
});
}
getMenuItemByIndex(index) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.findChildren(selenium_1.By.xpath('./li')))[index - 1];
});
}
getMenuItemByTextLocator(text) {
return selenium_1.By.xpath(`.//li[contains(@class,"k-menu-item") and .//span[@class="k-menu-link-text" and normalize-space()="${text}"]]`);
}
getMenuItemByText(text) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild(this.getMenuItemByTextLocator(text));
});
}
getMenuItemArrow(text) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.browser.findChild(yield this.getMenuItemByText(text), '.k-menu-expand-arrow');
});
}
clickMenuItem(text_1) {
return __awaiter(this, arguments, void 0, function* (text, { waitForAnimation = true } = {}) {
if (waitForAnimation) {
yield this.browser.waitForAnimation(this.getMenuItemByTextLocator(text), { timeout: 3000, pollTimeout: 50 });
}
const item = yield this.getMenuItemByText(text);
yield this.browser.click(item);
});
}
hoverMenuItem(text_1) {
return __awaiter(this, arguments, void 0, function* (text, { waitForAnimation = true } = {}) {
if (waitForAnimation) {
yield this.browser.waitForAnimation(this.getMenuItemByTextLocator(text), { timeout: 3000, pollTimeout: 50 });
}
const item = yield this.getMenuItemByText(text);
yield this.browser.hover(item);
});
}
isMenuItemFocused(text) {
return __awaiter(this, void 0, void 0, function* () {
const item = this.getMenuItemByText(text);
return (yield (yield item).getAttribute('class')).includes(const_1.STATES.FOCUSED);
});
}
isMenuItemHovered(text) {
return __awaiter(this, void 0, void 0, function* () {
const item = this.getMenuItemByText(text);
return (yield (yield item).getAttribute('class')).includes('k-hover');
});
}
getSubMenuOfItem(text) {
return __awaiter(this, void 0, void 0, function* () {
const menuItem = yield this.getMenuItemByText(text);
const animationContainer = yield this.browser.findChild(menuItem, '.k-animation-container-shown');
return new Menu(this.browser, 'ul', animationContainer);
});
}
leftScroll() {
return __awaiter(this, void 0, void 0, function* () {
return yield (yield this.root()).findElement(selenium_1.By.xpath("./..")).findElement(selenium_1.By.css(".k-scroll-left"));
});
}
rightScroll() {
return __awaiter(this, void 0, void 0, function* () {
return yield (yield this.root()).findElement(selenium_1.By.xpath("./..")).findElement(selenium_1.By.css(".k-scroll-right"));
});
}
upScroll() {
return __awaiter(this, void 0, void 0, function* () {
return yield (yield this.root()).findElement(selenium_1.By.xpath("./..")).findElement(selenium_1.By.css(".k-scroll-up"));
});
}
downScroll() {
return __awaiter(this, void 0, void 0, function* () {
return yield (yield this.root()).findElement(selenium_1.By.xpath("./..")).findElement(selenium_1.By.css(".k-scroll-down"));
});
}
}
exports.Menu = Menu;
Menu.SELECTOR = const_1.SELECTORS.MENU;
//# sourceMappingURL=menu.js.map