ChainSafe / dappeteer

[DEPRECATED]🏌🏼‍E2E testing for dApps using Puppeteer + MetaMask
Other
491 stars 152 forks source link

how to select Language #212

Closed gpBlockchain closed 1 year ago

gpBlockchain commented 1 year ago

commit:2d86a6d Describe the problem I can't use it, because my metaMesk language is Chinese,how do I change the language of metamask

image
npm run test

> @chainsafe/dappeteer@3.0.0 test
> mocha

(node:12908) DeprecationWarning: Configuration via mocha.opts is DEPRECATED and will be removed from a future version of Mocha. Use RC files or package.json instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

  dappeteer
Starting ganache...
Ganache running at http://localhost:8545
Starting test server...
Server running at http://localhost:8080
Deploying test contract...
web3-shh package will be deprecated in version 1.3.5 and will no longer be supported.
web3-bzz package will be deprecated in version 1.3.5 and will no longer be supported.
Contract deployed at 0x0fC7E4bD0784Af9b444015557CDBdA05d9D4D46e
path: /Users/guopenglin/test/e2e/dappeteer/test/dapp/data.js

Running tests on MetaMask version v10.15.0

    1) "before all" hook for "should be deployed, contract"

  0 passing (34s)
  1 failing

  1) dappeteer
       "before all" hook for "should be deployed, contract":
     TimeoutError: waiting for XPath `//button[contains(text(), 'Get Started')]` failed: timeout 30000ms exceeded
      at new WaitTask (node_modules/puppeteer/src/common/DOMWorld.ts:813:28)
      at DOMWorld.waitForXPath (node_modules/puppeteer/src/common/DOMWorld.ts:702:22)
      at Frame.waitForXPath (node_modules/puppeteer/src/common/FrameManager.ts:1327:47)
      at Page.waitForXPath (node_modules/puppeteer/src/common/Page.ts:3281:29)
      at getElementByContent (src/helpers/selectors.ts:5:8)
      at /Users/guopenglin/test/e2e/dappeteer/src/helpers/actions.ts:33:43
      at Generator.next (<anonymous>)
      at /Users/guopenglin/test/e2e/dappeteer/src/helpers/actions.ts:8:71
      at new Promise (<anonymous>)
      at __awaiter (src/helpers/actions.ts:4:12)
      at clickOnButton (src/helpers/actions.ts:32:80)
      at /Users/guopenglin/test/e2e/dappeteer/src/setup/setupActions.ts:22:22
      at Generator.next (<anonymous>)
      at /Users/guopenglin/test/e2e/dappeteer/src/setup/setupActions.ts:8:71
      at new Promise (<anonymous>)
      at __awaiter (src/setup/setupActions.ts:4:12)
      at confirmWelcomeScreen (src/setup/setupActions.ts:24:12)
      at Object.<anonymous> (src/setup/setupMetamask.ts:23:11)
      at Generator.next (<anonymous>)
      at fulfilled (src/setup/setupMetamask.ts:5:58)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
BeroBurny commented 1 year ago

Issues are with browser preferences, try to switch the system to English till the issue is resolved.

BeroBurny commented 1 year ago

anyone who is going to take over a task needs to add one of these args (found best fitted for it)

https://peter.sh/experiments/chromium-command-line-switches/#accept-lang https://peter.sh/experiments/chromium-command-line-switches/#lang https://peter.sh/experiments/chromium-command-line-switches/#override-language-detection

Lykhoyda commented 1 year ago

@gpBlockchain thank you for your question. To change the language you have to provide an accept-lang argument to puppeteer and playwright options during the initial bootstrap method call:


await dappeteer.bootstrap({
      .... // other parameters,
      playwrightOptions: {
        args: ["--accept-lang=en"],
      },
      puppeteerOptions: {
        args: ["--accept-lang=en"],
      },
    });