Chrome 60 启用无头模式下的日志记录



我在Windows 7 Enterprise上使用Geb(Selenium和Webdrivers 3.40(和Chrome 60。

我的GebConfig.groovy定义了一个chrome环境,该环境使用以下启动参数--headless --disable-gpu --disable-plugins --enable-logging --v=1来配置 Chrome

environments {
chrome {
ChromeDriverManager.instance.setup()
driver = {
ChromeOptions options = new ChromeOptions()
options.addArguments('--headless', '--disable-gpu', '--disable-plugins', '--enable-logging', '--v=1')
def capabilities = DesiredCapabilities.chrome()
capabilities.setCapability(ChromeOptions.CAPABILITY, options)
def driver = new ChromeDriver(capabilities)
return driver
}
}
}

根据这篇文章,Chrome 应该登录到~/.config/google-chrome但是在运行我的 Geb 测试后,我找不到该路径上的任何日志。我正在尝试启用日志,因为我在使用HTTPS连接内部网站时遇到问题,并且我需要有关出现问题的更多信息。

你能告诉我如何正确启用日志以及在哪里可以找到谷歌浏览器日志输出吗?

更新 1:

根据此文档,日志保存在%LOCALAPPDATA%GoogleChromeUser Datachrome_debug.log下。我找到了那个日志,但它是空的。 由于我似乎无法通过SSL连接,因此我想知道如何让Chrome告诉我问题出在哪里。有什么想法吗?

更新 2:

似乎每当我以--headless模式运行测试并访问内部 HTTPS URL 时,我都会从 Web 驱动程序获得以下虚拟 HTML。

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<pre style="word-wrap: break-word; white-space: pre-wrap;"></pre><iframe name="chromedriver dummy frame" src="about:blank"></iframe>
</body>
</html>

在服务器日志中,我看不到任何传入的HTTP请求。有谁知道这样的行为?

根据此页面,日志记录取决于平台:

在 Linux 上:

--enable-logging=stderr --v=1

在视窗上:

--enable-logging --v=1
--enable-logging=stderr --v=1 > log.txt 2>&1  # Seems to capture more output

我已经在 Linux 上测试过,它工作正常。

日志保存在 Chrome 的用户数据目录中。

我认为您的最后一个参数应该是

'--enable-logging=v=1'

将两者结合起来。

我找到的调试日志也在应用程序安装目录中。

C:Program Files (x86)GoogleChromeApplication<chrome version>

chrome_debug.log

最新更新