chromedp / chromedp

A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't multiple chrome use the same user-data-dir at the same time?

imblowsnow opened this issue · comments

What versions are you running?

$ go list -m github.com/chromedp/chromedp
github.com/chromedp/chromedp v0.9.5
$ google-chrome --version
121.0.6167.161 (正式版本) (64 位) (cohort: Stable) 
$ go version
go version go1.21.3 windows/amd64

What did you do? Include clear steps.

       opts := buildOptions(ChromiumOptions{
		Url:         "http://www.google.com",
		UserDataDir: GetCurrentBrowserFlagDir("default"),
	})

	ctx, cancel := chromedp.NewExecAllocator(context.Background(), opts...)
	defer cancel()

	// log the protocol messages to understand how it works.
	ctx, cancel = chromedp.NewContext(ctx)
	defer cancel()

	// create a timeout
	ctx, cancel = context.WithCancel(ctx)
	defer cancel()

	// navigate to a page, wait for an element, click
	err := chromedp.Run(ctx)

	if err != nil {
		log.Fatal(err)
	}

	err2 := chromedp.Run(ctx)

	if err2 != nil {
		log.Fatal(err2)
	}

	select {}

What did you expect to see?

I want to use the same user-data-dir

What did you see instead?

When I started the second window when I used the same user data directory, I found that he made a error.

chrome failed to start:
�������е��������Ự�д򿪡�

@imblowsnow No, you would not be able to start two separate parent processes using the same data dir. You can use chromedp, however to open additional tabs or windows from the primary chromedp.Context returned from chromedp.NewContext. This is a limitation of Chrome, and not of chromedp.