UNPKG

@redhat-developer/page-objects

Version:

Page Object API implementation for a VS Code editor used by ExTester framework.

82 lines 3.5 kB
"use strict"; /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License", destination); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomTreeSection = exports.GenericCustomTreeSection = void 0; const TreeSection_1 = require("../TreeSection"); const selenium_webdriver_1 = require("selenium-webdriver"); const __1 = require("../../../.."); /** * Generic custom tree view, e.g. contributed by an extension */ class GenericCustomTreeSection extends TreeSection_1.TreeSection { _viewContent; _itemConstructor; constructor(panel, _viewContent, itemConstructor) { super(panel, _viewContent); this._viewContent = _viewContent; this._itemConstructor = itemConstructor; } get viewContent() { return this._viewContent; } get itemConstructor() { return this._itemConstructor; } async getVisibleItems() { const items = []; const container = await this.getContainer(); const elements = await container.findElements(CustomTreeSection.locators.CustomTreeSection.itemRow); for (const element of elements) { if (await element.isDisplayed()) { items.push(new this.itemConstructor(element, this)); } } return items; } async findItem(labelOrPredicate, maxLevel = 0) { const predicate = typeof labelOrPredicate === 'string' ? async (el) => (await el.getLabel()) === labelOrPredicate : labelOrPredicate; const elements = await this.getVisibleItems(); for (const element of elements) { if (await predicate(element)) { const level = +(await element.getAttribute(CustomTreeSection.locators.ViewSection.level)); if (maxLevel < 1 || level <= maxLevel) { return element; } } } return undefined; } async getContainer() { await this.expand(); await this.getDriver().wait(selenium_webdriver_1.until.elementLocated(CustomTreeSection.locators.CustomTreeSection.rowContainer), 5000); const container = await this.findElement(CustomTreeSection.locators.CustomTreeSection.rowContainer); await container.sendKeys(selenium_webdriver_1.Key.HOME); return new GenericCustomTreeSection(container, this.viewContent, this.itemConstructor); } } exports.GenericCustomTreeSection = GenericCustomTreeSection; /** * Custom tree view, e.g. contributed by an extension */ class CustomTreeSection extends GenericCustomTreeSection { constructor(panel, viewContent) { super(panel, viewContent, __1.CustomTreeItem); } } exports.CustomTreeSection = CustomTreeSection; //# sourceMappingURL=CustomTreeSection.js.map