diff --git a/wallets/keplr/src/KeplrWallet.ts b/wallets/keplr/src/KeplrWallet.ts index 412f85a70..f9567a834 100644 --- a/wallets/keplr/src/KeplrWallet.ts +++ b/wallets/keplr/src/KeplrWallet.ts @@ -32,8 +32,8 @@ export class KeplrWallet { return wallet; } - async getWalletAddress() { - const walletAddress = await this.homePage.getWalletAddress() + async getWalletAddress(wallet: string) { + const walletAddress = await this.homePage.getWalletAddress(wallet) return walletAddress; } } diff --git a/wallets/keplr/src/fixtures/keplrFixtures.ts b/wallets/keplr/src/fixtures/keplrFixtures.ts index 6a3bb7aa0..efa2e9b12 100644 --- a/wallets/keplr/src/fixtures/keplrFixtures.ts +++ b/wallets/keplr/src/fixtures/keplrFixtures.ts @@ -80,6 +80,7 @@ export const keplrFixtures = (walletSetup: ReturnType, _keplrPage = context.pages()[0] as Page await _keplrPage.goto(`chrome-extension://${extensionId}/popup.html`) + await unlockForFixtures(_keplrPage, PASSWORD) await use(context) diff --git a/wallets/keplr/src/pages/HomePage/actions/getWalletAddress.ts b/wallets/keplr/src/pages/HomePage/actions/getWalletAddress.ts index 76b8af67c..0d08acfe4 100644 --- a/wallets/keplr/src/pages/HomePage/actions/getWalletAddress.ts +++ b/wallets/keplr/src/pages/HomePage/actions/getWalletAddress.ts @@ -1,14 +1,12 @@ import type { Page } from '@playwright/test'; import { homePageElements } from '../selectors'; -export const getWalletAddress = async (page: Page) => { +export const getWalletAddress = async (page: Page, wallet: string) => { await page.waitForLoadState('domcontentloaded'); - const newTokensFoundSelector = await page.waitForSelector(homePageElements.newTokensFoundSelector); - if (newTokensFoundSelector) { - await page.waitForSelector(homePageElements.newTokensFoundSelector); - } - await page.waitForSelector(homePageElements.copyAddress); - const walletAddress = await page.click(homePageElements.copyAddress); - console.log('Wallet address copied', walletAddress); - return walletAddress; + await page.getByText(homePageElements.copyAddress).click(); + const chain = await page.waitForSelector(homePageElements.walletSelectors(wallet)); + chain.click(); + await page.context().grantPermissions(['clipboard-read', 'clipboard-write']); + const clipboardText = await page.evaluate(() => navigator.clipboard.readText()); + return clipboardText; } \ No newline at end of file diff --git a/wallets/keplr/src/pages/HomePage/page.ts b/wallets/keplr/src/pages/HomePage/page.ts index adb05d15e..1a3864bd3 100644 --- a/wallets/keplr/src/pages/HomePage/page.ts +++ b/wallets/keplr/src/pages/HomePage/page.ts @@ -16,8 +16,8 @@ export class HomePage { return await getTokenAmount(this.page, 'token name') } - async getWalletAddress() { - return await getWalletAddress(this.page) + async getWalletAddress(wallet: string) { + return await getWalletAddress(this.page, wallet) } async addNewTokensFound() { diff --git a/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/actions/acceptAccess.ts b/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/actions/acceptAccess.ts deleted file mode 100644 index d225ebf37..000000000 --- a/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/actions/acceptAccess.ts +++ /dev/null @@ -1,13 +0,0 @@ - -import { notificationPageElements } from '../selectors'; - -export const acceptAccess = async () => { - console.log('Accepting access in Keplr wallet', notificationPageElements); - // const notificationPage = await playwright.switchToKeplrNotification(); - // await playwright.waitAndClick( - // notificationPageElements.approveButton, - // notificationPage, - // { waitForEvent: 'close' }, - // ); - // return true; -} diff --git a/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/actions/confirmAccess.ts b/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/actions/confirmAccess.ts deleted file mode 100644 index 9aa5b9586..000000000 --- a/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/actions/confirmAccess.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { notificationPageElements } from "../selectors"; - -export const confirmTransaction = async () => { - console.log('Confirming transaction in Keplr wallet', notificationPageElements) - // const notificationPage = await playwright.switchToKeplrNotification(); - // await playwright.waitAndClick( - // notificationPageElements.approveButton, - // notificationPage, - // { waitForEvent: 'close' }, - // ); - return true; - } \ No newline at end of file diff --git a/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/actions/index.ts b/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/actions/index.ts deleted file mode 100644 index 0c7179ffc..000000000 --- a/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/actions/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './acceptAccess'; -export * from './confirmAccess'; \ No newline at end of file diff --git a/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/page.ts b/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/page.ts deleted file mode 100644 index 1182e8090..000000000 --- a/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/page.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { Page } from '@playwright/test' -import { notificationPageElements } from './selectors' -import { confirmTransaction, acceptAccess } from './actions' - -export class NotificationPage { - static readonly selectors = notificationPageElements - readonly selectors = notificationPageElements - - readonly page: Page - - constructor(page: Page) { - this.page = page - } - - async confirmTransaction() { - await confirmTransaction() - } - - async acceptAccess() { - await acceptAccess() - } -} diff --git a/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/selectors/index.ts b/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/selectors/index.ts deleted file mode 100644 index f247584b8..000000000 --- a/wallets/keplr/src/pages/HomePage/selectors/NotificationPage/selectors/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const notificationPageElements = { - approveButton: 'button', - copyAddress: 'Copy Address', - walletSelectors: (chainName: string) => `img[alt="${chainName}"]`, -}; \ No newline at end of file diff --git a/wallets/keplr/src/pages/HomePage/selectors/index.ts b/wallets/keplr/src/pages/HomePage/selectors/index.ts index 73e1f7e38..b23ee90fc 100644 --- a/wallets/keplr/src/pages/HomePage/selectors/index.ts +++ b/wallets/keplr/src/pages/HomePage/selectors/index.ts @@ -5,5 +5,6 @@ export const homePageElements = { newTokensFound: 'new token(s) found', addChainsButton: 'Add Chains', newTokensFoundSelector: 'text=new token(s) found', + walletSelectors: (chainName: string) => `img[alt="${chainName}"]`, copyAddress: 'Copy Address', } \ No newline at end of file diff --git a/wallets/keplr/src/pages/LockPage/selectors/index.ts b/wallets/keplr/src/pages/LockPage/selectors/index.ts index 51bf03d63..af731d18e 100644 --- a/wallets/keplr/src/pages/LockPage/selectors/index.ts +++ b/wallets/keplr/src/pages/LockPage/selectors/index.ts @@ -4,7 +4,7 @@ export const onboardingElements = { useRecoveryPhraseButton: 'Use recovery phrase or private key', createNewRecoveryPhraseButton: 'Create new recovery phrase', showMyPhraseButton: 'I understood. Show my phrase.', - copyToClipboardButton: 'Copy to clipboard', + copyToClipboardButton: 'Copy Address', nextButton: 'Next', focusedInput: 'input:focus', phrasePrivateKey: 'Private key', diff --git a/wallets/keplr/test/playwright/getAddress.spec.ts b/wallets/keplr/test/playwright/getAddress.spec.ts index 0ac88330e..f5dfaf68f 100644 --- a/wallets/keplr/test/playwright/getAddress.spec.ts +++ b/wallets/keplr/test/playwright/getAddress.spec.ts @@ -3,6 +3,8 @@ import synpress from '../synpress' const test = synpress +const { expect } = test + // test('should import wallet', async ({ keplr }) => { // try { // await keplr.setupWallet({ secretWordsOrPrivateKey: SEED_PHRASE, password: PASSWORD }) @@ -13,7 +15,9 @@ const test = synpress test('should create address', async ({ keplr }) => { try { - await keplr.getWalletAddress() + const address = await keplr.getWalletAddress('Cosmos Hub') + console.log('Address:', address) + expect(address).toContain('cosmos') } catch (error) { console.error('Error:', error) }