@redhat-developer/page-objects
Version:
Page Object API implementation for a VS Code editor used by ExTester framework.
91 lines • 3.74 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.ViewContent = void 0;
const __1 = require("../..");
const selenium_webdriver_1 = require("selenium-webdriver");
const AbstractElement_1 = require("../AbstractElement");
/**
* Page object representing the view container of a side bar view
*/
class ViewContent extends AbstractElement_1.AbstractElement {
constructor(view = new __1.SideBarView()) {
super(ViewContent.locators.ViewContent.constructor, view);
}
/**
* Finds whether a progress bar is active at the top of the view
* @returns Promise resolving to true/false
*/
async hasProgress() {
const progress = await this.findElement(ViewContent.locators.ViewContent.progress);
const hidden = await progress.getAttribute('aria-hidden');
if (hidden === 'true') {
return false;
}
return true;
}
async getSection(titleOrPredicate, type) {
const sections = await this.getSections();
const predicate = typeof titleOrPredicate === 'string' ? async (section) => (await section.getTitle()) === titleOrPredicate : titleOrPredicate;
for (const section of sections) {
if (await predicate(section)) {
if (type !== undefined && !(section instanceof type)) {
return new type(section, this);
}
return section;
}
}
if (typeof titleOrPredicate === 'string') {
throw new selenium_webdriver_1.error.NoSuchElementError(`No section with title '${titleOrPredicate}' found`);
}
else {
throw new selenium_webdriver_1.error.NoSuchElementError(`No section satisfying predicate found`);
}
}
/**
* Retrieves all the collapsible view content sections
* @returns Promise resolving to array of ViewSection objects
*/
async getSections() {
const sections = [];
const elements = await this.findElements(ViewContent.locators.ViewContent.section);
for (const element of elements) {
sections.push(await this.createSection(element));
}
return sections;
}
async createSection(panel, type) {
if (type !== undefined) {
return new type(panel, this);
}
const section = new __1.DefaultTreeSection(panel, this);
const types = ViewContent.locators.DefaultTreeSection.type;
const locators = ViewContent.locators;
if (await types.default(section, locators)) {
return section;
}
else if (await types.marketplace.extension(section, locators)) {
return new __1.ExtensionsViewSection(panel, this);
}
else {
return new __1.CustomTreeSection(panel, this);
}
}
}
exports.ViewContent = ViewContent;
//# sourceMappingURL=ViewContent.js.map
;