UNPKG

@progress/kendo-e2e

Version:

Kendo UI end-to-end test utilities.

113 lines 5.21 kB
"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.TreeView = void 0; const ui_component_1 = require("./ui-component"); const const_1 = require("./const"); const selenium_1 = require("../selenium"); class TreeView extends ui_component_1.UIComponent { constructor(browser, locator = TreeView.SELECTOR, parentElement) { super(browser, locator, parentElement); this.parentElement = parentElement; } getNodesText() { return __awaiter(this, void 0, void 0, function* () { const locator = ".k-treeview-leaf-text"; const treeNodes = yield this.findChildren(locator, { waitForChild: false }); const treeNodesLength = yield treeNodes.length; let nodesText = ""; for (let i = 0; i < treeNodesLength; i++) { nodesText += yield treeNodes[i].getText(); } return nodesText; }); } toggleByIndex(index) { return __awaiter(this, void 0, void 0, function* () { const locator = "li.k-treeview-item .k-treeview-toggle"; const item = (yield this.findChildren(locator, { waitForChild: true }))[index]; yield item.click(); yield this.browser.sleep(100); }); } selectItemByIndex(index) { return __awaiter(this, void 0, void 0, function* () { const item = yield this.getItemByIndex(index); yield item.click(); yield this.browser.wait(selenium_1.EC.hasClass(item, const_1.STATES.SELECTED), { timeout: 5000, message: `Failed to select item ${index}` }); yield this.browser.sleep(100); }); } getItemByIndex(index) { return __awaiter(this, void 0, void 0, function* () { const locator = ".k-treeview-item .k-treeview-leaf"; return (yield this.findChildren(locator, { waitForChild: true }))[index]; }); } getItemName(index) { return __awaiter(this, void 0, void 0, function* () { const locator = "li.k-treeview-item div span.k-treeview-leaf"; return yield (yield this.findChildren(locator, { waitForChild: true }))[index].getText(); }); } isItemChecked(index) { return __awaiter(this, void 0, void 0, function* () { yield this.browser.wait(() => __awaiter(this, void 0, void 0, function* () { return (yield this.findChildren("li.k-treeview-item")).length > index; }), { timeout: 10000, message: `Failed to find TreeView item with index ${index}.`, }); const value = yield (yield this.findChildren("li.k-treeview-item"))[index].getAttribute("aria-checked"); if (value === "true") { return true; } else if (value === "false") { return false; } else { throw new Error("Can not determine if item is checked."); } }); } isItemExpanded(index) { return __awaiter(this, void 0, void 0, function* () { yield this.browser.wait(() => __awaiter(this, void 0, void 0, function* () { return (yield this.findChildren("li.k-treeview-item")).length > index; }), { timeout: 10000, message: `Failed to find TreeView item with index ${index}.`, }); const value = yield (yield this.findChildren("li.k-treeview-item"))[index].getAttribute("aria-expanded"); if (value === "true") { return true; } else if (value === "false") { return false; } else { throw new Error("Can not determine if item is expanded."); } }); } checkItem(index) { return __awaiter(this, void 0, void 0, function* () { const locator = "li.k-treeview-item div span.k-checkbox-wrap input"; yield (yield this.findChildren(locator, { waitForChild: true }))[index].click(); }); } getItemChildren(index) { return __awaiter(this, void 0, void 0, function* () { const locator = ".k-treeview-item"; const item = (yield this.findChildren(locator, { waitForChild: true }))[index]; return yield item.findElements(selenium_1.By.css(".k-treeview-item")); }); } } exports.TreeView = TreeView; TreeView.SELECTOR = const_1.SELECTORS.TREEVIEW; //# sourceMappingURL=treeview.js.map