Multiple Browser Contexts using CDP

206 views
Skip to first unread message

Mor Amrani

unread,
Dec 4, 2022, 8:39:34 AM12/4/22
to devtools-dev
Hello,

Is there a way to create multiple persistent profiles/Browser Contexts using CDP?
Target.createBrowserContext method description indicates that the new browser context is similar to an Incognito one and this is well represented by the code:


Is there a reason for not using regular profiles?
Is there a plan to support this?

Thanks,
Mor

Paul Irish

unread,
Dec 5, 2022, 4:07:59 PM12/5/22
to Mor Amrani, devtools-dev
You can use existing profile folders using --profile-directory (assuming --user-data-dir also points somewhere existing). More: https://github.com/GoogleChrome/chrome-launcher/issues/172#issuecomment-555277231

AFAIK you cannot create/select Chrome profiles over CDP.

This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.

--
You received this message because you are subscribed to the Google Groups "devtools-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to devtools-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/devtools-dev/a951f686-bf44-455f-83f5-f151f9060de5n%40chromium.org.

Mor Amrani

unread,
Dec 13, 2022, 4:31:23 AM12/13/22
to devtools-dev, Paul, devtools-dev, Mor Amrani
Thank you Paul, this is very helpful!

I have managed to use multiple profiles with the same browser process when running headful. However, this doesn't work for me when running headless.
Is it fair to say that the browser must be launched in headful mode in order to use the --profile-directory option?

Mor Amrani

unread,
Aug 3, 2026, 3:21:04 AM (yesterday) Aug 3
to devtools-dev, Mor Amrani, Paul, devtools-dev

Hi,

Checking here again as it's been nearly 4 years since this was discussed :)

Are there any plans or a roadmap for natively managing persistent browser contexts over CDP?
Currently, Target.createBrowserContext remains strictly incognito. If we want to manage multiple persistent profiles using CDP, the only way is to spawn separate Chrome instances for every profile via --user-data-dir. This adds significant process overhead. Having a protocol-level way in CDP to dynamically create or load to a persistent profile directory on a single running browser instance would be hugely beneficial.

Yang Guo

unread,
Aug 3, 2026, 3:25:04 AM (yesterday) Aug 3
to Mor Amrani, devtools-dev, Paul
Hi Mor,

CDP is not a public API. We made decisions on extending it based on requirements of our supported products, not based on public feature requests.

Cheers,

Yang

To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/devtools-dev/9f742feb-e1fe-46db-956c-7b51ab6726dcn%40chromium.org.

--
You received this message because you are subscribed to the Google Groups "devtools-googlers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to devtools-googl...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/devtools-googlers/9f742feb-e1fe-46db-956c-7b51ab6726dcn%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.
Reply all
Reply to author
Forward
0 new messages