systelab-components-wdio-test
Version:
Widgets to be use in the E2E Tests based in WDIO
91 lines (90 loc) • 3.02 kB
JavaScript
import { DefaultTimeout } from "../wdio/index.js";
export class Widget {
constructor(elem) {
this.elem = elem;
}
getElement() {
return this.elem;
}
async isPresent() {
return this.elem.isPresent();
}
async isDisplayed() {
return this.elem.isDisplayed();
}
async isClickable() {
return this.elem.isClickable();
}
async isEnabled() {
return this.elem.isEnabled();
}
async isDisabled() {
return !(await this.isEnabled());
}
byId(id) {
return this.elem.byId(id);
}
byTagName(tagName) {
return this.elem.byTagName(tagName);
}
byClassName(className) {
return this.elem.byClassName(className);
}
byCSS(cssExpression) {
return this.elem.byCSS(cssExpression);
}
byButtonText(text) {
return this.elem.byButtonText(text);
}
byElementText(tagName, text) {
return this.elem.byElementText(tagName, text);
}
bySystelabTestId(systelabTestId) {
return this.elem.bySystelabTestId(systelabTestId);
}
allByTagName(tagName) {
return this.elem.allByTagName(tagName);
}
allByClassName(className) {
return this.elem.allByClassName(className);
}
allByCSS(cssExpression) {
return this.elem.allByCSS(cssExpression);
}
allBySystelabTestId(systelabTestId) {
return this.elem.allBySystelabTestId(systelabTestId);
}
async waitToBePresent(timeout = DefaultTimeout.FAST_WAIT) {
return this.elem.waitUntil(async () => await this.isPresent(), timeout);
}
async waitToBeNotPresent(timeout = DefaultTimeout.FAST_WAIT) {
return this.elem.waitUntil(async () => !(await this.isPresent()), timeout);
}
async waitToBeDisplayed(timeout = DefaultTimeout.FAST_WAIT) {
return this.elem.waitUntil(async () => await this.isDisplayed(), timeout);
}
async waitToBeNotDisplayed(timeout = DefaultTimeout.FAST_WAIT) {
return this.elem.waitUntil(async () => !(await this.isDisplayed()), timeout);
}
async waitToBeClickable(timeout = DefaultTimeout.FAST_WAIT) {
return this.elem.waitUntil(async () => await this.isClickable(), timeout);
}
async waitToBeNotClickable(timeout = DefaultTimeout.FAST_WAIT) {
return this.elem.waitUntil(async () => !(await this.isClickable()), timeout);
}
async waitToBeEnabled(timeout = DefaultTimeout.FAST_WAIT) {
return this.elem.waitUntil(async () => await this.isEnabled(), timeout);
}
async waitToBeDisabled(timeout = DefaultTimeout.FAST_WAIT) {
return this.elem.waitUntil(async () => await this.isDisabled(), timeout);
}
async waitUntil(condition, timeout = DefaultTimeout.SLOW_WAIT) {
return this.elem.waitUntil(condition, timeout);
}
async takeScreenshot() {
return this.elem.takeScreenshot();
}
async saveScreenshot(filepath) {
return this.elem.saveScreenshot(filepath);
}
}