简体   繁体   中英

Is there any way to call a function in JavaScript multiple times at once? Using puppeteer

A website is developed using Reactjs, which interacts with ethereum smart contract in the backend.

This smart contract requires one chrome extension (metamask) for transaction.

Now while using puppeteer it runs in the chromium where chrome extensions aren't available.

Also I wanna run this contract in parallel. That means it runs same contract multiple times at once in order to know how much time will it take to get the result when many users at once are using that website.

  1. Is there any to way to load chrome extensions in puppeteer?
  2. How to run that javascript file multiple times at once?

Loading Extensions

Discussed here , You can use --disable-extensions-except to enable only the extensions that you want to test:

var options = {
  headless: false,
  args: [
    '--disable-extensions-except=/path/to/extension/',
    '--load-extension=/path/to/extension/',
  ]
}

For loading multiple chrome extensions, you can pass a comma-seperated list;

var options = {
  headless: false,
  args: [
    '--disable-extensions-except=/path/to/ext1/, /path/to/ext2/, /path/to/ext3/'
  ]
}

Note, it will not work in headless mode, nor you can automate the extensions themselves.

Multiple times at once?

You can create multiple pages/tabs with same metamask, or create different browser sessions to keep things seperate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM