Add page navigation to e2e web driver (#7867)

The driver now has a page navigation function that can navigate to any
of the three primary pages used in the extension. Additional pages and
support of paths can be added later as needed.
feature/default_network_editable
Mark Stacey 5 years ago committed by GitHub
parent 22d66b3b2d
commit ca38635d22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      test/e2e/webdriver/chrome.js
  2. 15
      test/e2e/webdriver/driver.js
  3. 2
      test/e2e/webdriver/firefox.js
  4. 6
      test/e2e/webdriver/index.js

@ -28,7 +28,7 @@ class ChromeDriver {
return {
driver,
extensionUrl: `chrome-extension://${extensionId}/home.html`,
extensionUrl: `chrome-extension://${extensionId}`,
}
}

@ -8,9 +8,10 @@ class Driver {
* @param {string} browser - The type of browser this driver is controlling
* @param {number} timeout
*/
constructor (driver, browser, timeout = 10000) {
constructor (driver, browser, extensionUrl, timeout = 10000) {
this.driver = driver
this.browser = browser
this.extensionUrl = extensionUrl
this.timeout = timeout
}
@ -84,6 +85,12 @@ class Driver {
assert.ok(!dataTab, 'Found element that should not be present')
}
// Navigation
async navigate (page = Driver.PAGES.HOME) {
return await this.driver.get(`${this.extensionUrl}/${page}.html`)
}
// Window management
async openNewPage (url) {
@ -173,4 +180,10 @@ class Driver {
}
}
Driver.PAGES = {
HOME: 'home',
NOTIFICATION: 'notification',
POPUP: 'popup',
}
module.exports = Driver

@ -52,7 +52,7 @@ class FirefoxDriver {
return {
driver,
extensionId,
extensionUrl: `moz-extension://${internalExtensionId}/home.html`,
extensionUrl: `moz-extension://${internalExtensionId}`,
}
}

@ -10,14 +10,12 @@ async function buildWebDriver ({ responsive, port } = {}) {
const { driver: seleniumDriver, extensionId, extensionUrl } = await buildBrowserWebDriver(browser, { extensionPath, responsive, port })
setupFetchMocking(seleniumDriver)
await seleniumDriver.get(extensionUrl)
const driver = new Driver(seleniumDriver, browser)
const driver = new Driver(seleniumDriver, browser, extensionUrl)
await driver.navigate()
return {
driver,
extensionId,
extensionUrl,
}
}

Loading…
Cancel
Save