Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Error: waitForXPath failed while using the setupMetaMask function #355

Open
LuCrypto opened this issue Feb 16, 2024 · 2 comments
Open

Error: waitForXPath failed while using the setupMetaMask function #355

LuCrypto opened this issue Feb 16, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@LuCrypto
Copy link

Describe the bug

When i use setupMetaMask of dappeteer, my code just crash
I want to automate metamask !

To Reproduce

Try this code for reproduce

import dotenv from 'dotenv'
dotenv.config()

import dappeteer from '@chainsafe/dappeteer';

console.log('dappeteer: ', dappeteer)

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function main() {

  let browser;
  let metamask;

  browser = await dappeteer.launch({
    headless: false,
    metaMaskVersion: "v11.0.0",
    defaultViewport: null,
    automation: "puppeteer",
  })

  metamask = await dappeteer.setupMetaMask(browser, {
    seed: process.env.SEED,
    password: process.env.PASSWORD
  })
}

main();

Logs

/home/lucrypto/Documents/code/scroll-automate/node_modules/@chainsafe/dappeteer/dist/puppeteer/page.js:73
        return new elements_1.DPuppeteerElementHandle((await this.page.waitForXPath(xpath, opts)));
                                                                       ^

TypeError: this.page.waitForXPath is not a function
    at DPupeteerPage.waitForXPath (/home/lucrypto/Documents/code/scroll-automate/node_modules/@chainsafe/dappeteer/dist/puppeteer/page.js:73:72)
    at getElementByContent (/home/lucrypto/Documents/code/scroll-automate/node_modules/@chainsafe/dappeteer/dist/helpers/selectors.js:5:71)
    at clickOnElement (/home/lucrypto/Documents/code/scroll-automate/node_modules/@chainsafe/dappeteer/dist/helpers/actions.js:51:45)
    at importAccount (/home/lucrypto/Documents/code/scroll-automate/node_modules/@chainsafe/dappeteer/dist/setup/setupActions.js:41:40)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.setupMetaMask (/home/lucrypto/Documents/code/scroll-automate/node_modules/@chainsafe/dappeteer/dist/setup/setupMetaMask.js:33:9)
    at async file:///home/lucrypto/Documents/code/scroll-automate/src/index.js:25:18

Expected behavior

I want to automate metamask, and for that i would like to use this repo
But if you have a better solution, im clearly open for any suggestion !

System:

  • OS: Ubuntu
  • OS version Ubuntu 20.04.6 LTS
  • NodeJs version : v20.10.0
  • dappeteer version 5.2.1
  • testing framework puppeteer
  • testing framework version 22.0.0
  • puppeteer version 22.0.0 (the same)
  • playwright version not used

Thanks in advance for your help !

@LuCrypto LuCrypto added the bug Something isn't working label Feb 16, 2024
@0xFNDS
Copy link

0xFNDS commented Feb 19, 2024

Downgrade Puppeteer to 21.6.1

@LuCrypto
Copy link
Author

Ok thanks it resolved waitForXPath problem

But it still doesn't seem to work

I have this error

TimeoutError: Waiting for selector `.//label[contains(.,'New password')]/following-sibling::textarea|//label[contains(.,'New password')]/following-sibling::*//input|//h6[contains(.,'New password')]/parent::node()/parent::node()/following-sibling::input|//h6[contains(.,'New password')]/parent::node()/parent::node()/following-sibling::*//input|//span[contains(.,'New password')]/parent::node()/parent::node()/following-sibling::*//input|//span[contains(.,'New password')]/following-sibling::*//input` failed: Waiting failed: 1000ms exceeded

It crashes when it goes to metamask page

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants