playwright-go icon indicating copy to clipboard operation
playwright-go copied to clipboard

Documentation doesn't seem to shed light on using the local chrome driver most users have installed instead of downloading it.

Open dracoDevs opened this issue 2 years ago • 1 comments

I did see a push referencing the "local chrome path" pull request but I cannot tell the difference when I run the code it still's installs the playwright-md files.

I want to be able to use my installation of chrome as a driver not what the package wants to install.

dracoDevs avatar Feb 01 '23 06:02 dracoDevs

_, b := os.LookupEnv("PLAYWRIGHT_BROWSERS_PATH")
	if !b {
		err = os.Setenv("PLAYWRIGHT_BROWSERS_PATH", dir+"/tools/browser/")
		if err != nil {
			log.Errorln("set env PLAYWRIGHT_BROWSERS_PATH fail" + err.Error())
			err = nil
		}
	}
pwo := &playwright.RunOptions{
		DriverDirectory:     dir + "/tools/driver/",
		SkipInstallBrowsers: true,
		Browsers:            []string{"msedge"},
	}

pwt, err := playwright.Run(pwo)
	if err != nil {
		log.Errorln("[core]", "init the playwright fail")
		log.Errorln("[core] ", err.Error())

		return
	}
if path == "" {
		path = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
	}

browser, err := pwt.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
		ExecutablePath:  playwright.String(path),
	})

You can customize the location of the browser by setting ExecutablePath, and set SkipInstallBrowsers to determine whether to skip downloading the browser. If you need to download the browser, you can use the environment variable PLAYWRIGHT_BROWSERS_PATH to set the location of the browser download,my roommate's playwright-go version is v0.2000.1.

you can see https://playwright.bootcss.com/docs/installation?_highlight=playwright_browsers_path#managing-browser-binaries

huoxue1 avatar Mar 10 '23 03:03 huoxue1

Refer https://playwright.dev/docs/browsers#google-chrome--microsoft-edge and #340

browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
		Channel: playwright.String("chrome"),
	})

canstand avatar Mar 22 '24 06:03 canstand