Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Commit

Permalink
Add page navigation to e2e web driver (MetaMask#7867)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Gudahtt authored and yqrashawn committed Feb 3, 2020
1 parent 29210eb commit 5623e52
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion test/e2e/webdriver/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ChromeDriver {

return {
driver,
extensionUrl: `chrome-extension://${extensionId}/home.html`,
extensionUrl: `chrome-extension://${extensionId}`,
}
}

Expand Down
15 changes: 14 additions & 1 deletion test/e2e/webdriver/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -90,6 +91,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) {
Expand Down Expand Up @@ -189,4 +196,10 @@ class Driver {
}
}

Driver.PAGES = {
HOME: 'home',
NOTIFICATION: 'notification',
POPUP: 'popup',
}

module.exports = Driver
2 changes: 1 addition & 1 deletion test/e2e/webdriver/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FirefoxDriver {
return {
driver,
extensionId,
extensionUrl: `moz-extension://${internalExtensionId}/home.html`,
extensionUrl: `moz-extension://${internalExtensionId}`,
}
}

Expand Down
6 changes: 2 additions & 4 deletions test/e2e/webdriver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ async function buildWebDriver ({ responsive, port } = {}) {
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,
}
}

Expand Down

0 comments on commit 5623e52

Please sign in to comment.