dappeteer
dappeteer copied to clipboard
RPC Error: User rejected the request. Object code: 4001 message: "User rejected the request." [[Prototype]]: Object
Describe the bug MetaMask - RPC Error: User rejected the request. Object code: 4001 message: "User rejected the request." [[Prototype]]: Object To Reproduce
Steps to reproduce the behavior: const browser = await dappeteer.launch(puppeteer, {headless: false, metamaskVersion: 'v10.8.1', defaultViewport: null, args: ['--start-maximized'] }); const metamask = await dappeteer.setupMetamask(browser,{seed: "bla bla"}); await metamask.addNetwork({networkName: "Avalanche Network",rpc: "https://api.avax.network/ext/bc/C/rpc",chainId: "43114",symbol: "AVAX", explorer : "https://snowtrace.io/"}) await metamask.switchNetwork('Avalanche Network') await metamask.addToken('blabla')
const page = await browser.newPage()
await page.goto('https://website.com')
await sleep(3000)
await page.waitForXPath('//*[@id="root"]/div/div/section/main/div[1]/div[1]/a/div/div');
var originSelector = await page.$x('//*[@id="root"]/div/div/section/main/div[1]/div[1]/a/div/div');
await originSelector[0].click();
await page.waitForXPath('/html/body/div[2]/div/div[2]/div/div[2]/div/div/div[2]/button');
var connectWallet = await page.$x('/html/body/div[2]/div/div[2]/div/div[2]/div/div/div[2]/button');
await connectWallet[0].click();
await sleep(3000)
await metamask.confirmTransaction();
console.log("Connected wallet")
Expected behavior pop up shown and confirm and connect website.
Is there any fixed for this problem ?
https://github.com/MetaMask/metamask-extension/pull/12643
I am also facing this bug
I am also facing this bug
You have to call await metamask.approve();
after clicking the connect wallet button
hmm .. having the same problem . I tried the approve, but no luck
+1, same problem.
Metamask popup is immediately closed with:
MetaMask - RPC Error: User rejected the request. Object code: 4001 message: "User rejected the request."
Anyone get any resolution with this?
Well the only way I solved it was to try catch the timeout
try {
await metamask.confirmTransaction();
await metamask.approve()
} catch {
console.error("Metamask selector timeout")
}
Sucks only that its 30 sec and then it continues
Struggling with the same issue when using Jest + Dappeteer.
What is interesting, when a new test suite is run, the Metamask pop-ups work correctly. They only break right after the extension & account init.
I struggled with this issue too and I found that it happens because there is a browser "targetcreated" event who listen to creation of "
async function closeNotificationPage(browser: puppeteer.Browser): Promise<void> {
browser.on('targetcreated', async target => {
if (target.url().match('chrome-extension://[a-z]+/notification.html')) {
try {
const page = await target.page()
await page.close()
} catch {
return
}
}
})
}
This should be solved by #181