3.6.1 • Published 7 months ago

promod-system v3.6.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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 { waitFor } from 'sat-wait';
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
3.6.1

7 months ago

3.6.0

8 months ago

3.3.0-beta-9

11 months ago

3.3.0-beta-8

12 months ago

3.5.1

9 months ago

3.5.0

9 months ago

3.4.0

10 months ago

3.4.4

10 months ago

3.4.3

10 months ago

3.4.2

10 months ago

3.4.1

10 months ago

3.4.5

10 months ago

3.3.1

10 months ago

3.3.0-beta-7

1 year ago

3.3.0-beta-6

1 year ago

3.3.0-beta-1

1 year ago

3.3.0-beta-3

1 year ago

3.2.0-beta

1 year ago

2.17.0-beta-2

1 year ago

3.3.0-beta-2

1 year ago

3.3.0-beta-4

1 year ago

3.1.0

1 year ago

3.2.0-beta-1

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0-beta-1

1 year ago

3.0.0

1 year ago

3.0.0-alpha

1 year ago

3.0.0-alpha-2

1 year ago

3.0.0-alpha-1

1 year ago

3.0.0-alpha-3

1 year ago

2.17.0-beta-1

1 year ago

2.17.0-alpha-3

2 years ago

2.17.0-alpha-2

2 years ago

2.17.0-alpha-1

2 years ago

2.17.0-alpha

2 years ago

2.16.0-beta

2 years ago

2.15.0

2 years ago

2.15.1

2 years ago

2.14.0

2 years ago

2.13.4

2 years ago

2.13.2

2 years ago

2.13.3

2 years ago

2.12.0-beta

2 years ago

2.12.0-rc2

2 years ago

2.12.0-rc1

2 years ago

2.12.0-rc3

2 years ago

2.13.0

2 years ago

2.13.1

2 years ago

2.11.3

2 years ago

2.11.2

2 years ago

2.11.0

2 years ago

2.11.1

2 years ago

2.9.4

2 years ago

2.9.6

2 years ago

2.9.5

2 years ago

2.10.0

2 years ago

2.9.2

2 years ago

2.9.1

2 years ago

2.9.3

2 years ago

2.8.0-rc

2 years ago

2.9.0

2 years ago

2.7.10-rc1

2 years ago

2.6.3-rc1

2 years ago

2.7.1-rc1

2 years ago

2.6.1-rc1

2 years ago

2.7.7-rc1

2 years ago

2.7.5-rc1

2 years ago

2.7.12-rc1

2 years ago

2.7.2-rc1

2 years ago

2.6.6-rc1

2 years ago

2.7.9-rc1

2 years ago

2.7.0-rc1

2 years ago

2.6.4-rc1

2 years ago

2.7.8-rc1

2 years ago

2.6.2-rc1

2 years ago

2.6.7-rc1

2 years ago

2.6.0-rc1

2 years ago

2.7.11-rc1

2 years ago

2.7.6-rc1

2 years ago

2.5.0-rc1

2 years ago

2.4.3-rc1

2 years ago

2.4.2-rc1

2 years ago

2.4.0-rc1

2 years ago

2.4.1-rc1

2 years ago

2.3.2-rc1

2 years ago

2.3.1-rc1

2 years ago

2.2.2-rc1

3 years ago

2.3.0-rc1

2 years ago

2.2.3-rc1

3 years ago

2.2.1-rc1

3 years ago

2.4.4-rc1

2 years ago

2.2.0-rc1

3 years ago

2.5.1-rc1

2 years ago

1.6.0

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.7.0-rc1

3 years ago

1.7.0-rc2

3 years ago

1.7.0-rc3

3 years ago

1.7.0-rc5

3 years ago

2.1.0-rc2

3 years ago

2.1.0-rc1

3 years ago

2.1.0-rc4

3 years ago

2.1.0-rc3

3 years ago

2.1.0-rc6

3 years ago

2.1.0-rc5

3 years ago

1.7.0-p-beta

3 years ago

2.0.0-rc7

3 years ago

2.0.0-rc6

3 years ago

2.0.0-rc5

3 years ago

2.0.0-rc4

3 years ago

1.3.4

3 years ago

2.0.0-rc3

3 years ago

1.3.3

3 years ago

2.0.0-rc2

3 years ago

1.5.0

3 years ago

1.3.2

3 years ago

2.0.0-rc1

3 years ago

1.3.1

3 years ago

2.0.0-rc8

3 years ago

1.7.0-beta

3 years ago

1.2.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

0.2.0-rc-21

3 years ago

0.2.0-rc-20

3 years ago

1.1.0

3 years ago

0.2.0-rc-19

3 years ago

0.2.0-rc-18

3 years ago

0.2.0-rc-16

3 years ago

1.3.0

3 years ago

0.2.0-rc-15

3 years ago

0.2.0-rc-14

3 years ago

0.2.0-rc-13

3 years ago

0.2.0-rc-12

3 years ago

0.2.0-rc-11

3 years ago

0.2.0-rc-10

3 years ago

0.2.0-rc-9

3 years ago

0.2.0-rc-6

3 years ago

0.2.0-rc-5

3 years ago

0.2.0-rc-8

3 years ago

0.2.0-rc-7

3 years ago

0.2.0-rc-2

3 years ago

0.2.0-rc-1

3 years ago

0.2.0-rc-4

3 years ago

0.1.2

3 years ago

0.2.0-rc-3

3 years ago

0.1.1

3 years ago

0.2.0-rc-0

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.0

3 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.6

4 years ago

0.0.1

4 years ago