PROMOD-SYSTEM
Designed for
promod - works with anyone
API
The purpose of this library is building of the TAF ecosystem which will not
regardless of library or framework which you use for your automation testing
Element(s)
Browser
PromodSystem env var usage
PromodSystem test runner (powered by mocha)
PromodSystem base element
PromodSystem base structure
PromodSystem base collection
Usage. promod example.
Waiters
import { seleniumWD } from 'promod';
import { createBrowserWaiters, createElementWaiters } from 'promod-system';
const { browser, $ } = seleniumWD;
;(async () => {
await getSeleniumDriver({seleniumAddress: 'http://localhost:4444/wd/hub'}, browser);
const browserWaiters = createBrowserWaiters(browser);
const elementWaiters = createElementWaiters();
const documentBody = $('body');
await browser.get('https://www.npmjs.com/');
await browserWaiters.waitForTabTitleIncludes('promod', {timeout: 10_000});
await elementWaiters.waitForTextIncludes(documentBody, 'promod' {timeout: 10_000});
})();
Core
import { waitForCondition } from 'sat-utils';
import { seleniumWD } from 'promod';
import { PromodSystemStructure } from 'promod-system';
import type { PromodElementType } from 'promod/built/interface';
const timeouts = {
s: 5000,
m: 10000,
l: 15000,
xl: 25000,
}
class BaseElement extends PromodSystemElement<PromodElementType> {
constructor(locator: string, name: string, rootElement) {
super(locator, name, rootElement);
}
async waitLoadedState() {
await waitForCondition(async () => this.rootElement.isDisplayed(), {
message: `Element ${this.identifier} with root selector ${this.rootLocator}
should become visible during ${timeouts.l} ms.`
timeout: timeouts.l
});
}
async baseSendKeys(value): Promise<void> {
await this.rootElement.sendKeys(value);
}
async baseGetData(): Promise<{ background: any; value: any }> {
return browser.executeScript(() => {
const background = arguments[0].style.background;
const value = arguments[0].value;
const rect = arguments[0].getBoundingClientRect();
const text = arguments[0].innerText.trim()
return {background, value, rect, text}
}, this.rootElement.getEngineElement());
}
}
class BaseFragment extends PromodSystemStructure {
constructor(locator: string, name: string, rootElement: PromodElementType) {
super(locator, name, rootElement);
}
init(locator: string, name: string, Child: new (...args) => any, ...rest) {
return new Child(locator, name, this.rootElement.$(locator), ...rest);
}
initCollection(locator: string, name: string, Collection: new (...args) => any, Child: new (...args) => any) {
return new Collection(locator, name, this.rootElement.$$(locator), Child);
}
async waitLoadedState() {
await waitForCondition(async () => this.rootElement.isDisplayed(), {
message: `Fragment ${this.identifier} with root selector ${this.rootLocator}
should become visible during ${timeouts.l} ms.`
timeout: timeouts.l
});
}
}
class BasePage extends PromodSystemStructure {
constructor(locator: string, pageName: string) {
super(locator, structureName, $(locator));
}
init(locator: string, name: string, Child: new (...args) => any) {
return new Child(locator, name, this.rootElement.$(locator));
}
initCollection(locator: string, name: string, Collection: new (...args) => any, Child: new (...args) => any) {
return new Collection(locator, name, this.rootElement.$$(locator), Child);
}
async waitLoadedState() {
await waitForCondition(async () => this.rootElement.isDisplayed(), {
message: `Page ${this.identifier} with root selector ${this.rootLocator}
should become visible during ${timeouts.l} ms.`
timeout: timeouts.l
});
}
}
Improvement/new features plan