1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

test/e2e/driver/switchToWindowWithTitle - refresh window handles on each retry loop (#12237)

This commit is contained in:
kumavis 2021-09-28 12:40:07 -10:00 committed by GitHub
parent 4c38d12c5f
commit 20eb35be4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -277,13 +277,13 @@ class Driver {
async switchToWindowWithTitle(
title,
windowHandles,
initialWindowHandles,
delayStep = 1000,
timeout = 5000,
) {
let windowHandles =
initialWindowHandles || (await this.driver.getAllWindowHandles());
let timeElapsed = 0;
// eslint-disable-next-line no-param-reassign
windowHandles = windowHandles || (await this.driver.getAllWindowHandles());
while (timeElapsed <= timeout) {
for (const handle of windowHandles) {
await this.driver.switchTo().window(handle);
@ -294,6 +294,8 @@ class Driver {
}
await this.delay(delayStep);
timeElapsed += delayStep;
// refresh the window handles
windowHandles = await this.driver.getAllWindowHandles();
}
throw new Error(`No window with title: ${title}`);