From 5623e5269c6eb770047f9fc33af67b26504f67cf Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Mon, 20 Jan 2020 13:03:07 -0400 Subject: [PATCH] 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. --- test/e2e/webdriver/chrome.js | 2 +- test/e2e/webdriver/driver.js | 15 ++++++++++++++- test/e2e/webdriver/firefox.js | 2 +- test/e2e/webdriver/index.js | 6 ++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/test/e2e/webdriver/chrome.js b/test/e2e/webdriver/chrome.js index f225f77f1daa..d9d0e2b06876 100644 --- a/test/e2e/webdriver/chrome.js +++ b/test/e2e/webdriver/chrome.js @@ -22,7 +22,7 @@ class ChromeDriver { return { driver, - extensionUrl: `chrome-extension://${extensionId}/home.html`, + extensionUrl: `chrome-extension://${extensionId}`, } } diff --git a/test/e2e/webdriver/driver.js b/test/e2e/webdriver/driver.js index 01a7a42ddb65..59a9bd6e201c 100644 --- a/test/e2e/webdriver/driver.js +++ b/test/e2e/webdriver/driver.js @@ -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 } @@ -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) { @@ -189,4 +196,10 @@ class Driver { } } +Driver.PAGES = { + HOME: 'home', + NOTIFICATION: 'notification', + POPUP: 'popup', +} + module.exports = Driver diff --git a/test/e2e/webdriver/firefox.js b/test/e2e/webdriver/firefox.js index cd698e6e3e11..c1b31bee9aec 100644 --- a/test/e2e/webdriver/firefox.js +++ b/test/e2e/webdriver/firefox.js @@ -53,7 +53,7 @@ class FirefoxDriver { return { driver, extensionId, - extensionUrl: `moz-extension://${internalExtensionId}/home.html`, + extensionUrl: `moz-extension://${internalExtensionId}`, } } diff --git a/test/e2e/webdriver/index.js b/test/e2e/webdriver/index.js index ae2bd8faeedb..1e5bea5e5434 100644 --- a/test/e2e/webdriver/index.js +++ b/test/e2e/webdriver/index.js @@ -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, } }