aboutsummaryrefslogtreecommitdiffstats
path: root/test/e2e/beta/helpers.js
diff options
context:
space:
mode:
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))
+ }
+}