diff --git a/wallets/metamask/src/pages/NotificationPage/actions/connectToDapp.ts b/wallets/metamask/src/pages/NotificationPage/actions/connectToDapp.ts index 74cb0618f..16f89413a 100644 --- a/wallets/metamask/src/pages/NotificationPage/actions/connectToDapp.ts +++ b/wallets/metamask/src/pages/NotificationPage/actions/connectToDapp.ts @@ -1,8 +1,8 @@ import type { BrowserContext } from '@playwright/test' -import { getNotificationPage } from '../../../utils/getNotificationPage' +import { getNotificationPageAndWaitForLoad } from '../../../utils/getNotificationPageAndWaitForLoad' export async function connectToDapp(context: BrowserContext, extensionId: string) { - const notificationPage = await getNotificationPage(context, extensionId) + const notificationPage = await getNotificationPageAndWaitForLoad(context, extensionId) // Click `Next`. await notificationPage.getByRole('button').nth(1).click() diff --git a/wallets/metamask/src/pages/NotificationPage/actions/signSimpleMessage.ts b/wallets/metamask/src/pages/NotificationPage/actions/signSimpleMessage.ts index 734957595..52e800a76 100644 --- a/wallets/metamask/src/pages/NotificationPage/actions/signSimpleMessage.ts +++ b/wallets/metamask/src/pages/NotificationPage/actions/signSimpleMessage.ts @@ -1,15 +1,15 @@ import type { BrowserContext } from '@playwright/test' -import { getNotificationPage } from '../../../utils/getNotificationPage' +import { getNotificationPageAndWaitForLoad } from '../../../utils/getNotificationPageAndWaitForLoad' import Selectors from '../selectors' const signMessage = async (context: BrowserContext, extensionId: string) => { - const notificationPage = await getNotificationPage(context, extensionId) + const notificationPage = await getNotificationPageAndWaitForLoad(context, extensionId) await notificationPage.locator(Selectors.SignaturePage.signButton).click() } const rejectMessage = async (context: BrowserContext, extensionId: string) => { - const notificationPage = await getNotificationPage(context, extensionId) + const notificationPage = await getNotificationPageAndWaitForLoad(context, extensionId) await notificationPage.locator(Selectors.SignaturePage.rejectButton).click() } diff --git a/wallets/metamask/src/utils/getNotificationPage.ts b/wallets/metamask/src/utils/getNotificationPageAndWaitForLoad.ts similarity index 81% rename from wallets/metamask/src/utils/getNotificationPage.ts rename to wallets/metamask/src/utils/getNotificationPageAndWaitForLoad.ts index 16fcc7a5e..0f444598c 100644 --- a/wallets/metamask/src/utils/getNotificationPage.ts +++ b/wallets/metamask/src/utils/getNotificationPageAndWaitForLoad.ts @@ -1,6 +1,6 @@ import type { BrowserContext, Page } from '@playwright/test' -export async function getNotificationPage(context: BrowserContext, extensionId: string) { +export async function getNotificationPageAndWaitForLoad(context: BrowserContext, extensionId: string) { const notificationPageUrl = `chrome-extension://${extensionId}/notification.html` const isNotificationPage = (page: Page) => page.url().includes(notificationPageUrl) @@ -18,5 +18,7 @@ export async function getNotificationPage(context: BrowserContext, extensionId: height: 592 }) + await notificationPage.waitForLoadState('load') + return notificationPage }