diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts index 121be7b2..244dd71e 100644 --- a/packages/wallets/src/metamask/metamask.page.ts +++ b/packages/wallets/src/metamask/metamask.page.ts @@ -133,6 +133,7 @@ export class MetamaskPage implements WalletPage { isClosePage = false, ) { await test.step(`Add new network "${networkName}"`, async () => { + await this.navigate(); await this.networkList.addNetworkManually( networkName, networkUrl, @@ -140,8 +141,8 @@ export class MetamaskPage implements WalletPage { tokenSymbol, blockExplorer, ); + if (isClosePage) await this.page.close(); }); - if (isClosePage) await this.page.close(); } async addPopularNetwork(networkName: string) { @@ -154,7 +155,6 @@ export class MetamaskPage implements WalletPage { await test.step(`Add popular network "${networkName}"`, async () => { await this.networkList.networkDisplayCloseBtn.click(); await this.networkList.addPopularNetwork(networkName); - await this.popoverElements.switchToButton.click(); }); } await this.page.close(); diff --git a/packages/wallets/src/metamask/pages/elements/networkList.element.ts b/packages/wallets/src/metamask/pages/elements/networkList.element.ts index 485fee15..51a3384f 100644 --- a/packages/wallets/src/metamask/pages/elements/networkList.element.ts +++ b/packages/wallets/src/metamask/pages/elements/networkList.element.ts @@ -122,7 +122,19 @@ export class NetworkList { .locator('../../..') .locator('button:has-text("Add")') .click(); + // Without awaiting the button is not clickable + await this.page.waitForTimeout(500); await new PopoverElements(this.page).approveAddNetworkButton.click(); + await this.dialogSection.waitFor({ state: 'hidden' }); + // Need to wait while the network to be added to the wallet + try { + await this.page + .getByText('Connecting to') + .waitFor({ state: 'visible', timeout: 5000 }); + await this.page.getByText('Connecting to').waitFor({ state: 'hidden' }); + } catch { + console.error('Connecting network was without loader'); + } }); } }