mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Add timeout to waitUntilXWindowHandles e2e helper fn
This commit is contained in:
parent
921125b7fd
commit
2902fa948f
@ -85,11 +85,22 @@ async function openNewPage (driver, url) {
|
|||||||
await delay(1000)
|
await delay(1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function waitUntilXWindowHandles (driver, x) {
|
async function waitUntilXWindowHandles (driver, x, delayStep = 1000, timeout = 5000) {
|
||||||
const windowHandles = await driver.getAllWindowHandles()
|
let timeElapsed = 0
|
||||||
if (windowHandles.length === x) return
|
async function _pollWindowHandles () {
|
||||||
await delay(1000)
|
const windowHandles = await driver.getAllWindowHandles()
|
||||||
return await waitUntilXWindowHandles(driver, x)
|
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) {
|
async function switchToWindowWithTitle (driver, title, windowHandles) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user