aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-11-20 01:13:49 +0800
committerWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-11-21 01:34:50 +0800
commit2902fa948fb4582bd49587bc5638f5f4bc947dc3 (patch)
treef8272c5905fe5544e3cec258205c011d3fba842a /test
parent921125b7fd999965d757c86772b845bdcbc85c20 (diff)
downloadtangerine-wallet-browser-2902fa948fb4582bd49587bc5638f5f4bc947dc3.tar
tangerine-wallet-browser-2902fa948fb4582bd49587bc5638f5f4bc947dc3.tar.gz
tangerine-wallet-browser-2902fa948fb4582bd49587bc5638f5f4bc947dc3.tar.bz2
tangerine-wallet-browser-2902fa948fb4582bd49587bc5638f5f4bc947dc3.tar.lz
tangerine-wallet-browser-2902fa948fb4582bd49587bc5638f5f4bc947dc3.tar.xz
tangerine-wallet-browser-2902fa948fb4582bd49587bc5638f5f4bc947dc3.tar.zst
tangerine-wallet-browser-2902fa948fb4582bd49587bc5638f5f4bc947dc3.zip
Add timeout to waitUntilXWindowHandles e2e helper fn
Diffstat (limited to 'test')
-rw-r--r--test/e2e/beta/helpers.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/test/e2e/beta/helpers.js b/test/e2e/beta/helpers.js
index 08416857e..5e3f45b2b 100644
--- a/test/e2e/beta/helpers.js
+++ b/test/e2e/beta/helpers.js
@@ -85,11 +85,22 @@ async function openNewPage (driver, url) {
await delay(1000)
}
-async function waitUntilXWindowHandles (driver, x) {
- const windowHandles = await driver.getAllWindowHandles()
- if (windowHandles.length === x) return
- await delay(1000)
- return await waitUntilXWindowHandles(driver, x)
+async function waitUntilXWindowHandles (driver, x, delayStep = 1000, timeout = 5000) {
+ let timeElapsed = 0
+ async function _pollWindowHandles () {
+ const windowHandles = await driver.getAllWindowHandles()
+ if (windowHandles.length === x) {
+ return
+ }
+ await delay(delayStep)
+ timeElapsed += delayStep
+ if (timeElapsed > timeout) {
+ throw new Error('waitUntilXWindowHandles timed out polling window handles')
+ } else {
+ await _pollWindowHandles()
+ }
+ }
+ return await _pollWindowHandles()
}
async function switchToWindowWithTitle (driver, title, windowHandles) {