Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor building of e2e web driver #7841

Merged
merged 1 commit into from
Jan 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions test/e2e/webdriver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,26 @@ async function buildWebDriver ({ responsive, port } = {}) {
const browser = process.env.SELENIUM_BROWSER
const extensionPath = `dist/${browser}`

const { driver: seleniumDriver, extensionId, extensionUrl } = await buildBrowserWebDriver(browser, { extensionPath, responsive, port })
setupFetchMocking(seleniumDriver)
await seleniumDriver.get(extensionUrl)

const driver = new Driver(seleniumDriver, browser)

return {
driver,
extensionId,
extensionUrl,
}
}

async function buildBrowserWebDriver (browser, webDriverOptions) {
switch (browser) {
case Browser.CHROME: {
const { driver, extensionId, extensionUrl } = await ChromeDriver.build({ extensionPath, responsive, port })
setupFetchMocking(driver)
await driver.get(extensionUrl)

return {
driver: new Driver(driver, browser),
extensionId,
extensionUrl,
}
return await ChromeDriver.build(webDriverOptions)
}
case Browser.FIREFOX: {
const { driver, extensionId, extensionUrl } = await FirefoxDriver.build({ extensionPath, responsive, port })
setupFetchMocking(driver)
await driver.get(extensionUrl)

return {
driver: new Driver(driver, browser),
extensionId,
extensionUrl,
}
return await FirefoxDriver.build(webDriverOptions)
}
default: {
throw new Error(`Unrecognized browser: ${browser}`)
Expand Down