使用“remote-debugging-port”标志调试 Chrome 实例

问题描述 投票:0回答:3

我尝试按照https://chromedevtools.github.io/devtools-protocol/上的基础知识:使用 DevTools 作为协议客户端中描述的步骤进行操作。我使用

google-chrome --remote-debugger-port=9222
启动了两个 Chrome 实例 和
google-chrome --user-data-dir=/home/whatever/Desktop/chrome/
。之后,我导航到
http://127.0.0.1:9222/
,但收到“无法访问此网站”错误页面。

如果我使用

google-chrome --headless --remote-debugging-port=9222
启动 Chrome,那么当我导航到
http://127.0.0.1:9222/
时,我可以看到“Inspectable WebContents”和指向空白页面的链接。

有人知道为什么

remote-debugging-port
标志仅适用于无头实例吗?据我所知,它应该是双向的。

注意:我尝试的是能够使用

connect
方法在 Chorme 实例上使用 Puppeteer (https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerconnectoptions )。

google-chrome google-chrome-devtools puppeteer
3个回答
12
投票

问题是

user-data-dir=

您可以指向您当前的配置文件目录,这可能会导致一些问题。 如果没有这个参数,调试就不会开始。

在 Windows 上,您可以这样启动:

C:\>"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe " --remote-debugging-port=9222 --user-data-dir=/temp'

从新版本开始,不要再看

http://localhost:9222/

正确的方法是打开新窗口并加载

chrome://inspect

任何调试实例都会显示在设备列表下。


9
投票

我设法通过启动 chrome 使其正常工作,如下所示:

google-chrome --remote-debugging-port=9222 --user-data-dir=/home/whatever/Desktop/chrome/


0
投票

尝试忽略空白页和首次访问

http://localhost:9222/json

然后从 JSON 检查 devtoolsFrontendUrl 并转到

http://localhost:9222/

我写了一篇关于如何设置 Chrome 远程调试的文章,其中涵盖了此修复https://devforth.io/blog/chrome-remote-debugging-setup/

© www.soinside.com 2019 - 2024. All rights reserved.