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

feature/default_network_editable
kumavis 3 years ago committed by GitHub
parent 4c38d12c5f
commit 20eb35be4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      test/e2e/webdriver/driver.js

@ -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…
Cancel
Save