4

I'm using Geb (Selenium & Webdrivers 3.40) with Chrome 60 on Windows 7 Enterprise.

My GebConfig.groovy defines a chrome environment that configures Chrome with the following start arguments --headless --disable-gpu --disable-plugins --enable-logging --v=1.

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
        }
    }
}

According to this post Chrome should log to ~/.config/google-chrome but after running my Geb tests I cannot find any log on that path. I'm trying to enable the log since I have trouble connecting a internal website using HTTPS and I need more information on what is going wrong.

Can you tell me how to enable the log correctly and where I can find Google Chromes log output?

Update 1:

According to this documentation the log is saved under %LOCALAPPDATA%\Google\Chrome\User Data\chrome_debug.log. I found that log but its empty. Since I cannot seem to connect over SSL I wonder how I can get Chrome to tell me where the problem lies. Any ideas?

Update 2:

It seems that whenever I ran the tests in --headless mode and accessing an internal HTTPS URL I get the following Dummy HTML from the Web Driver.

<!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>

In the servers log I cannot see any incoming HTTP request. Does anyone know such a behaviour?

saw303
  • 8,051
  • 7
  • 50
  • 90
  • First verify manually that the log works. Because I doubt it logs https and other details. Also the log file is `chrome_debug.log` created in the profile directory. Refer to https://www.chromium.org/for-testers/enable-logging – Tarun Lalwani Aug 15 '17 at 07:52
  • I am unable to find the chrome_debug.log file when using headless mode. Did you face the same issue? – Phani Apr 12 '18 at 13:44

2 Answers2

4

According to this page, the logging depends on the platform:

On Linux:

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

On Windows:

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

I've tested on Linux and it works fine.

The logs are saved on the Chrome's user data directory.

Cyril N.
  • 38,875
  • 36
  • 142
  • 243
0

I think your last parameter should be

'--enable-logging=v=1'

Combining the two.

Also the debug log I find is in the application install directory.

C:\Program Files (x86)\Google\Chrome\Application\<chrome version>

called

chrome_debug.log
Dan
  • 1,450
  • 1
  • 17
  • 34
  • 2
    Does not work for me. The following documentation states it as follows > To enable logging, launch Chrome with these command line flags: > `--enable-logging --v=1` https://www.chromium.org/for-testers/enable-logging – saw303 Aug 15 '17 at 10:34
  • On windows these are the command line switches for chrom which work for me; chrome --enable-logging --v=1 --headless --disable-gpu --dump-dom https://www.some-url.com/ – Dan Aug 15 '17 at 10:47
  • Can you try adding it as one argument without the = ? so '--enable-logging --v=4' – Dan Aug 15 '17 at 10:50
  • Where does `--dump-dom some-url.com` dumps the DOM to? – saw303 Aug 15 '17 at 11:00
  • To stdout although you can save the dom to a file by adding '> filename.html' to the end. That will save it in the chrome executing directory, so the same folder as I added to my answer. – Dan Aug 15 '17 at 12:12
  • On Chrome 63, when using these logging options on normal Chrome, it logs to a file in the user application data directory, but when using headless mode, it writes it to stderr instead. – reduckted Jan 23 '18 at 01:32
  • @reduckted: Have you been able to solve this issue? I also find that in headless mode, it is writing to stderr and I am unable to capture that when using Selenium. Any hints will be appreciated. – Phani Apr 12 '18 at 13:42
  • @Phani I don't think so, no. I was running Chrome locally via a command prompt, and was able to see the stderr output, so I didn't look any further into it. – reduckted Apr 13 '18 at 10:00