Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use chrome profile in puppeteer

I am unable to use specific profile in Puppeteer. It always open the chrome as a new user.

For example: I have 3 profiles for my chrome. Following is the code I am using to open chrome in specific profile:

const browser = await puppeteer.launch({
    headless: false,
    executablePath: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
    // args: ['--profile-directory="Profile 1"'],
    userDataDir:"C:\\Users\\USER_NAME\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 1"
  });

But it always open the chrome as "Current user" profile.

like image 432
nbi Avatar asked Nov 10 '18 06:11

nbi


People also ask

How do I run puppeteer against stable chrome?

@lucasteisseire in order to run puppeteer against stable chrome, you should do the following: Figure the version of your stable chrome installation (in your stable chrome, navigate to about:version) Figure out matching Puppeteer version in our api.md

How to get the profile path of puppeteer?

So you can input the path to your userDataDir as part of the puppeteer launch parameters. Look for profile path by executing chrome://version in your browser. Doing this, puppeteer executed itself in the same chrome window that I am currently using. Sorry, something went wrong. @ashminbhandari puppeteer-core or puppeteer?

Can I Mirror a chrome profile in puppeteer?

Mirroring the state of one of your existing Chrome Profiles in Puppeteer can prove extremely useful for local projects and testing.

How to get WebSocket debug url in puppet?

What you need to do is (1) Start new chrome windows with remote-debugging flag so that you can get webSocketDebuggerUrl. You should get new Chrome window and some logs from Terminal. (2) Then in your puppeteer js file, copy websocket url (ws) from Terminal and put in your js file.


1 Answers

Try below code:

const browser = await puppeteer.launch({headless:false, args:[
'--user-data-dir=/user/data/directory/profile_n']
});

Full explanation is given here:

In Puppeteer how to switch to chrome window from default profile to desired profile

like image 125
Govinda Avatar answered Sep 28 '22 08:09

Govinda