2.17.0-beta-1 • Published 6 days ago

promod-system v2.17.0-beta-1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 days 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 { 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
2.17.0-beta-1

6 days ago

2.17.0-alpha-3

1 month ago

2.17.0-alpha-2

1 month ago

2.17.0-alpha-1

2 months ago

2.17.0-alpha

2 months ago

2.16.0-beta

2 months ago

2.15.0

2 months ago

2.15.1

2 months ago

2.14.0

2 months ago

2.13.4

2 months ago

2.13.2

2 months ago

2.13.3

2 months ago

2.12.0-beta

2 months ago

2.12.0-rc2

2 months ago

2.12.0-rc1

2 months ago

2.12.0-rc3

2 months ago

2.13.0

2 months ago

2.13.1

2 months ago

2.11.3

4 months ago

2.11.2

5 months ago

2.11.0

6 months ago

2.11.1

5 months ago

2.9.4

7 months ago

2.9.6

7 months ago

2.9.5

7 months ago

2.10.0

6 months ago

2.9.2

8 months ago

2.9.1

8 months ago

2.9.3

8 months ago

2.8.0-rc

8 months ago

2.9.0

8 months ago

2.7.10-rc1

8 months ago

2.6.3-rc1

11 months ago

2.7.1-rc1

10 months ago

2.6.1-rc1

11 months ago

2.7.7-rc1

9 months ago

2.7.5-rc1

9 months ago

2.7.12-rc1

8 months ago

2.7.2-rc1

9 months ago

2.6.6-rc1

10 months ago

2.7.9-rc1

8 months ago

2.7.0-rc1

10 months ago

2.6.4-rc1

11 months ago

2.7.8-rc1

9 months ago

2.6.2-rc1

11 months ago

2.6.7-rc1

10 months ago

2.6.0-rc1

11 months ago

2.7.11-rc1

8 months ago

2.7.6-rc1

9 months ago

2.5.0-rc1

12 months ago

2.4.3-rc1

12 months ago

2.4.2-rc1

12 months ago

2.4.0-rc1

1 year ago

2.4.1-rc1

1 year ago

2.3.2-rc1

1 year ago

2.3.1-rc1

1 year ago

2.2.2-rc1

1 year ago

2.3.0-rc1

1 year ago

2.2.3-rc1

1 year ago

2.2.1-rc1

1 year ago

2.4.4-rc1

12 months ago

2.2.0-rc1

1 year ago

2.5.1-rc1

12 months ago

1.6.0

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.7.0-rc1

1 year ago

1.7.0-rc2

1 year ago

1.7.0-rc3

1 year ago

1.7.0-rc5

1 year ago

2.1.0-rc2

1 year ago

2.1.0-rc1

1 year ago

2.1.0-rc4

1 year ago

2.1.0-rc3

1 year ago

2.1.0-rc6

1 year ago

2.1.0-rc5

1 year ago

1.7.0-p-beta

1 year ago

2.0.0-rc7

1 year ago

2.0.0-rc6

1 year ago

2.0.0-rc5

1 year ago

2.0.0-rc4

1 year ago

1.3.4

1 year ago

2.0.0-rc3

1 year ago

1.3.3

1 year ago

2.0.0-rc2

1 year ago

1.5.0

1 year ago

1.3.2

1 year ago

2.0.0-rc1

1 year ago

1.3.1

1 year ago

2.0.0-rc8

1 year ago

1.7.0-beta

1 year ago

1.2.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

0.2.0-rc-21

1 year ago

0.2.0-rc-20

1 year ago

1.1.0

1 year ago

0.2.0-rc-19

1 year ago

0.2.0-rc-18

1 year ago

0.2.0-rc-16

2 years ago

1.3.0

1 year ago

0.2.0-rc-15

2 years ago

0.2.0-rc-14

2 years ago

0.2.0-rc-13

2 years ago

0.2.0-rc-12

2 years ago

0.2.0-rc-11

2 years ago

0.2.0-rc-10

2 years ago

0.2.0-rc-9

2 years ago

0.2.0-rc-6

2 years ago

0.2.0-rc-5

2 years ago

0.2.0-rc-8

2 years ago

0.2.0-rc-7

2 years ago

0.2.0-rc-2

2 years ago

0.2.0-rc-1

2 years ago

0.2.0-rc-4

2 years ago

0.1.2

2 years ago

0.2.0-rc-3

2 years ago

0.1.1

2 years ago

0.2.0-rc-0

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.0

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.6

2 years ago

0.0.1

3 years ago