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:
parent
4c38d12c5f
commit
20eb35be4e
@ -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}`);
|
||||
|
Loading…
Reference in New Issue
Block a user