aboutsummaryrefslogtreecommitdiffstats
path: root/test/e2e/beta/helpers.js
diff options
context:
space:
mode:
authorVimal <vtiwari@coinswitch.co>2018-11-12 20:20:37 +0800
committerVimal <vtiwari@coinswitch.co>2018-11-12 20:20:37 +0800
commit6bb92a8672edf23465fb109c8966d2e56500ea86 (patch)
tree6f5c4e348fb58fcf23b27278ffae1c1b912ad08e /test/e2e/beta/helpers.js
parent82b11b69a5dea38a4a036096528354a5a291a447 (diff)
parentda1036f2c4b20748407b7fa89b60df5e321fcab7 (diff)
downloadtangerine-wallet-browser-6bb92a8672edf23465fb109c8966d2e56500ea86.tar
tangerine-wallet-browser-6bb92a8672edf23465fb109c8966d2e56500ea86.tar.gz
tangerine-wallet-browser-6bb92a8672edf23465fb109c8966d2e56500ea86.tar.bz2
tangerine-wallet-browser-6bb92a8672edf23465fb109c8966d2e56500ea86.tar.lz
tangerine-wallet-browser-6bb92a8672edf23465fb109c8966d2e56500ea86.tar.xz
tangerine-wallet-browser-6bb92a8672edf23465fb109c8966d2e56500ea86.tar.zst
tangerine-wallet-browser-6bb92a8672edf23465fb109c8966d2e56500ea86.zip
merging upstream branch
Diffstat (limited to 'test/e2e/beta/helpers.js')
-rw-r--r--test/e2e/beta/helpers.js17
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))
+ }
+}