@redhat-developer/page-objects
Version:
Page Object API implementation for a VS Code editor used by ExTester framework.
85 lines • 4.04 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.VariableSectionItem = void 0;
const selenium_webdriver_1 = require("selenium-webdriver");
const CustomTreeItem_1 = require("../custom/CustomTreeItem");
const compare_versions_1 = require("compare-versions");
class VariableSectionItem extends CustomTreeItem_1.CustomTreeItem {
constructor(element, viewPart) {
super(element, viewPart);
}
/**
* Get name of the variable.
* @returns a promise resolving to variable name string
*/
async getVariableName() {
const name = await this.findElement(VariableSectionItem.locators.VariableSectionItem.name.constructor);
return VariableSectionItem.locators.VariableSectionItem.name.value(name);
}
/**
* Get value of the variable.
* @returns a promise resolving to value string of the variable
*/
async getVariableValue() {
const value = await this.findElement(VariableSectionItem.locators.VariableSectionItem.value.constructor);
return VariableSectionItem.locators.VariableSectionItem.value.value(value);
}
/**
* Get variable name tooltip.
* @returns a promise resolving to variable name tooltip string
* @deprecated For VS Code 1.88+ this method won't be working any more
*/
async getVariableNameTooltip() {
if ((0, compare_versions_1.satisfies)(VariableSectionItem.versionInfo.version, '>=1.88.0')) {
throw Error(`DEPRECATED METHOD! For VS Code 1.88+ this method won't be working any more.`);
}
const name = await this.findElement(VariableSectionItem.locators.VariableSectionItem.name.constructor);
return VariableSectionItem.locators.VariableSectionItem.name.tooltip(name);
}
/**
* Get variable value tooltip.
* @returns a promise resolving to variable value tooltip string
* @deprecated For VS Code 1.89+ this method won't be working any more
*/
async getVariableValueTooltip() {
if ((0, compare_versions_1.satisfies)(VariableSectionItem.versionInfo.version, '>=1.89.0')) {
throw Error(`DEPRECATED METHOD! For VS Code 1.89+ this method won't be working any more.`);
}
const value = await this.findElement(VariableSectionItem.locators.VariableSectionItem.value.constructor);
return VariableSectionItem.locators.VariableSectionItem.value.tooltip(value);
}
async getLabel() {
return VariableSectionItem.locators.VariableSectionItem.label(this);
}
getTooltip() {
throw new Error('unsupported: use either getVariableNameTooltip or getVariableValueTooltip');
}
/**
* Assign new value to the variable.
* @param value new value
*/
async setVariableValue(value) {
const valueRootElement = await this.findElement(VariableSectionItem.locators.VariableSectionItem.value.constructor);
const driver = this.getDriver();
await driver.actions().clear();
await driver.actions().doubleClick(valueRootElement).sendKeys(value, selenium_webdriver_1.Key.ENTER).perform();
}
}
exports.VariableSectionItem = VariableSectionItem;
//# sourceMappingURL=VariableSectionItem.js.map
;