Robustify waiting logic in e2e test (#9704)

* Robustify waiting for popup to open

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
feature/default_network_editable
Erik Marks 4 years ago committed by GitHub
parent 046b495670
commit d843bed4e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      test/e2e/metamask-ui.spec.js
  2. 5
      test/e2e/webdriver/driver.js

@ -772,9 +772,8 @@ describe('MetaMask', function () {
await driver.delay(regularDelayMs * 2)
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create Token')]`))
await driver.delay(largeDelayMs)
windowHandles = await driver.waitUntilXWindowHandles(3)
windowHandles = await driver.getAllWindowHandles()
const popup = windowHandles[2]
await driver.switchToWindow(popup)
await driver.delay(regularDelayMs)

@ -124,10 +124,11 @@ class Driver {
async waitUntilXWindowHandles (x, delayStep = 1000, timeout = 5000) {
let timeElapsed = 0
let windowHandles = []
while (timeElapsed <= timeout) {
const windowHandles = await this.driver.getAllWindowHandles()
windowHandles = await this.driver.getAllWindowHandles()
if (windowHandles.length === x) {
return
return windowHandles
}
await this.delay(delayStep)
timeElapsed += delayStep

Loading…
Cancel
Save