Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 1.11 KB

init.md

File metadata and controls

29 lines (23 loc) · 1.11 KB

Set driver to engine wrapper

Promod is a library, it does not have own test runner, and own browser manipulation interface.
Currently promod has API alignment for playwright
and selenium-webdriver so to run browser manipulation interface next functions could be created

const { chromium } = require('playwright');
const { Browser, Builder } = require('selenium-webdriver');
const { ENGINE } = process.env;

async function getEngine() {
  if (ENGINE === 'pw') {
    const lauchedChrome = await chromium.launch({ headless: false });
    playwrightWD.browser.setClient({ driver: lauchedChrome });

		return playwrightWD;
  } else {
    require('chromedriver');
    const lauchedChrome = await new Builder().forBrowser(Browser.CHROME).build();
    seleniumWD.browser.setClient({
      driver: lauchedChrome,
      lauchNewInstance: async () => await new Builder().forBrowser(Browser.CHROME).build(),
    });

		return seleniumWD
  }
}

module.exports = { getEngine };