UNPKG

@redhat-developer/page-objects

Version:

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

95 lines 3.57 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.TitleBarItem = exports.TitleBar = void 0; const selenium_webdriver_1 = require("selenium-webdriver"); const __1 = require("../.."); const Menu_1 = require("./Menu"); const MenuItem_1 = require("./MenuItem"); /** * Page object representing the custom VS Code title bar */ class TitleBar extends Menu_1.Menu { constructor() { super(TitleBar.locators.TitleBar.constructor, TitleBar.locators.Workbench.constructor); } /** * Get title bar item by name * @param name name of the item to search by * @returns Promise resolving to TitleBarItem object */ async getItem(name) { try { await this.findElement(TitleBar.locators.TitleBar.itemConstructor(name)); return await new TitleBarItem(name, this).wait(); } catch (err) { return undefined; } } /** * Get all title bar items * @returns Promise resolving to array of TitleBarItem objects */ async getItems() { const items = []; const elements = await this.findElements(TitleBar.locators.TitleBar.itemElement); for (const element of elements) { if (await element.isDisplayed()) { items.push(await new TitleBarItem(await element.getAttribute(TitleBar.locators.TitleBar.itemLabel), this).wait()); } } return items; } /** * Get the window title * @returns Promise resolving to the window title */ async getTitle() { return await this.findElement(TitleBar.locators.TitleBar.title).getText(); } /** * Get a reference to the WindowControls * @deprecated Window Control is no more available in a DOM of Visual Studio Code */ getWindowControls() { return new __1.WindowControls(this); } } exports.TitleBar = TitleBar; /** * Page object representing an item of the custom VS Code title bar */ class TitleBarItem extends MenuItem_1.MenuItem { constructor(label, parent) { super(TitleBar.locators.TitleBar.itemConstructor(label), parent); this.parent = parent; this.label = label; } async select() { const openMenus = await this.getDriver().findElements(TitleBar.locators.ContextMenu.constructor); if (openMenus.length > 0 && (await openMenus[0].isDisplayed())) { await this.getDriver().actions().sendKeys(selenium_webdriver_1.Key.ESCAPE).perform(); } await this.click(); await new Promise((res) => setTimeout(res, 500)); return new __1.ContextMenu(this).wait(); } } exports.TitleBarItem = TitleBarItem; //# sourceMappingURL=TitleBar.js.map