UNPKG

@progress/kendo-e2e

Version:

Kendo UI end-to-end test utilities.

447 lines 21.1 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.PivotGridColumnMenu = exports.FieldGroup = exports.PivotConfigurator = exports.PivotGrid = void 0; const ui_component_1 = require("./ui-component"); const const_1 = require("./const"); const selenium_1 = require("../selenium"); const treeview_1 = require("./treeview"); const dropdownlist_1 = require("./dropdownlist"); class PivotGrid extends ui_component_1.UIComponent { constructor(browser, locator, parentElement) { super(browser, locator, parentElement); this.parentElement = parentElement; } getColumnHeaderCell(row, column) { return __awaiter(this, void 0, void 0, function* () { const locator = `.k-grid-header tr:nth-of-type(${row}) th:nth-of-type(${column})`; return yield this.findChild(locator); }); } getColumnHeaderCellText(row, column) { return __awaiter(this, void 0, void 0, function* () { return yield (yield this.getColumnHeaderCell(row, column)).getText(); }); } getRowHeaderCell(row, column) { return __awaiter(this, void 0, void 0, function* () { const locator = `.k-pivot-rowheaders .k-grid tr:nth-of-type(${row}) td:nth-of-type(${column})`; return yield this.findChild(locator); }); } getRowHeaderCellText(row, column) { return __awaiter(this, void 0, void 0, function* () { return yield (yield this.getRowHeaderCell(row, column)).findElement(selenium_1.By.css('span:last-of-type')).getText(); }); } cell(row, column) { return __awaiter(this, void 0, void 0, function* () { const locator = `.k-grid-content tr:nth-of-type(${row}) td:nth-of-type(${column})`; return yield this.findChild(locator); }); } cellText(row, column) { return __awaiter(this, void 0, void 0, function* () { return yield (yield this.cell(row, column)).getText(); }); } getRowHeader() { return __awaiter(this, void 0, void 0, function* () { return yield this.findChild('.k-pivot-rowheaders'); }); } getRowHeaderCellsCount() { return __awaiter(this, void 0, void 0, function* () { return (yield this.findChildren('.k-pivot-rowheaders tr th', { waitForChild: false })).length; }); } getRowHeaderCellToggle(row, column) { return __awaiter(this, void 0, void 0, function* () { const icon = yield this.browser.findChild(yield this.getRowHeaderCell(row, column), '.k-svg-icon'); yield this.browser.waitForAnimationAndClick(icon); yield this.waitUntilLoaded({ timeout: 30000, pollTimeout: 100 }); }); } getExportButton(type) { return __awaiter(this, void 0, void 0, function* () { return yield this.browser.find(`button#${type}`); }); } getLoaderContainer() { return __awaiter(this, void 0, void 0, function* () { return (yield this.findChildren('.k-loader-container'))[0]; }); } rowHeaderIsExpanded(row, column) { return __awaiter(this, void 0, void 0, function* () { const cell = yield this.getRowHeaderCell(row, column); const iconClass = yield (yield cell.findElement(selenium_1.By.css('.k-svg-icon'))).getAttribute('class'); if (iconClass.includes('k-svg-i-caret-alt-down') || iconClass.includes('k-svg-i-chevron-up')) { // legacy pivot use k-svg-i-caret-alt-down, new pivot use k-svg-i-chevron-up return true; } else if (iconClass.includes('k-svg-i-caret-alt-right') || iconClass.includes('k-svg-i-chevron-down')) { // legacy pivot use k-svg-i-caret-alt-right, new pivot use k-svg-i-chevron-down return false; } else { throw new Error('Can not determine if header cell is expanded!'); } }); } getColumnHeader() { return __awaiter(this, void 0, void 0, function* () { return this.findChild('.k-pivotgrid-column-headers'); }); } getColumnHeaderCellsCount() { return __awaiter(this, void 0, void 0, function* () { return (yield this.findChildren('.k-pivotgrid-column-headers tr th')).length; }); } getColumnHeaderCellToggle(row, column) { return __awaiter(this, void 0, void 0, function* () { const toggle = yield this.browser.findChild(yield this.getColumnHeaderCell(row, column), '.k-svg-icon'); yield this.browser.waitForAnimationAndClick(toggle); yield this.waitUntilLoaded({ timeout: 30000, pollTimeout: 100 }); }); } columnHeaderIsExpanded(row, column) { return __awaiter(this, void 0, void 0, function* () { const cell = yield this.getColumnHeaderCell(row, column); const iconClass = yield (yield cell.findElement(selenium_1.By.css('.k-svg-icon'))).getAttribute('class'); if (iconClass.includes('k-svg-i-caret-alt-down') || iconClass.includes('k-svg-i-chevron-up')) { // legacy pivot use k-svg-i-caret-alt-down, new pivot use k-svg-i-chevron-up return true; } else if (iconClass.includes('k-svg-i-caret-alt-right') || iconClass.includes('k-svg-i-chevron-down')) { // legacy pivot use k-svg-i-caret-alt-right, new pivot use k-svg-i-chevron-down return false; } else { throw new Error('Can not determine if header cell is expanded!'); } }); } scrollContentVertical(height) { return __awaiter(this, void 0, void 0, function* () { const script = `return $('.k-pivotgrid-values').scrollTop(${height})`; yield this.browser.executeScript(script); }); } getKpiTemplateValue(row, column) { return __awaiter(this, void 0, void 0, function* () { const locator = `.k-pivotgrid-values tr:nth-of-type(${row}) td:nth-of-type(${column}) > span`; return yield this.findChild(locator); }); } } exports.PivotGrid = PivotGrid; PivotGrid.SELECTOR = const_1.SELECTORS.PIVOTGRID; class PivotConfigurator extends ui_component_1.UIComponent { constructor(browser, locator = PivotConfigurator.SELECTOR, parentElement) { super(browser, locator, parentElement); this.parentElement = parentElement; } fieldsList() { return __awaiter(this, void 0, void 0, function* () { return new treeview_1.TreeView(this.browser, '.k-treeview', '.k-fields-list-wrapper'); }); } getColumnsItem(index) { return __awaiter(this, void 0, void 0, function* () { const columnFields = yield this.findChild(PivotConfigurator.COLUMNS_LIST); return yield this.browser.findChild(columnFields, selenium_1.By.css(`.k-chip:nth-of-type(${index})`)); }); } getColumnsItemLabel(index) { return __awaiter(this, void 0, void 0, function* () { const columnFields = yield this.findChild(PivotConfigurator.COLUMNS_LIST); return yield this.browser.findChild(columnFields, selenium_1.By.css(`.k-chip:nth-of-type(${index}) .k-chip-label`)); }); } getColumnsItemText(index) { return __awaiter(this, void 0, void 0, function* () { return (yield this.getColumnsItemLabel(index)).getText(); }); } getRowsItem(index) { return __awaiter(this, void 0, void 0, function* () { const rowFields = yield this.findChild(PivotConfigurator.ROWS_LIST); return yield this.browser.findChild(rowFields, selenium_1.By.css(`.k-chip:nth-of-type(${index})`)); }); } getRowsItemLabel(index) { return __awaiter(this, void 0, void 0, function* () { const rowFields = yield this.findChild(PivotConfigurator.ROWS_LIST); return yield this.browser.findChild(rowFields, selenium_1.By.css(`.k-chip:nth-of-type(${index}) .k-chip-label`)); }); } getRowsItemText(index) { return __awaiter(this, void 0, void 0, function* () { return (yield this.getRowsItemLabel(index)).getText(); }); } getValuesItem(index) { return __awaiter(this, void 0, void 0, function* () { const valueFields = yield this.findChild(PivotConfigurator.VALUES_LIST); return yield this.browser.findChild(valueFields, selenium_1.By.css(`.k-chip:nth-of-type(${index})`)); }); } getValuesItemLabel(index) { return __awaiter(this, void 0, void 0, function* () { const valueFields = yield this.findChild(PivotConfigurator.VALUES_LIST); return yield this.browser.findChild(valueFields, selenium_1.By.css(`.k-chip:nth-of-type(${index}) .k-chip-label`)); }); } getValuesItemText(index) { return __awaiter(this, void 0, void 0, function* () { return (yield this.getValuesItemLabel(index)).getText(); }); } getColumnsCount() { return __awaiter(this, arguments, void 0, function* ({ waitForItems = true } = {}) { const columnFields = yield this.findChild(PivotConfigurator.COLUMNS_LIST); return (yield this.browser.findChildren(columnFields, selenium_1.By.css('.k-chip'), { waitForChild: waitForItems })).length; }); } getRowsCount() { return __awaiter(this, arguments, void 0, function* ({ waitForItems = true } = {}) { const rowFields = yield this.findChild(PivotConfigurator.ROWS_LIST); return (yield this.browser.findChildren(rowFields, selenium_1.By.css('.k-chip'), { waitForChild: waitForItems })).length; }); } getValuesCount() { return __awaiter(this, arguments, void 0, function* ({ waitForItems = true } = {}) { const valueFields = yield this.findChild(PivotConfigurator.VALUES_LIST); return (yield this.browser.findChildren(valueFields, selenium_1.By.css('.k-chip'), { waitForChild: waitForItems })).length; }); } cancel() { return __awaiter(this, void 0, void 0, function* () { const locator = '.k-pivotgrid-configurator-actions .k-button:nth-of-type(1)'; yield (yield this.findChild(locator)).click(); }); } apply() { return __awaiter(this, void 0, void 0, function* () { const locator = '.k-pivotgrid-configurator-actions .k-button:nth-of-type(2)'; yield (yield this.findChild(locator)).click(); }); } deleteRowsItem(index) { return __awaiter(this, void 0, void 0, function* () { const item = yield this.getRowsItem(index); yield (yield this.browser.findChild(item, '.k-svg-i-x')).click(); }); } deleteColumnsItem(index) { return __awaiter(this, void 0, void 0, function* () { const item = yield this.getColumnsItem(index); yield (yield this.browser.findChild(item, '.k-svg-i-x')).click(); }); } openMenuForColumn(index) { return __awaiter(this, void 0, void 0, function* () { const columnFields = yield this.findChild(PivotConfigurator.COLUMNS_LIST); const more = yield this.browser.findChild(columnFields, selenium_1.By.css(`.k-chip:nth-of-type(${index}) .k-svg-i-more-vertical`)); yield this.browser.waitForAnimationAndClick(more); yield this.browser.waitForAnimation('.k-animation-container-shown .k-pivot-fieldmenu'); const menu = new PivotGridColumnMenu(this.browser, '.k-pivot-fieldmenu', '.k-animation-container-shown'); yield this.browser.waitForAnimation(yield menu.root()); return menu; }); } openMenuForRow(index) { return __awaiter(this, void 0, void 0, function* () { const rowFields = yield this.findChild(PivotConfigurator.ROWS_LIST); const more = yield this.browser.findChild(rowFields, selenium_1.By.css(`.k-chip:nth-of-type(${index}) .k-svg-i-more-vertical`)); yield this.browser.waitForAnimationAndClick(more); yield this.browser.waitForAnimation('.k-animation-container-shown .k-pivot-fieldmenu'); const menu = new PivotGridColumnMenu(this.browser, '.k-pivot-fieldmenu', '.k-animation-container-shown'); yield this.browser.waitForAnimation(yield menu.root()); return menu; }); } } exports.PivotConfigurator = PivotConfigurator; PivotConfigurator.SELECTOR = '.k-pivotgrid-configurator'; PivotConfigurator.COLUMNS_LIST = selenium_1.By.css('.k-pivotgrid-targets .k-pivotgrid-target:nth-of-type(1) .k-column-fields'); PivotConfigurator.ROWS_LIST = selenium_1.By.css('.k-pivotgrid-targets .k-pivotgrid-target:nth-of-type(2) .k-column-fields'); PivotConfigurator.VALUES_LIST = selenium_1.By.css('.k-pivotgrid-targets .k-pivotgrid-target:nth-of-type(3) .k-column-fields'); class FieldGroup { } exports.FieldGroup = FieldGroup; FieldGroup.Columns = 'div.k-pivotgrid-targets > .k-pivotgrid-target:nth-child(1)'; FieldGroup.Rows = 'div.k-pivotgrid-targets > .k-pivotgrid-target:nth-child(2)'; FieldGroup.Values = 'div.k-pivotgrid-targets > .k-pivotgrid-target:nth-child(3)'; class PivotGridColumnMenu extends ui_component_1.UIComponent { constructor(browser, locator, parentElement) { super(browser, locator, parentElement); this.parentElement = parentElement; } sortAsc() { return __awaiter(this, void 0, void 0, function* () { const ascMenu = yield this.findChild('.k-svg-i-sort-asc-small'); yield this.browser.waitForAnimationAndClick(ascMenu); yield this.browser.wait(selenium_1.EC.notInViewport(ascMenu), { message: 'Failed to close pivot grid column menu on sort asc click.' }); }); } sortDesc() { return __awaiter(this, void 0, void 0, function* () { const descMenu = yield this.findChild('.k-svg-i-sort-desc-small'); yield this.browser.waitForAnimationAndClick(descMenu); yield this.browser.wait(selenium_1.EC.notInViewport(descMenu), { message: 'Failed to close pivot grid column menu on sort desc click.' }); }); } okButtonClick() { return __awaiter(this, void 0, void 0, function* () { yield this.browser.click('div.k-edit-form-container .k-button-ok'); }); } getItemByText(text) { return __awaiter(this, void 0, void 0, function* () { const locator = selenium_1.By.xpath(`.//*[contains(@class, "k-columnmenu-item") and .="${text}"]`); return yield this.findChild(locator); }); } moveToColumnsElement() { return __awaiter(this, void 0, void 0, function* () { return this.getItemByText("Move to Columns"); }); } moveToRowsElement() { return __awaiter(this, void 0, void 0, function* () { return this.getItemByText("Move to Rows"); }); } moveAsNextElement() { return __awaiter(this, void 0, void 0, function* () { return this.getItemByText("Move next"); }); } moveAsPreviousElement() { return __awaiter(this, void 0, void 0, function* () { return this.getItemByText("Move previous"); }); } moveToColumns() { return __awaiter(this, void 0, void 0, function* () { const item = yield this.moveToColumnsElement(); yield this.browser.waitForAnimation(item); yield item.click(); yield this.browser.isNotVisible(this.rootElement); }); } moveToRows() { return __awaiter(this, void 0, void 0, function* () { const item = yield this.moveToRowsElement(); yield this.browser.waitForAnimation(item); yield item.click(); yield this.browser.isNotVisible(this.rootElement); }); } moveNext() { return __awaiter(this, void 0, void 0, function* () { const item = yield this.moveAsNextElement(); yield this.browser.waitForAnimation(item); yield item.click(); yield this.browser.isNotVisible(this.rootElement); }); } movePrevious() { return __awaiter(this, void 0, void 0, function* () { const item = yield this.moveAsPreviousElement(); yield this.browser.waitForAnimation(item); yield item.click(); yield this.browser.isNotVisible(this.rootElement); }); } openFilterMenu() { return __awaiter(this, void 0, void 0, function* () { const filterMenu = yield this.findChild('.k-filter-item'); yield this.browser.waitForAnimation(filterMenu); yield this.browser.hover(filterMenu); yield this.browser.wait(selenium_1.EC.isVisible('.k-animation-container-shown .k-filter-menu'), { timeout: 5000, message: 'Failed to expand filter menu.' }); }); } filterMenuInput() { return __awaiter(this, void 0, void 0, function* () { return yield this.findChild('.k-animation-container-shown .k-filter-menu .k-textbox input'); }); } getValueFilterMenuInput() { return __awaiter(this, void 0, void 0, function* () { const input = yield this.filterMenuInput(); return yield input.getAttribute('value'); }); } setValueFilterMenuInput(value) { return __awaiter(this, void 0, void 0, function* () { const input = yield this.filterMenuInput(); yield this.browser.waitForAnimation(input); yield this.browser.type(input, value); }); } selectFilterOperators(index) { return __awaiter(this, void 0, void 0, function* () { const container = yield this.browser.find('.k-animation-container-shown .k-filter-menu'); const dropDown = new dropdownlist_1.DropDownList(this.browser, '.k-dropdownlist', container); yield dropDown.selectItemByIndex(index); }); } clearFilter() { return __awaiter(this, void 0, void 0, function* () { const button = yield this.browser.find('.k-animation-container-shown .k-filter-menu .k-button-clear'); yield this.browser.waitForAnimationAndClick(button); yield this.browser.wait(selenium_1.EC.notVisible(button), { timeout: 5000, message: 'Failed to clear filter.' }); }); } applyFilter() { return __awaiter(this, void 0, void 0, function* () { const button = yield this.browser.find('.k-animation-container-shown .k-filter-menu .k-button-filter'); yield this.browser.waitForAnimationAndClick(button); yield this.browser.wait(selenium_1.EC.notVisible(button), { timeout: 5000, message: 'Failed to filter.' }); }); } openIncludeFields() { return __awaiter(this, void 0, void 0, function* () { const includeFields = yield this.findChild('.k-include-item'); yield this.browser.waitForAnimationAndClick(includeFields); yield this.browser.wait(selenium_1.EC.isVisible('.k-window:not([style*=none])'), { timeout: 5000, message: 'Failed to open include fields window.' }); }); } includeFieldsTreeView() { return __awaiter(this, void 0, void 0, function* () { return new treeview_1.TreeView(this.browser, '.k-window:not([style*=none]) .k-treeview'); }); } applyIncludes() { return __awaiter(this, void 0, void 0, function* () { yield this.browser.waitForAnimationAndClick('.k-window:not([style*=none]) .k-button-ok'); }); } resetIncludes() { return __awaiter(this, void 0, void 0, function* () { yield this.browser.waitForAnimationAndClick('.k-window:not([style*=none]) .k-button-cancel'); }); } } exports.PivotGridColumnMenu = PivotGridColumnMenu; //# sourceMappingURL=pivotgrid-legacy.js.map