@progress/kendo-e2e
Version:
Kendo UI end-to-end test utilities.
80 lines • 3.56 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.SplitButton = void 0;
const selenium_1 = require("../selenium");
const const_1 = require("./const");
const ui_component_1 = require("./ui-component");
class SplitButton extends ui_component_1.UIComponent {
constructor(browser, locator = SplitButton.SELECTOR, parentElement) {
super(browser, locator, parentElement);
this.parentElement = parentElement;
}
getMainButton() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild("button:not([class*=k-split-button-arrow])");
});
}
getArrowButton() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.findChild(".k-split-button-arrow");
});
}
popupLocator() {
return __awaiter(this, void 0, void 0, function* () {
const main = yield this.getMainButton();
const id = yield main.getAttribute("aria-controls");
return selenium_1.By.xpath(`//div[contains(@class, "k-animation-container-shown")]//ul[@id="${id}"]`);
});
}
popup() {
return __awaiter(this, void 0, void 0, function* () {
const locator = yield this.popupLocator();
return yield this.browser.find(locator);
});
}
expand() {
return __awaiter(this, void 0, void 0, function* () {
yield (yield this.getArrowButton()).click();
yield this.waitToExpand();
});
}
waitToExpand() {
return __awaiter(this, void 0, void 0, function* () {
yield this.browser.wait(selenium_1.EC.isVisible(yield this.popupLocator()), { timeout: 5000, message: "Failed to expand popup." });
yield this.browser.waitForAnimation(yield this.popupLocator());
});
}
waitToCollapse() {
return __awaiter(this, void 0, void 0, function* () {
yield this.browser.wait(selenium_1.EC.notVisible(yield this.popupLocator()), { timeout: 5000, message: "Failed to collapse popup." });
yield this.browser.sleep(200); // Wait for animation timeout
});
}
getItems() {
return __awaiter(this, void 0, void 0, function* () {
return yield this.browser.findChildren(yield this.popup(), "li");
});
}
getItemByIndex(index) {
return __awaiter(this, void 0, void 0, function* () {
return (yield this.getItems())[index];
});
}
getItemByText(text) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.browser.findChild(yield this.popup(), selenium_1.By.xpath(`.//li[.="${text}"]`));
});
}
}
exports.SplitButton = SplitButton;
SplitButton.SELECTOR = const_1.SELECTORS.SPLIT_BUTTON;
//# sourceMappingURL=splitbutton.js.map