playwright-community / playwright-go

Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.
https://playwright-community.github.io/playwright-go/
MIT License
1.94k stars 144 forks source link

firefox 中的识别问题 #357

Closed zouxingyuks closed 10 months ago

zouxingyuks commented 11 months ago

firefox 中的 FirefoxUserPrefs 如果使用的 network.proxy.http_port 对应的interface是 string 会报错,但报错信息十分令人迷惑 复现代码

FirefoxUserPrefs: map[string]any{
            "security.cert_pinning. enforcement_level":    0,
            "security.tls.version.min":                    1,
            "network.stricttransportsecurity.preloadlist": false,
            "network.proxy.type":                          1,
            "network.proxy.http":                          p.Host, // 将此处替换为你的Proxy PAC文件的URL
            "network.proxy.http_port":                     "8080",
            //"network.proxy.ssl":                           proxyUrl,
            //"network.proxy.socket":                        proxyUrl,
        },
<launching> C:\Users\Anubis.LXFPIIYOMOVFWTV\AppData\Local\ms-playwright\firefox-1408
\firefox\firefox.exe -no-remote -wait-for-browser -foreground -profile C:\Users\Anub
is.LXFPIIYOMOVFWTV\AppData\Local\Temp\playwright_firefoxdev_profile-Xyxath -juggler-
pipe -silent
<launched> pid=27928
[pid=27928][out] console.warn: services.settings: Ignoring preference override of re
mote settings server
[pid=27928][out] console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTIN
GS_DEVTOOLS=1 in the environment
[pid=27928][out] console.error: ({})
[pid=27928][out]
[pid=27928][out] Juggler listening to the pipe
[pid=27928][out] console.error: "Warning: unrecognized command line flag -wait-for-b
rowser\n"
[pid=27928][out]
[pid=27928][out]         ERROR: Component returned failure code: 0x8000ffff (NS_ERRO
R_UNEXPECTED) [nsIPrefBranch.setStringPref] Browser.enable@chrome://juggler/content/
protocol/BrowserHandler.js:41:24
[pid=27928][out]
canstand commented 11 months ago

报错信息来自服务端(https://github.com/microsoft/playwright ),与 playwright-go 客户端无关。 (The error message comes from the server (https://github.com/microsoft/playwright) and has nothing to do with the playwright-go client.)

如果只是想配置代理,用如下参数直接配置: (If you just want to configure the proxy, configure it directly with the following parameters: )

    browser, err := pw.Firefox.Launch(playwright.BrowserTypeLaunchOptions{
        Proxy: &playwright.Proxy{
            Server: playwright.String("http://127.0.0.1:8080"),
        },
    })

如果要配置 PAC 地址或其它选项,先自己在firefox里配置好,然后在浏览器的 about:config 界面勾选仅显示修改过的首选项查看实际保存在哪个配置项,以及对应的类型是 string/number/boolean 哪一种。 (If you want to configure the PAC URL or other options, first configure them in firefox, and then check Only display modified preferences in the about:config interface of the browser to see which configuration item is actually saved. )