N
N
Nikolai2020-01-14 21:14:06
JavaScript
Nikolai, 2020-01-14 21:14:06

How to run puppeteer in chrome with different user (profile)?

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://web.telegram.org/');
  await page.screenshot({path: 'example.png'});

  await browser.close();
})();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai, 2020-01-15
Demidovets

So far I have stopped at this:
1. Create profiles in the browser.
2. We are looking for a directory where they are stored in files.
3. In the profile folder, create the Default folder.
4. Transfer the contents of the profile folder to the Default folder.
5. Specify the path to the profile in args.
Example in Chrome on Ubuntu:

const browser = await puppeteer.launch({args:['--user-data-dir=/home/rut/.config/google-chrome/Profile 1']});
const page = await browser.newPage();
await page.goto('https://google.ru/');
await page.screenshot({path: 'google.png'});
await browser.close();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question