UNPKG

@redhat-developer/page-objects

Version:

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

144 lines 5.53 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.BottomBarPanel = void 0; const AbstractElement_1 = require("../AbstractElement"); const selenium_webdriver_1 = require("selenium-webdriver"); const __1 = require("../.."); /** * Page object for the bottom view panel */ class BottomBarPanel extends AbstractElement_1.AbstractElement { constructor() { super(BottomBarPanel.locators.BottomBarPanel.constructor, BottomBarPanel.locators.Workbench.constructor); } /** * Open/Close the bottom bar panel * @param open true to open. false to close * @returns Promise resolving when the view visibility is toggled */ async toggle(open) { try { const tab = await new __1.EditorView().getActiveTab(); await tab?.click(); } catch (err) { // ignore and move on } const height = (await this.getRect()).height; if ((open && height === 0) || (!open && height > 0)) { if (open) { await this.getDriver().actions().clear(); await this.getDriver().actions().keyDown(BottomBarPanel.ctlKey).sendKeys('j').perform(); await this.wait(); } else { await this.closePanel(); await this.getDriver().wait(selenium_webdriver_1.until.elementIsNotVisible(this)); } } } /** * Open the Problems view in the bottom panel * @returns Promise resolving to a ProblemsView object */ async openProblemsView() { await this.openTab(BottomBarPanel.locators.BottomBarPanel.problemsTab); return new __1.ProblemsView(this).wait(); } /** * Open the Output view in the bottom panel * @returns Promise resolving to OutputView object */ async openOutputView() { await this.openTab(BottomBarPanel.locators.BottomBarPanel.outputTab); return new __1.OutputView(this).wait(); } /** * Open the Debug Console view in the bottom panel * @returns Promise resolving to DebugConsoleView object */ async openDebugConsoleView() { await this.openTab(BottomBarPanel.locators.BottomBarPanel.debugTab); return new __1.DebugConsoleView(this).wait(); } /** * Open the Terminal view in the bottom panel * @returns Promise resolving to TerminalView object */ async openTerminalView() { await this.openTab(BottomBarPanel.locators.BottomBarPanel.terminalTab); return new __1.TerminalView(this).wait(); } /** * Maximize the the bottom panel if not maximized * @returns Promise resolving when the maximize button is pressed */ async maximize() { await this.resize(BottomBarPanel.locators.BottomBarPanel.maximize); } /** * Restore the the bottom panel if maximized * @returns Promise resolving when the restore button is pressed */ async restore() { await this.resize(BottomBarPanel.locators.BottomBarPanel.restore); } /** * Opens (or focuses) a tab in the bottom bar panel by its title. * * @param title The exact name of the tab to be opened or focused. * @returns A promise that resolves when the tab is opened or focused. */ async openTab(title) { await this.toggle(true); const tabContainer = await this.findElement(BottomBarPanel.locators.BottomBarPanel.tabContainer); try { const tabs = await tabContainer.findElements(BottomBarPanel.locators.BottomBarPanel.tab(title)); if (tabs.length > 0) { await tabs[0].click(); } else { const label = await tabContainer.findElement(BottomBarPanel.locators.BottomBarPanel.openTabElement(title)); await label.click(); } } catch (err) { await new __1.Workbench().executeCommand(`${title}: Focus on ${title} View`); } } async resize(label) { await this.toggle(true); let action; try { action = await this.findElement(BottomBarPanel.locators.BottomBarPanel.globalActions).findElement(BottomBarPanel.locators.BottomBarPanel.action(label)); } catch (err) { // the panel is already maximized } if (action) { await action.click(); } } async closePanel() { const closeButton = await this.findElement(BottomBarPanel.locators.BottomBarPanel.closeAction); await closeButton.click(); } } exports.BottomBarPanel = BottomBarPanel; //# sourceMappingURL=BottomBarPanel.js.map