1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/test/e2e/webdriver/index.js

39 lines
952 B
JavaScript
Raw Normal View History

const { Browser } = require('selenium-webdriver');
const Driver = require('./driver');
const ChromeDriver = require('./chrome');
const FirefoxDriver = require('./firefox');
async function buildWebDriver({ responsive, port, timeOut } = {}) {
const browser = process.env.SELENIUM_BROWSER;
2020-11-03 00:41:28 +01:00
const {
driver: seleniumDriver,
extensionId,
extensionUrl,
} = await buildBrowserWebDriver(browser, { responsive, port });
const driver = new Driver(seleniumDriver, browser, extensionUrl, timeOut);
return {
driver,
extensionId,
};
}
2020-11-03 00:41:28 +01:00
async function buildBrowserWebDriver(browser, webDriverOptions) {
switch (browser) {
case Browser.CHROME: {
return await ChromeDriver.build(webDriverOptions);
}
case Browser.FIREFOX: {
return await FirefoxDriver.build(webDriverOptions);
}
default: {
throw new Error(`Unrecognized browser: ${browser}`);
}
}
}
module.exports = {
buildWebDriver,
};