diff --git a/commands/metamask.js b/commands/metamask.js index b6ea56f29..8e19d009a 100644 --- a/commands/metamask.js +++ b/commands/metamask.js @@ -372,6 +372,8 @@ module.exports = { }, confirmTransaction: async () => { const isKovanTestnet = getNetwork().networkName === 'kovan'; + // todo: remove waitForTimeout below after improving switchToMetamaskNotification + await puppeteer.metamaskWindow().waitForTimeout(1000); const notificationPage = await puppeteer.switchToMetamaskNotification(); const currentGasFee = await puppeteer.waitAndGetValue( confirmPageElements.gasFeeInput, diff --git a/commands/puppeteer.js b/commands/puppeteer.js index d97776d13..7333dc7b5 100644 --- a/commands/puppeteer.js +++ b/commands/puppeteer.js @@ -5,8 +5,6 @@ let puppeteerBrowser; let mainWindow; let metamaskWindow; -let switchToMetamaskNotificationRetries; - module.exports = { puppeteerBrowser: () => { return puppeteerBrowser; @@ -98,24 +96,18 @@ module.exports = { return true; }, switchToMetamaskNotification: async () => { - await metamaskWindow.waitForTimeout(500); + // todo: wait for page to be initialized before triggering waitFor + // todo: wait for spinning loader to be gone before triggering waitFor + // todo: get rid of waitForTimeout after fixing above + // todo: all of the above are issues related to metamask notification of tx confirmation + await module.exports.metamaskWindow().waitForTimeout(3000); let pages = await puppeteerBrowser.pages(); for (const page of pages) { if (page.url().includes('notification')) { - switchToMetamaskNotificationRetries = 0; await page.bringToFront(); return page; } } - - // 24*500ms = 12 seconds in total - if (switchToMetamaskNotificationRetries < 24) { - switchToMetamaskNotificationRetries++; - const page = await module.exports.switchToMetamaskNotification(); - return page; - } else { - return false; - } }, waitFor: async (selector, page = metamaskWindow) => { await page.waitForFunction(