Socket
Socket
Sign inDemoInstall

promod-system

Package Overview
Dependencies
120
Maintainers
1
Versions
133
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    promod-system

Library promod condition waitings


Version published
Weekly downloads
1.2K
decreased by-22.13%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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);
  }

	/**
	 * @info
	 * this method should be overridden,
	 * method will be execute to wait visibility before next base methods
	 * sendKeys, get, action
	 * ! for isDisplayed method waitLoadedState will not be executed.
	 */
  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
		});
  }

	/**
	 * @info
	 * this method should be overridden,
	 * method will be execute inside sendKeys method
	 * depends on base library/framework specific
	 */
  async baseSendKeys(value): Promise<void> {
    await this.rootElement.sendKeys(value);
  }

	/**
	 * @info
	 * this method should be overridden,
	 * method will be execute inside get method
	 * depends on base library/framework specific
	 */
  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);
  }

	/**
	 * @info
	 * this method should be overridden, it will be execute to wait visibility before next base methods
	 * sendKeys, get, action
	 * ! for isDisplayed method waitLoadedState will not be executed.
	 */
  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);
  }

	/**
	 * @info
	 * this method should be overridden,
	 * method will be execute to wait visibility before next base methods
	 * sendKeys, get, action
	 * ! for isDisplayed method waitLoadedState will not be executed.
	 */
  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

  • Fix hardcoded values
  • Generate get random flows for several fields
  • Config validation
  • Logging
  • Error messages
  • Generate config baseElementsActionsDescription part based on base elements library
  • Generate base library
  • Generate project example
  • Вepth level flow generation

Keywords

FAQs

Last updated on 01 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc