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.
@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
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?
Mirroring the state of one of your existing Chrome Profiles in Puppeteer can prove extremely useful for local projects and testing.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With