1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 23:58:06 +01:00
metamask-extension/test/e2e/webdriver/index.js
Mark Stacey 8f40cd8438
Update selenium-webdriver (#7749)
Update `selenium-webdriver` to v4.0.0-alpha.5. Despite the fact that
this version has "alpha" in the name, the maintainer of
`selenium-webdriver` has described this release as stable [1].

A few APIs were removed or changed in v4, which required changes to our
Firefox webdriver.

The port used for webdriver communication can now be specified
manually. This was required to ensure the threebox tests kept working,
because they used two different driver instances. This new version of
`selenium-webdriver` now uses the same port for each instance of the
webdriver (unlike the old version, which generated a new port for each
one), so it was necessary to manually specify the port to prevent the
same port from being used for both instances.

`chromedriver` required an update, as the version we were using was not
compatible with the new W3C WebDriver protocol. I've updated
`geckodriver` as well, just to bring it in line with the version of
Firefox we are using.

[1]: https://github.com/SeleniumHQ/selenium/issues/5617#issuecomment-373446249
2020-01-07 10:01:06 -04:00

34 lines
845 B
JavaScript

const { Browser } = require('selenium-webdriver')
const ChromeDriver = require('./chrome')
const FirefoxDriver = require('./firefox')
const buildWebDriver = async function buildWebDriver ({ browser, extensionPath, responsive, port }) {
switch (browser) {
case Browser.CHROME: {
const { driver, extensionId, extensionUrl } = await ChromeDriver.build({ extensionPath, responsive, port })
return {
driver,
extensionId,
extensionUrl,
}
}
case Browser.FIREFOX: {
const { driver, extensionId, extensionUrl } = await FirefoxDriver.build({ extensionPath, responsive, port })
return {
driver,
extensionId,
extensionUrl,
}
}
default: {
throw new Error(`Unrecognized browser: ${browser}`)
}
}
}
module.exports = {
buildWebDriver,
}