2019-12-11 20:14:58 +01:00
|
|
|
const { Browser } = require('selenium-webdriver')
|
|
|
|
const ChromeDriver = require('./chrome')
|
|
|
|
const FirefoxDriver = require('./firefox')
|
|
|
|
|
2020-01-07 15:01:06 +01:00
|
|
|
const buildWebDriver = async function buildWebDriver ({ browser, extensionPath, responsive, port }) {
|
2019-12-11 20:14:58 +01:00
|
|
|
switch (browser) {
|
|
|
|
case Browser.CHROME: {
|
2020-01-07 15:01:06 +01:00
|
|
|
const { driver, extensionId, extensionUrl } = await ChromeDriver.build({ extensionPath, responsive, port })
|
2019-12-11 20:14:58 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
driver,
|
|
|
|
extensionId,
|
|
|
|
extensionUrl,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case Browser.FIREFOX: {
|
2020-01-07 15:01:06 +01:00
|
|
|
const { driver, extensionId, extensionUrl } = await FirefoxDriver.build({ extensionPath, responsive, port })
|
2019-12-11 20:14:58 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
driver,
|
|
|
|
extensionId,
|
|
|
|
extensionUrl,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
throw new Error(`Unrecognized browser: ${browser}`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
buildWebDriver,
|
|
|
|
}
|