Due to the request from the community for "plugins", this is one experimentation approach to it. It will not be covered by the test and the wound not provides support, so use it at your own risk.
Usages Example
It is recommended to use typescript.
import dappeteer from '@chainsafe/dappeteer';
import puppeteer from 'puppeteer-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth';
import {DPuppeteerBrowser} from "@chainsafe/dappeteer/dist/puppeteer";
async function main() {
const { metaMask, browser } = await dappeteer.bootstrap({
automation: "custom",
customAutomation: async (metamaskPath, userDataDir, options) => {
puppeteer.use(StealthPlugin());
const browser = puppeteer.launch({
userDataDir,
args: [
`--disable-extensions-except=${metamaskPath}`,
`--load-extension=${metamaskPath}`,
],
});
return DPuppeteerBrowser(browser, userDataDir, options.metaMaskFlask);
},
});
// create a new page and visit your dapp
const dappPage = await browser.newPage();
await dappPage.goto('http://my-dapp.com');
// you can change the network if you want
await metaMask.switchNetwork('goerli');
// do something in your dapp that prompts MetaMask to add a Token
const addTokenButton = await dappPage.$('#add-token');
await addTokenButton.click();
// instruct MetaMask to accept this request
await metaMask.acceptAddToken();
// do something that prompts MetaMask to confirm a transaction
const payButton = await dappPage.$('#pay-with-eth');
await payButton.click();
// š
await metaMask.confirmTransaction();
}
main();
Due to the request from the community for "plugins", this is one experimentation approach to it. It will not be covered by the test and the wound not provides support, so use it at your own risk.
Usages Example
It is recommended to use typescript.