Description
Rod Version: v0.116.2
With previous versions of Chrome, the following code opened up Chrome with the correct current user session, with the correct extensions etc.
func main() {
wsURL := launcher.NewUserMode().Bin("/run/current-system/sw/bin/google-chrome-stable").MustLaunch()
browser := rod.New().ControlURL(wsURL).MustConnect().NoDefaultDevice()
browser.MustPage().MustNavigate("https://www.wikipedia.org/")
}
Using a recent version of Chrome causes the code to crash with the error:
panic: [launcher] Failed to get the debug url:
DevTools remote debugging requires a non-default data directory. Specify this using --user-data-dir.
[58064:58094:0517/110139.708314:ERROR:content/browser/browser_main_loop.cc:278] GLib: g_main_context_pop_thread_default: assertion 'stack != NULL' failed
goroutine 1 [running]:
github.com/go-rod/rod/lib/utils.init.func2({0x806280?, 0xc000122060?})
/home/andrew/go/pkg/mod/github.com/go-rod/[email protected]/lib/utils/utils.go:68 +0x1d
github.com/go-rod/rod/lib/utils.E(...)
/home/andrew/go/pkg/mod/github.com/go-rod/[email protected]/lib/utils/utils.go:74
github.com/go-rod/rod/lib/launcher.(*Launcher).MustLaunch(0xc00019ee00?)
/home/andrew/go/pkg/mod/github.com/go-rod/[email protected]/lib/launcher/launcher.go:401 +0x6f
main.main()
/home/andrew/Code/gener8/main.go:12 +0x6e
exit status 2
This is almost certainly to do with: https://developer.chrome.com/blog/remote-debugging-port
Furthermore, giving a user data directory like the following:
func main() {
wsURL := launcher.NewUserMode().Bin("/run/current-system/sw/bin/google-chrome-stable").UserDataDir("./chrome-user-data").MustLaunch()
browser := rod.New().ControlURL(wsURL).MustConnect().NoDefaultDevice()
browser.MustPage().MustNavigate("https://www.wikipedia.org/")
}
causes the browser to load but the point of NewUserMode is now in conflict with a blank user data directory.
Copying the user's data directory, in my case "/home/andrew/.config/google-chrome/Default" to the program folder, renaming it to "chrome-user-data" and running the above code again yields the same result. The browser loads (with headless as false) but does not seem to load with the user session/settings e.g. no extensions.