chromedp 无法启动 chrome 的新实例

chromedp fails to start a new instance of chrome

大家好,我一直在尝试使用 chromedp 在我的浏览器机器上自动执行任务。

我尝试了 repo 上的示例,但它们总是失败:

unexpected fault address 0x7f7a36461000 fatal error: fault [signal SIGBUS: bus error code=0x2 addr=0x7f7a36461000 pc=0x53a9d5]

示例的源代码是 运行 可以找到 here

据我所知,chromedp 附带 chrome 的无头预编译版本。我浏览了 API 文档以查看是否可以传递开发工具正在侦听的端口,但没有成功。

然而,当我尝试 mafredri/cdp 时,它起作用了。我开始了解到 chromedp 无法启动其嵌入式 chrome。虽然,我不太确定。为什么会这样?

我的环境:

Google Chrome 85.0.4183.102

Ubuntu 18.04.4 LTS

go version go1.13.5 linux/amd64

任何帮助将不胜感激。

所以,长话短说,我通过 go test 对 chromedp 本地安装的库进行了 运行 测试,但失败了。我打开了an issue on the Github repo。虽然没有指明它需要 Go 1.14+,但确实如此。

如果您遇到此问题,请先 运行 在本地安装的库的 master 分支上进行测试。如果失败并显示以下日志:

github.com/chromedp/chromedp [github.com/chromedp/chromedp.test] ./chromedp_test.go:862:3: t.Cleanup undefined (type *testing.T has no field or method Cleanup) ./chromedp_test.go:948:5: t.Cleanup undefined (type *testing.T has no field or method Cleanup) ./chromedp_test.go:950:5: t.Cleanup undefined (type *testing.T has no field or method Cleanup) FAIL github.com/chromedp/chromedp [build failed]

您需要知道 t.Cleanup 是在 Go 1.14 中添加的(感谢 Oiyoo)。

如果您遇到同样的问题,我希望这对您有所帮助。