npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

promod-system

v3.4.5

Published

Library promod condition waitings

Downloads

6,638

Readme

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

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