|
|
|
@ -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}`); |
|
|
|
|