@redhat-developer/page-objects
Version:
Page Object API implementation for a VS Code editor used by ExTester framework.
73 lines • 3.12 kB
JavaScript
/**
* 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.ViewControl = void 0;
const __1 = require("../..");
const ElementWithContextMenu_1 = require("../ElementWithContextMenu");
const NewScmView_1 = require("../sidebar/scm/NewScmView");
const compare_versions_1 = require("compare-versions");
/**
* Page object representing a view container item in the activity bar
*/
class ViewControl extends ElementWithContextMenu_1.ElementWithContextMenu {
constructor(element, bar) {
super(element, bar);
}
/**
* Opens the associated view if not already open
* @returns Promise resolving to SideBarView object representing the opened view
*/
async openView() {
// Check whether view is already open
const klass = await this.getAttribute(ViewControl.locators.ViewControl.attribute);
if (klass.indexOf(ViewControl.locators.ViewControl.klass) < 0) {
await this.click();
await ViewControl.driver.sleep(500);
}
const view = await new __1.SideBarView().wait();
if ((await view.findElements(ViewControl.locators.ViewControl.scmId)).length > 0) {
if (ViewControl.versionInfo.browser === 'vscode' && (0, compare_versions_1.satisfies)(ViewControl.versionInfo.version, '>=1.47.0')) {
return new NewScmView_1.NewScmView().wait();
}
return new __1.ScmView().wait();
}
if ((await view.findElements(ViewControl.locators.ViewControl.debugId)).length > 0) {
return new __1.DebugView().wait();
}
return view;
}
/**
* Closes the associated view if not already closed
* @returns Promise resolving when the view closes
*/
async closeView() {
const klass = await this.getAttribute(ViewControl.locators.ViewControl.attribute);
if (klass.indexOf(ViewControl.locators.ViewControl.klass) > -1) {
await this.click();
}
}
/**
* Returns the title of the associated view
*/
async getTitle() {
const badge = await this.findElement(ViewControl.locators.ViewControl.badge);
return await badge.getAttribute('aria-label');
}
}
exports.ViewControl = ViewControl;
//# sourceMappingURL=ViewControl.js.map
;