UNPKG

@progress/kendo-e2e

Version:

Kendo UI end-to-end test utilities.

84 lines 3.61 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.Editor = void 0; const ui_component_1 = require("./ui-component"); const selenium_1 = require("../selenium"); const const_1 = require("./const"); class Editor extends ui_component_1.UIComponent { constructor(browser, locator = Editor.SELECTOR, parentElement) { super(browser, locator, parentElement); this.parentElement = parentElement; } getValue() { return __awaiter(this, void 0, void 0, function* () { let content = ''; try { const iframe = yield this.browser.find('.k-editor-content iframe'); yield this.browser.driver.switchTo().frame(iframe); const body = yield this.browser.find('body'); content = (yield body.getAttribute('outerHTML')).replace(/\s/g, ' '); } catch (_a) { content = ''; } finally { yield this.browser.driver.switchTo().defaultContent(); } return content; }); } getToolByTitle(title) { return __awaiter(this, void 0, void 0, function* () { return yield this.findChild(`[title='${title}']`); }); } focusToolByTitle(title) { return __awaiter(this, void 0, void 0, function* () { let found = false; for (let i = 0; i < 99; i++) { yield this.browser.sendKey(selenium_1.Key.ARROW_RIGHT); yield this.browser.sleep(50); const focused = yield this.browser.driver.switchTo().activeElement(); const button = yield this.getToolByTitle(title); if ((yield focused.getId()) === (yield button.getId())) { found = true; break; } } if (!found) { throw new Error(`Failed to focus '${title}' item.`); } }); } getEditableArea() { return __awaiter(this, void 0, void 0, function* () { return yield this.findChild('.k-editable-area'); }); } getEditableContent() { return __awaiter(this, void 0, void 0, function* () { return yield this.findChild('.k-content'); }); } setMaliciousInputs(myInputElement, maliciousInputArray, expectationsArray) { const _super = Object.create(null, { setMaliciousInputs: { get: () => super.setMaliciousInputs } }); return __awaiter(this, void 0, void 0, function* () { const inputElement = myInputElement || (yield this.getEditableContent()); yield _super.setMaliciousInputs.call(this, inputElement, maliciousInputArray, expectationsArray); }); } } exports.Editor = Editor; Editor.SELECTOR = const_1.SELECTORS.EDITOR; //# sourceMappingURL=editor.js.map