chrome-launcher
chrome-launcher copied to clipboard
How to automate non-default profile dynamically?
If chrome is launched with Profile 1
:
await launch({
userDataDir: <PROFILE_NAME>, // `Profile 1`
})
Can we execute an event on Profile 2
?
Maybe a better question is what kind of boundary is this profile boundary? I can launch with Profile 1
, then manually switch profiles to Profile 2
. If so, is there a way to do the same from code? Maybe something via devtools protocol?
https://vanilla.aslushnikov.com/?Target.createBrowserContext is kinda similar but not
you currently can't dynamically change what profile is being used by chrome. or launch a new chrome window with a diff profile folder.
the chrome binary must be relaunched.
Follow up: Can I launch chrome binary with multiple profiles? And then switch between them. Assuming no.
Can I launch chrome binary with multiple profiles
well.. you can use any user-data-dir. and a single user-data-dir can contain multiple profiles. but there is a default profile. and it will use that one.
and yah.. you can't change it (or open a new window using a diff one) using any automated way. the devtools protocol doesnt deal with stuff like that.
Ah! That's helpful. Thanks for the details @paulirish.
Hey @paulirish I was able to create a proof-of-concept that is able to run multiple profiles without relaunching the binary. Please take a look at this issue: https://github.com/GoogleChrome/puppeteer/issues/4966
I am very interested in this POC
Hey @paulirish Were you able to reproduce this issue on your side as well? Let me know if there's something I am overlooking here.
Hey @paulirish Could we reopen the issue now that we have a working POC for this? Or should I open a new issue for this?
POC https://gist.github.com/VikramTiwari/9fe97f990d17ada231dee35eea128480
key bit: --profile-directory='Profile 1'
@VikramTiwari question on this.... why do you want to use secondary profiles? obviously both Lh and PPTR are happier if you just use the Default profile on separate userDataDirs.. is that too annoying for your usecase?
That's true. For my use-case however, I am trying to use PPTR on users's existing userDataDir
(to get around auth etc). This causes challenge because we can't break user's existing chrome profiles functionality by cloning/moving directories etc. This makes sense?