diff options
author | Thomas <thomas.b.huang@gmail.com> | 2018-05-15 08:17:36 +0800 |
---|---|---|
committer | Thomas <thomas.b.huang@gmail.com> | 2018-05-15 08:17:36 +0800 |
commit | cd42d1820318739668774af25e9b1318cd2256dd (patch) | |
tree | 0bd202618e24828d0a5d2c6cba3c230331d90325 /test/e2e/func.js | |
parent | 3632ea29cc0a21448d904d985ae70ee0c13484a4 (diff) | |
download | tangerine-wallet-browser-cd42d1820318739668774af25e9b1318cd2256dd.tar tangerine-wallet-browser-cd42d1820318739668774af25e9b1318cd2256dd.tar.gz tangerine-wallet-browser-cd42d1820318739668774af25e9b1318cd2256dd.tar.bz2 tangerine-wallet-browser-cd42d1820318739668774af25e9b1318cd2256dd.tar.lz tangerine-wallet-browser-cd42d1820318739668774af25e9b1318cd2256dd.tar.xz tangerine-wallet-browser-cd42d1820318739668774af25e9b1318cd2256dd.tar.zst tangerine-wallet-browser-cd42d1820318739668774af25e9b1318cd2256dd.zip |
Merge e2e tests into one
Diffstat (limited to 'test/e2e/func.js')
-rw-r--r-- | test/e2e/func.js | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/test/e2e/func.js b/test/e2e/func.js index 4ad0ea615..8b221ce47 100644 --- a/test/e2e/func.js +++ b/test/e2e/func.js @@ -1,13 +1,24 @@ require('chromedriver') require('geckodriver') +const path = require('path') const webdriver = require('selenium-webdriver') +const Command = require('selenium-webdriver/lib/command').Command +const By = webdriver.By -exports.delay = function delay (time) { - return new Promise(resolve => setTimeout(resolve, time)) +module.exports = { + delay, + buildChromeWebDriver, + buildFirefoxWebdriver, + installWebExt, + getExtensionIdChrome, + getExtensionIdFirefox, } +function delay (time) { + return new Promise(resolve => setTimeout(resolve, time)) +} -exports.buildChromeWebDriver = function buildChromeWebDriver (extPath) { +function buildChromeWebDriver (extPath) { return new webdriver.Builder() .withCapabilities({ chromeOptions: { @@ -17,6 +28,29 @@ exports.buildChromeWebDriver = function buildChromeWebDriver (extPath) { .build() } -exports.buildFirefoxWebdriver = function buildFirefoxWebdriver (extPath) { +function buildFirefoxWebdriver () { return new webdriver.Builder().build() } + +async function getExtensionIdChrome (driver) { + await driver.get('chrome://extensions') + const extensionId = await driver.executeScript('return document.querySelector("extensions-manager").shadowRoot.querySelector("extensions-view-manager extensions-item-list").shadowRoot.querySelector("extensions-item:nth-child(2)").getAttribute("id")') + return extensionId +} + +async function getExtensionIdFirefox (driver) { + await driver.get('about:debugging#addons') + const extensionId = await driver.findElement(By.css('dd.addon-target-info-content:nth-child(6) > span:nth-child(1)')).getText() + return extensionId +} + +async function installWebExt (driver, extension) { + const cmd = await new Command('moz-install-web-ext') + .setParameter('path', path.resolve(extension)) + .setParameter('temporary', true) + + await driver.getExecutor() + .defineCommand(cmd.getName(), 'POST', '/session/:sessionId/moz/addon/install') + + return await driver.schedule(cmd, 'installWebExt(' + extension + ')') +}
\ No newline at end of file |