Replies: 2 comments 1 reply
-
Hey @kwdikeman, I will implement adding a custom token this week. Cheers! |
Beta Was this translation helpful? Give feedback.
1 reply
-
I got it to work. I'm not sure why but by creating a new page and using
that descriptor it could not see the form elements. I pulled the elements
out and treated it as if the main page was the target.
KD
…On Wed, Apr 6, 2022 at 1:29 PM drptbl ***@***.***> wrote:
Hey @kwdikeman <https://github.com/kwdikeman>, I will implement adding a
custom token this week. Cheers!
—
Reply to this email directly, view it on GitHub
<#359 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AW5CN5YVKAEGD2S2HWIN35DVDXXZXANCNFSM5Q2R35PQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Does/has anyone extended the metamask commands to support the adding of custom tokens (add-token)?
I'm starting this task but am getting hung at the input of the add-token page. What am I missing?
What I've done so far:
`// Add Custom Token Page
const importTokensPage='.add-token';
const input=
${importTokensPage} #custom-address
;const inputTokenName=
${importTokensPage} #custom-symbol
;const inputTokenDecimals=
${importTokensPage} #custom-decimals
;const cancelButton=
${importTokensPage} .btn-default
;const nextTokenPage=
${importTokensPage} .btn-primary
;module.exports.tokenPageElements = {
input,
inputTokenName,
inputTokenDecimals,
cancelButton,
nextTokenPage,
};
// Confirm Add Token Page
const confirmImportTokenPage='.confirm-add-token';
const confirmTokenAdd=
${confirmImportTokenPage} .btn-secondary
;module.exports.confirmTokenPageElements = {
confirmTokenAdd,
}`
Added code to command.js
// Add Custom Token Cypress.Commands.add('addCustomToken', (tokenAddress) => { return cy.task('addCustomToken', {tokenAddress} ); });
Added code to plugins.js
addCustomToken: async tokenAddress => { const added = await metamask.importToken(tokenAddress); return added; },
Added code to metamask.js
`// Add Custom Token
importToken: async tokenAddress => {
await switchToMetamaskIfNotActive();
await puppeteer.waitFor(mainPageElements.importToken.button);
if (tokenAddress) {
await puppeteer.waitAndType(tokenPageElements.input, tokenAddress);
await puppeteer.waitAndClick(tokenPageElements.nextTokenPage);
await puppeteer.waitFor(confirmTokenPageElements.confirmTokenAdd)
await puppeteer.waitAndClick(confirmTokenPageElements.confirmTokenAdd);
}
return true;
},`
Beta Was this translation helpful? Give feedback.
All reactions