* {{> waitForNumberOfTabs }}
(expectedTabs, sec)
| 2475 | * {{> waitForNumberOfTabs }} |
| 2476 | */ |
| 2477 | async waitForNumberOfTabs(expectedTabs, sec) { |
| 2478 | const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout |
| 2479 | let currentTabs |
| 2480 | let count = 0 |
| 2481 | |
| 2482 | do { |
| 2483 | currentTabs = await this.grabNumberOfOpenTabs() |
| 2484 | await this.wait(1) |
| 2485 | count += 1000 |
| 2486 | if (currentTabs >= expectedTabs) return |
| 2487 | } while (count <= waitTimeout) |
| 2488 | |
| 2489 | throw new Error(`Expected ${expectedTabs} tabs are not met after ${waitTimeout / 1000} sec.`) |
| 2490 | } |
| 2491 | |
| 2492 | async _getContext() { |
| 2493 | if (this.context && this.context.constructor.name === 'CdpFrame') { |
no test coverage detected