diff --git a/wallets/metamask/src/pages/NotificationPage/page.ts b/wallets/metamask/src/pages/NotificationPage/page.ts index ebed5cced..a41493c51 100644 --- a/wallets/metamask/src/pages/NotificationPage/page.ts +++ b/wallets/metamask/src/pages/NotificationPage/page.ts @@ -1,6 +1,5 @@ import type { Page } from '@playwright/test' import { getNotificationPageAndWaitForLoad } from '../../utils/getNotificationPageAndWaitForLoad' -import { waitFor } from '../../utils/waitFor' import { type GasSetting, approvePermission, @@ -35,13 +34,14 @@ export class NotificationPage { private async beforeMessageSignature(extensionId: string) { const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId) - // TODO: Make this configurable. - // Most of the time, this function will be used to sign structured messages, so we check for the scroll button first. - const isScrollButtonVisible = await waitFor( - () => notificationPage.locator(Selectors.SignaturePage.structuredMessage.scrollDownButton).isVisible(), - 1_500, - false - ) + const scrollButton = notificationPage.locator(Selectors.SignaturePage.structuredMessage.scrollDownButton) + const isScrollButtonPresent = (await scrollButton.count()) > 0 + + let isScrollButtonVisible = false + if (isScrollButtonPresent) { + await scrollButton.waitFor({ state: 'visible' }) + isScrollButtonVisible = true + } return { notificationPage, diff --git a/wallets/metamask/src/utils/getNotificationPageAndWaitForLoad.ts b/wallets/metamask/src/utils/getNotificationPageAndWaitForLoad.ts index 2a8951782..3b2405948 100644 --- a/wallets/metamask/src/utils/getNotificationPageAndWaitForLoad.ts +++ b/wallets/metamask/src/utils/getNotificationPageAndWaitForLoad.ts @@ -20,7 +20,7 @@ export async function getNotificationPageAndWaitForLoad(context: BrowserContext, height: 592 }) - await notificationPage.waitForLoadState('load') + await notificationPage.waitForLoadState('domcontentloaded') return notificationPage }