nish17
nish17

Reputation: 43

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?

Upvotes: 3

Views: 411

Answers (1)

Md. Abu Taher
Md. Abu Taher

Reputation: 18826

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.

Upvotes: 2

Related Questions