diff options
author | bitpshr <mail@bitpshr.net> | 2018-09-28 02:19:09 +0800 |
---|---|---|
committer | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-11-06 07:07:09 +0800 |
commit | c76c9ca2c86317f902f443db2c5704d4bf6311c0 (patch) | |
tree | e6b182dd8b0eb849d93143ecbd1217640aa8f490 /test/e2e/beta/helpers.js | |
parent | 2d4ff1dd82252cbe1abe06206fb2664f96905d91 (diff) | |
download | tangerine-wallet-browser-c76c9ca2c86317f902f443db2c5704d4bf6311c0.tar.gz tangerine-wallet-browser-c76c9ca2c86317f902f443db2c5704d4bf6311c0.tar.zst tangerine-wallet-browser-c76c9ca2c86317f902f443db2c5704d4bf6311c0.zip |
EIP-1102: updated implementation
Diffstat (limited to 'test/e2e/beta/helpers.js')
-rw-r--r-- | test/e2e/beta/helpers.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/e2e/beta/helpers.js b/test/e2e/beta/helpers.js index 4055d8155..08416857e 100644 --- a/test/e2e/beta/helpers.js +++ b/test/e2e/beta/helpers.js @@ -14,6 +14,7 @@ module.exports = { loadExtension, openNewPage, switchToWindowWithTitle, + switchToWindowWithUrlThatMatches, verboseReportOnFailure, waitUntilXWindowHandles, } @@ -130,3 +131,19 @@ async function assertElementNotPresent (webdriver, driver, by) { } assert.ok(!dataTab, 'Found element that should not be present') } + +async function switchToWindowWithUrlThatMatches (driver, regexp, windowHandles) { + if (!windowHandles) { + windowHandles = await driver.getAllWindowHandles() + } else if (windowHandles.length === 0) { + throw new Error('No window that matches: ' + regexp) + } + const firstHandle = windowHandles[0] + await driver.switchTo().window(firstHandle) + const windowUrl = await driver.getCurrentUrl() + if (windowUrl.match(regexp)) { + return firstHandle + } else { + return await switchToWindowWithUrlThatMatches(driver, regexp, windowHandles.slice(1)) + } +} |