diff --git a/commands/keplr.js b/commands/keplr.js index eb8a86029..ab40e2bc5 100644 --- a/commands/keplr.js +++ b/commands/keplr.js @@ -359,9 +359,22 @@ const keplr = { ); const innerTexts = await parentElement.allInnerTexts(); const textArray = innerTexts[0].split('\n'); - const tokenValue = Number(textArray[3]); - await playwright.switchToCypressWindow(); + let numberString; + for (const element of textArray) { + const elementWithNoCommas = element.replace(/,/g, ''); + if (!isNaN(parseFloat(elementWithNoCommas))) { + numberString = elementWithNoCommas; + break; + } + } + + if (!numberString) { + throw new Error(`Token value for ${tokenName} not found`); + } + + let tokenValue = parseFloat(numberString); + await playwright.switchToCypressWindow(); return tokenValue; }, }; diff --git a/tests/e2e/specs/keplr/keplr-spec.js b/tests/e2e/specs/keplr/keplr-spec.js index 0592b1096..9eed9e107 100644 --- a/tests/e2e/specs/keplr/keplr-spec.js +++ b/tests/e2e/specs/keplr/keplr-spec.js @@ -87,10 +87,13 @@ describe('Keplr', () => { }); cy.addNewTokensFound(); cy.getTokenAmount('ATOM').then(tokenValue => { - expect(tokenValue).to.equal(0); + expect(Number.isFinite(tokenValue)).to.be.true; }); cy.getTokenAmount('BLD').then(tokenValue => { - expect(tokenValue).to.equal(331); + expect(Number.isFinite(tokenValue)).to.be.true; + }); + cy.getTokenAmount('IST').then(tokenValue => { + expect(Number.isFinite(tokenValue)).to.be.true; }); }); it(`should disconnect the wallet from all the connected DAPPs`, () => {