UNPKG

@assert-equals/dappdriver

Version:

DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion

39 lines (38 loc) 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WebDriverFactory = void 0; const selenium_webdriver_1 = require("selenium-webdriver"); const chrome_1 = require("selenium-webdriver/chrome"); const constants_1 = require("../constants"); const log_1 = require("../log"); class WebDriverFactory { async build(browser, options) { if (browser.toLowerCase() === constants_1.CHROME) { return await this.buildChrome(options); } throw new Error('Unsupported browser: ' + browser); } async buildChrome(options) { const chromeOptions = new chrome_1.Options(); const args = []; if (options.proxy) { args.push(`--proxy-server=${constants_1.HTTPS_PROXY_HOST}`); chromeOptions.setAcceptInsecureCerts(true); } if (options.extension.wallet !== null && options.extension.wallet !== constants_1.HEADLESS) { const extensionPath = options.extension.path; (0, log_1.logInfo)(`Loading extension from path: ${extensionPath}`); args.push(`--load-extension=${extensionPath}`); } if (options.extension.wallet === constants_1.HEADLESS) { chromeOptions.enableBidi(); } args.push(`--window-size=1024,768`); chromeOptions.addArguments(...args); chromeOptions.setBrowserVersion('135.0.7049.114'); const driver = await new selenium_webdriver_1.Builder().forBrowser(constants_1.CHROME).setChromeOptions(chromeOptions).build(); await driver.manage().setTimeouts({ implicit: 20000 }); return driver; } } exports.WebDriverFactory = WebDriverFactory;