promod

Library for automation testing

Usage no npm install needed!

<script type="module">
  import promod from 'https://cdn.skypack.dev/promod';
</script>

README

PROMOD

Motivation. I really like protractor framework, and its api. Unfortunately protractor is deprecated.
That's why i decided to build this library and this library should allow you replace protractor framework in your TAF without massive refactoring.

API

Browser and element APIs should work in same way (as it was in protractor). But this library does not have ExpectedConditions object - replacement for this is simple browser.wait with browser/element API.

Element

Elements

Browser

Init driver

Usage

  const {seleniumWD} = require('promod');
  const {$, $, getSeleniumDriver, browser} = seleniumWD;

  ;(async () => {
    const searchInput = $('input[name="q"]');
    const sections = $('section');
    await getSeleniumDriver({seleniumAddress: 'http://localhost:4444/wd/hub'}, browser);
    await browser.get('https://www.npmjs.com/');
    await searchInput.sendKeys(`promod${browser.Key.ENTER}`);
    console.log(await sections.get(0).$('a').getText());
  })()

Transition from protractor to promod. Mocha example.

Current test command

  "test": "protractor ./protractor.conf.js"

Update to

  "test": "mocha $(find specs -name '*.spec.*') --file ./mocha.hooks.js --timeout 500000"

Where: $(find specs -name '*.spec.*') spec files --file ./mocha.hooks.js mocha hooks file

mocha.hooks.js example

const {config} = require('./protractor.conf.js');
const {seleniumWD} = require('promod');

before(async function() {
  /**
   * onPrepare - protractor part
   * rest - other config data
   */
  const {onPrepare, ...rest} = config;
  const {getSeleniumDriver, browser, $, $} = seleniumWD;

    await getSeleniumDriver(rest, browser);

  // i am not a big fan of global object usage, but if it is suitable for you, just add API to global
  global.browser = browser;
  global.$ = $;
  global.$ = $;

  if (onPrepare) {
    await onPrepare();
  }
});

after(async function() {
  await global.browser.quit();
});

Current drivers update command

  "update:driver": "webdriver-manager update"

Update to

  "update:driver": "selenium-standalone install"

Improvement plan

  • Add documentation
  • Add playwright integration
  • Add test runner
  • Add logger