diff --git a/commands/metamask.js b/commands/metamask.js index 5e6e726e7..fdad8daad 100644 --- a/commands/metamask.js +++ b/commands/metamask.js @@ -933,6 +933,20 @@ const metamask = { return true; } + if (options && options.switchNetwork) { + await playwright.waitAndClick( + permissionsPageElements.connectButton, + notificationPage, + { waitForEvent: 'navi' }, + ); + await playwright.waitAndClick( + confirmationPageElements.footer.approveButton, + notificationPage, + { waitForEvent: 'close' }, + ); + return true; + } + await playwright.waitAndClick( permissionsPageElements.connectButton, notificationPage, diff --git a/docs/synpress-commands.md b/docs/synpress-commands.md index 8a5564c95..2ae6bee81 100644 --- a/docs/synpress-commands.md +++ b/docs/synpress-commands.md @@ -398,6 +398,7 @@ acceptMetamaskAccess(options?: { allAccounts?: boolean; confirmSignatureRequest?: boolean; confirmDataSignatureRequest?: boolean; + switchNetwork?: boolean; }): Chainable; ``` diff --git a/support/index.d.ts b/support/index.d.ts index fb5bbb3e1..68d42b311 100644 --- a/support/index.d.ts +++ b/support/index.d.ts @@ -315,6 +315,7 @@ declare namespace Cypress { allAccounts?: boolean; confirmSignatureRequest?: boolean; confirmDataSignatureRequest?: boolean; + switchNetwork?: boolean; }): Chainable; /** * Reject metamask access request