diff --git a/packages/wallets/src/metamask/metamask.page.ts b/packages/wallets/src/metamask/metamask.page.ts index be88c37a..9c848cd7 100644 --- a/packages/wallets/src/metamask/metamask.page.ts +++ b/packages/wallets/src/metamask/metamask.page.ts @@ -207,7 +207,10 @@ export class MetamaskPage implements WalletPage { .toString() .trim(); if (tokenNameFromValue === tokenName) { - tokenBalance = parseFloat(await value.textContent()); + await value.click(); + tokenBalance = parseFloat( + await this.homePage.tokensListItemValues.textContent(), + ); break; } } diff --git a/packages/wallets/src/okx/okx.page.ts b/packages/wallets/src/okx/okx.page.ts index 1748be18..1ee3e552 100644 --- a/packages/wallets/src/okx/okx.page.ts +++ b/packages/wallets/src/okx/okx.page.ts @@ -83,8 +83,6 @@ export class OkxPage implements WalletPage { /** Checks the is installed the needed network and add new network to wallet (if needed) */ async setupNetwork(standConfig: Record) { await test.step(`Setup "${standConfig.chainName}" Network`, async () => { - await this.navigate(); - await this.homePage.networkListButton.click(); await this.addNetwork( standConfig.chainName, standConfig.rpcUrl, @@ -182,6 +180,12 @@ export class OkxPage implements WalletPage { timeout: 10000, }); await operationPage.connectButton.click(); + // need wait the page to be closed after the extension is connected + await new Promise((resolve) => { + operationPage.page.on('close', () => { + resolve(); + }); + }); await test.step('Sync the dApp network with wallet', async () => { await this.navigate(); @@ -257,6 +261,16 @@ export class OkxPage implements WalletPage { }); } + /** Get wallet address from wallet extension*/ + async getWalletAddress() { + return await test.step('Get current wallet address', async () => { + await this.navigate(); + const address = await this.homePage.getWalletAddress(); + await this.page.close(); + return address; + }); + } + // need realize for mainnet async openLastTxInEthplorer(txIndex = 0) { console.error( diff --git a/packages/wallets/src/okx/pages/home.page.ts b/packages/wallets/src/okx/pages/home.page.ts index c5508819..8b86da0d 100644 --- a/packages/wallets/src/okx/pages/home.page.ts +++ b/packages/wallets/src/okx/pages/home.page.ts @@ -3,6 +3,7 @@ import { Locator, Page, test } from '@playwright/test'; export class HomePage { page: Page; accountListButton: Locator; + copyAddressButton: Locator; settingButton: Locator; networkListButton: Locator; manageCryptoButton: Locator; @@ -10,6 +11,10 @@ export class HomePage { constructor(page: Page) { this.page = page; this.accountListButton = this.page.locator('image[alt="wallet-avatar"]'); + this.copyAddressButton = this.page + .getByTestId('okd-select-reference-value-box') + .locator('../../div') + .first(); this.settingButton = this.page .getByTestId('okd-select-reference-value-box') .locator('div') @@ -82,4 +87,13 @@ export class HomePage { // need wait some time to correct network install await this.page.waitForTimeout(2000); } + + async getWalletAddress() { + await this.copyAddressButton.click(); + return await this.page + .locator('span:has-text("address copied")') + .locator('../span') + .nth(1) + .textContent(); + } }