Puppeteer browser automation

Updated 1 month ago by Annes Silde

Related articles

Puppeteer is a library for Node.js that provides an opportunity to automate processes with a Chromium-based browser through high-level API over the Chrome DevTools Protocol. For example, you can create web crawlers that search and collect data by using the Mimic browser with masked fingerprints.

Multilogin port allocation

In Multilogin, you need to predefine the application port in order to utilize Puppeteer automation. Here is how you can predefine the Multilogin port:

  1. Go to the C:\Users\%username%\ directory and open the file
  2. Add the following string: multiloginapp.port=[PORT_NUMBER]
The port number has to be in the range of 10000 to 49151.
  1. Save the file

For more detailed instructions and different OS, check this guide. Thereafter, you will be able to refer to the Multilogin application through this port.

How to start

Step 1

Make sure that you have Node.js and npm package manager installed on your PC. Node.js and npm can be downloaded from the official Node.js website (the latest versions of Node.js include npm by default). Alternatively, you can use yarn for Node.js packages management.

You can check the version of your Node.js and npm by executing the following commands in the terminal:

nodejs -v || node -v && npm -v
Step 2

Create a new npm project in current directory.

npm init -y
This command will create a package.json file and a -y parameter allows to skip the questionnaire and create a project with default settings.
Step 3

Install Puppeteer-core in the project directory.

npm install [email protected] --save
Certain Puppeteer-core versions are only compatible with certain Chromium versions. Currently, (starting from Multilogin version Mimic uses Chromium 93, which is compatible with Puppeteer-core version 10.2.0
Previous version compatibility:

Chromium 90 (starting from Multilogin version 5.16.2)

Puppeteer-core 8.0.0

Chromium 87 (starting from Multilogin version 5.12)

Puppeteer-core 5.4.1

Step 4

Create a .js file with your automation code. Please use the following code example for reference:

const puppeteer = require('puppeteer-core');
const http = require('http');

async function startProfile(){
//Replace profileId value with existing browser profile ID.
let profileId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
let mlaPort = 35000;

/*Send GET request to start the browser profile by profileId.
Returns web socket as response which should be passed to puppeteer.connect*/
http.get(`${mlaPort}/api/v1/profile/start?automation=true&puppeteer=true&profileId=${profileId}`, (resp) => {
let data = '';
let ws = '';

//Receive response data by chunks
resp.on('data', (chunk) => {
data += chunk;

/*The whole response data has been received. Handling JSON Parse errors,
verifying if ws is an object and contains the 'value' parameter.*/
resp.on('end', () => {
let ws;
try {
ws = JSON.parse(data);
} catch(err) {
if (typeof ws === 'object' && ws.hasOwnProperty('value')) {
console.log(`Browser websocket endpoint: ${ws.value}`);

}).on("error", (err) => {

async function run(ws) {
//Connecting Puppeteer with Mimic instance and performing simple automation.
const browser = await puppeteer.connect({browserWSEndpoint: ws, defaultViewport:null});
const page = await browser.newPage();
await page.goto('');
await page.screenshot({ path: `/home/${process.env.USER}/Desktop/multiloginScreenshot.png` });
await browser.close();
} catch(err){


Step 5

Launch the .js file through the terminal in order to start your automation script.

nodejs example.js

Videos on the topic

Check out our latest news, research and tutorials

Was this article helpful?