sclevine / agouti

A WebDriver client and acceptance testing library for Go
MIT License
818 stars 105 forks source link

Support headless Google Chrome (and Chromium) #109

Open johanbrandhorst opened 7 years ago

johanbrandhorst commented 7 years ago

Headless Chrome is now built-in with Chrome 59 on Linux and Mac and from Chrome 60 on Windows. Seems like a great alternative to chromedriver, if it could be integrated. https://developers.google.com/web/updates/2017/04/headless-chrome this page contains more information, but I haven't been able to determine whether it supports the WebDriver protocol.

johanbrandhorst commented 7 years ago

I think this is already possible today actually!

I managed to run the following successfully:

agoutiDriver = agouti.ChromeDriver(
    agouti.ChromeOptions("args", []string{"--headless", "--disable-gpu"}),
)
Expect(agoutiDriver.Start()).NotTo(HaveOccurred())
johanbrandhorst commented 7 years ago

Reopening this as it appears enabling headless chrome via the parameters above triggers page.Navigate to hang forever. Removing the ChromeOptions makes it work again. Not sure this is on agoutis end but thought it'd be worth mentioning here for discussion.

sclevine commented 7 years ago

Any interesting output with agouti.Debug?

johanbrandhorst commented 7 years ago

I tried it again this morning and instead of hanging now it seems to not find my elements before timing out, so it doesn't seem to be an agouti problem after all. I think I'll close this again, thanks.

johanbrandhorst commented 7 years ago

Sorry, I need to reopen this, it's definitely still happening and I'm just seeing the following:

Starting ChromeDriver 2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57) on port 42129
Only local connections are allowed.

It blocks on the first page.Navigate call. I'm still not sure this is an agouti problem but I think it'll be worthwhile tracking. These are my Driver settings:

agoutiDriver = agouti.ChromeDriver(
    // Unfortunately headless doesn't seem to work quite yet,
    // seems lock up loading the page.
    // (tried Google Chrome 59.0.3071.115)
    // https://developers.google.com/web/updates/2017/04/headless-chrome#drivers
    agouti.ChromeOptions("args", []string{
        "--headless",
        "--disable-gpu",
    }),
    agouti.Debug,
)

agoutiDriver.Start() seems to return happily enough.

sclevine commented 7 years ago

I looked into the briefly today. The --headless and --disable-gpu options are options for Chrome, but I'm not sure what they do when passed to ChromeDriver. You could run Chrome directly with those options, but I don't think that provides the WebDriver API.

I think there are two options:

  1. Point ChromeDriver at Chrome somehow? Maybe this is already happening? See: https://github.com/nightwatchjs/nightwatch/issues/1439
  2. Use headless chrome via Selenium (via agouti.Selenium)
johanbrandhorst commented 7 years ago

Hm, I might try and change the "binary" option to ChromeDriver and see what that does. I thought Chromedriver would use chrome automatically and was just some translation layer but I might be wrong.

johanbrandhorst commented 7 years ago

Running with

agouti.ChromeOptions(
    "args", []string{
        "--headless",
        "--disable-gpu",
    },
),
agouti.ChromeOptions(
    "binary", "/usr/bin/google-chrome-stable",
),

Results in the same locking up.

DanielJonesEB commented 7 years ago

For my sins, I've been trying to automate the Concourse/OAuth GitHub dance, and I'm encountering the same issue.

I've run chromedriver myself as an external process, so I can see the verbose logs. I've then told Agouti to connect to that instance, rather than trying to manage the process itself.

    BeforeEach(func() {
        var err error
        //Expect(agoutiDriver).ToNot(BeNil())
        page, err = agouti.NewPage("http://localhost:9515", agouti.Debug, agouti.Desired(agouti.Capabilities{
            "chromeOptions": map[string][]string{
                "args": []string{
                    "--headless",
                    "--disable-gpu",
                    "--no-sandbox",
                },
            },
        }))
        Expect(err).NotTo(HaveOccurred())
    })

    AfterEach(func() {
        Expect(page.Destroy()).To(Succeed())
    })

    It("does the needful", func() {
        Expect(page.Navigate("https://SNIP/auth/github?team_name=cf-ops&fly_local_port=52086")).To(Succeed())
    })
MacOS $ chromedriver --version
ChromeDriver 2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262)
MacOS $ chromedriver --verbose
Starting ChromeDriver 2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262) on port 9515
Only local connections are allowed.
[57.522][INFO]: COMMAND InitSession {
   "desiredCapabilities": {
      "acceptSslCerts": true,
      "chromeOptions": {
         "args": [ "--headless", "--disable-gpu", "--no-sandbox" ]
      }
   }
}
[57.523][INFO]: Populating Preferences file: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "show_welcome_page": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[57.523][INFO]: Populating Local State file: {
   "background_mode": {
      "enabled": false
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   }
}
[57.525][INFO]: Launching chrome: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-gpu --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-automation --enable-logging --force-fieldtrials=SiteIsolationExtensions/Control --headless --ignore-certificate-errors --load-component-extension=/var/folders/fl/vb5mf5b1011778j59q6wrc0h0000gn/T/.org.chromium.Chromium.Hyu23t/internal --log-level=0 --metrics-recording-only --no-first-run --no-sandbox --password-store=basic --remote-debugging-port=12364 --safebrowsing-disable-auto-update --test-type=webdriver --use-mock-keychain --user-data-dir=/var/folders/fl/vb5mf5b1011778j59q6wrc0h0000gn/T/.org.chromium.Chromium.ZnpcnW data:,
[57.525][DEBUG]: DevTools request: http://localhost:12364/json/version
[57.526][DEBUG]: DevTools request failed
[57.577][DEBUG]: DevTools request: http://localhost:12364/json/version
[57.577][DEBUG]: DevTools request failed
[0714/115646.759965:WARNING:dns_config_service_posix.cc(154)] dns_config has unhandled options!
[57.627][DEBUG]: DevTools request: http://localhost:12364/json/version
[57.628][DEBUG]: DevTools response: {
   "Browser": "HeadlessChrome/59.0.3071.115",
   "Protocol-Version": "1.2",
   "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/59.0.3071.115 Safari/537.36",
   "V8-Version": "5.9.211.38",
   "WebKit-Version": "537.36 (@3cf8514bb1239453fd15ff1f7efee389ac9df8ba)"
}

[57.629][DEBUG]: DevTools request: http://localhost:12364/json
[57.629][DEBUG]: DevTools response: [ {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:12364/devtools/page/80f44e68-3034-4c78-aef9-e3b669389152",
   "id": "80f44e68-3034-4c78-aef9-e3b669389152",
   "title": "",
   "type": "page",
   "url": "data:,",
   "webSocketDebuggerUrl": "ws://localhost:12364/devtools/page/80f44e68-3034-4c78-aef9-e3b669389152"
} ]

[57.629][DEBUG]: DevTools request: http://localhost:12364/json
[57.630][DEBUG]: DevTools response: [ {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:12364/devtools/page/80f44e68-3034-4c78-aef9-e3b669389152",
   "id": "80f44e68-3034-4c78-aef9-e3b669389152",
   "title": "",
   "type": "page",
   "url": "data:,",
   "webSocketDebuggerUrl": "ws://localhost:12364/devtools/page/80f44e68-3034-4c78-aef9-e3b669389152"
} ]

[57.631][INFO]: resolved localhost to ["::1","127.0.0.1"]
[57.631][DEBUG]: DEVTOOLS COMMAND Log.enable (id=1) {

}
[57.632][DEBUG]: DEVTOOLS COMMAND DOM.getDocument (id=2) {

}
[57.632][DEBUG]: DEVTOOLS COMMAND Runtime.enable (id=3) {

}
[57.632][DEBUG]: DEVTOOLS COMMAND Page.enable (id=4) {

}
[57.632][DEBUG]: DEVTOOLS COMMAND Page.enable (id=5) {

}
[57.634][DEBUG]: DEVTOOLS RESPONSE Log.enable (id=1) {

}
[57.634][DEBUG]: DEVTOOLS RESPONSE DOM.getDocument (id=2) {
   "root": {
      "backendNodeId": 1,
      "baseURL": "",
      "childNodeCount": 1,
      "children": [ {
         "attributes": [  ],
         "backendNodeId": 2,
         "childNodeCount": 2,
         "children": [ {
            "attributes": [  ],
            "backendNodeId": 3,
            "childNodeCount": 0,
            "localName": "head",
            "nodeId": 3,
            "nodeName": "HEAD",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 2
         }, {
            "attributes": [  ],
            "backendNodeId": 4,
            "childNodeCount": 0,
            "localName": "body",
            "nodeId": 4,
            "nodeName": "BODY",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 2
         } ],
         "frameId": "1834.1",
         "localName": "html",
         "nodeId": 2,
         "nodeName": "HTML",
         "nodeType": 1,
         "nodeValue": "",
         "parentId": 1
      } ],
      "documentURL": "",
      "localName": "",
      "nodeId": 1,
      "nodeName": "#document",
      "nodeType": 9,
      "nodeValue": "",
      "xmlVersion": ""
   }
}
[57.634][DEBUG]: DEVTOOLS RESPONSE Runtime.enable (id=3) {

}
[57.634][DEBUG]: DEVTOOLS RESPONSE Page.enable (id=4) {

}
[57.634][DEBUG]: DEVTOOLS RESPONSE Page.enable (id=5) {

}
[57.634][DEBUG]: DEVTOOLS COMMAND Page.enable (id=6) {

}
[57.639][DEBUG]: DEVTOOLS EVENT Runtime.executionContextsCleared {

}
[57.639][DEBUG]: DEVTOOLS EVENT Page.frameNavigated {
   "frame": {
      "id": "1834.1",
      "loaderId": "1834.1",
      "mimeType": "text/plain",
      "securityOrigin": "://",
      "url": "data:,"
   }
}
[57.639][DEBUG]: DEVTOOLS EVENT DOM.documentUpdated {

}
[57.639][DEBUG]: DEVTOOLS COMMAND DOM.getDocument (id=7) {

}
[57.639][DEBUG]: DEVTOOLS EVENT Runtime.executionContextCreated {
   "context": {
      "auxData": {
         "frameId": "1834.1",
         "isDefault": true
      },
      "id": 1,
      "name": "",
      "origin": "://"
   }
}
[57.640][DEBUG]: DEVTOOLS RESPONSE Page.enable (id=6) {

}
[57.640][DEBUG]: DEVTOOLS RESPONSE DOM.getDocument (id=7) {
   "root": {
      "backendNodeId": 5,
      "baseURL": "data:,",
      "childNodeCount": 1,
      "children": [ {
         "attributes": [  ],
         "backendNodeId": 6,
         "childNodeCount": 2,
         "children": [ {
            "attributes": [  ],
            "backendNodeId": 7,
            "childNodeCount": 0,
            "localName": "head",
            "nodeId": 7,
            "nodeName": "HEAD",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 6
         }, {
            "attributes": [  ],
            "backendNodeId": 8,
            "childNodeCount": 1,
            "localName": "body",
            "nodeId": 8,
            "nodeName": "BODY",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 6
         } ],
         "frameId": "1834.1",
         "localName": "html",
         "nodeId": 6,
         "nodeName": "HTML",
         "nodeType": 1,
         "nodeValue": "",
         "parentId": 5
      } ],
      "documentURL": "data:,",
      "localName": "",
      "nodeId": 5,
      "nodeName": "#document",
      "nodeType": 9,
      "nodeValue": "",
      "xmlVersion": ""
   }
}
[57.640][DEBUG]: DEVTOOLS COMMAND Runtime.enable (id=8) {

}
[57.641][DEBUG]: DEVTOOLS EVENT Page.loadEventFired {
   "timestamp": 47221.837322
}
[57.641][DEBUG]: DEVTOOLS EVENT Page.frameStoppedLoading {
   "frameId": "1834.1"
}
[57.641][DEBUG]: DEVTOOLS EVENT Page.domContentEventFired {
   "timestamp": 47221.837515
}
[57.641][DEBUG]: DEVTOOLS EVENT DOM.documentUpdated {

}
[57.641][DEBUG]: DEVTOOLS COMMAND DOM.getDocument (id=9) {

}
[57.642][DEBUG]: DEVTOOLS RESPONSE Runtime.enable (id=8) {

}
[57.642][DEBUG]: DEVTOOLS RESPONSE DOM.getDocument (id=9) {
   "root": {
      "backendNodeId": 5,
      "baseURL": "data:,",
      "childNodeCount": 1,
      "children": [ {
         "attributes": [  ],
         "backendNodeId": 6,
         "childNodeCount": 2,
         "children": [ {
            "attributes": [  ],
            "backendNodeId": 7,
            "childNodeCount": 0,
            "localName": "head",
            "nodeId": 11,
            "nodeName": "HEAD",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 10
         }, {
            "attributes": [  ],
            "backendNodeId": 8,
            "childNodeCount": 1,
            "localName": "body",
            "nodeId": 12,
            "nodeName": "BODY",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 10
         } ],
         "frameId": "1834.1",
         "localName": "html",
         "nodeId": 10,
         "nodeName": "HTML",
         "nodeType": 1,
         "nodeValue": "",
         "parentId": 9
      } ],
      "documentURL": "data:,",
      "localName": "",
      "nodeId": 9,
      "nodeName": "#document",
      "nodeType": 9,
      "nodeValue": "",
      "xmlVersion": ""
   }
}
[57.642][DEBUG]: DEVTOOLS COMMAND Runtime.evaluate (id=10) {
   "expression": "(function() { // Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum f...",
   "returnByValue": true
}
[57.647][DEBUG]: DEVTOOLS RESPONSE Runtime.evaluate (id=10) {
   "result": {
      "type": "object",
      "value": {
         "status": 0,
         "value": 1
      }
   }
}
[57.647][INFO]: RESPONSE InitSession {
   "acceptSslCerts": true,
   "applicationCacheEnabled": false,
   "browserConnectionEnabled": false,
   "browserName": "chrome",
   "chrome": {
      "chromedriverVersion": "2.30.477690 (c53f4ad87510ee97b5c3425a14c0e79780cdf262)",
      "userDataDir": "/var/folders/fl/vb5mf5b1011778j59q6wrc0h0000gn/T/.org.chromium.Chromium.ZnpcnW"
   },
   "cssSelectorsEnabled": true,
   "databaseEnabled": false,
   "handlesAlerts": true,
   "hasTouchScreen": false,
   "javascriptEnabled": true,
   "locationContextEnabled": true,
   "mobileEmulationEnabled": false,
   "nativeEvents": true,
   "networkConnectionEnabled": false,
   "pageLoadStrategy": "normal",
   "platform": "Mac OS X",
   "rotatable": false,
   "takesHeapSnapshot": true,
   "takesScreenshot": true,
   "~~~": "..."
}
[57.648][INFO]: COMMAND Navigate {
   "url": "https://ci.SNIP.io/auth/github?team_name=cf-ops&fly_local_port=52086"
}
[57.648][INFO]: Waiting for pending navigations...
[57.648][DEBUG]: DEVTOOLS COMMAND Runtime.evaluate (id=11) {
   "expression": "1"
}
[57.649][DEBUG]: DEVTOOLS RESPONSE Runtime.evaluate (id=11) {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[57.649][INFO]: Done waiting for pending navigations. Status: ok
[57.649][DEBUG]: DEVTOOLS COMMAND Page.navigate (id=12) {
   "url": "https://ci.SNIP.io/auth/github?team_name=cf-ops&fly_local_port=52086"
}
[357.649][SEVERE]: Timed out receiving message from renderer: 299.999
[357.649][INFO]: Waiting for pending navigations...
[357.649][DEBUG]: DEVTOOLS COMMAND Runtime.evaluate (id=13) {
   "expression": "1"
}
[357.649][SEVERE]: Timed out receiving message from renderer: -0.000
[357.649][INFO]: Timed out. Stopping navigation...
[357.649][DEBUG]: DEVTOOLS COMMAND Runtime.evaluate (id=14) {
   "expression": "window.stop();",
   "returnByValue": true
}
[357.655][DEBUG]: DEVTOOLS RESPONSE Page.navigate (id=12) {
   "frameId": "1834.1"
}
[357.656][DEBUG]: DEVTOOLS COMMAND Runtime.evaluate (id=15) {
   "expression": "document.URL"
}
[357.656][DEBUG]: DEVTOOLS RESPONSE Runtime.evaluate (id=13) {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[357.656][DEBUG]: DEVTOOLS RESPONSE Runtime.evaluate (id=14) {
   "result": {
      "type": "undefined"
   }
}
[357.656][SEVERE]: Timed out receiving message from renderer: -0.007
[357.656][DEBUG]: DEVTOOLS COMMAND Runtime.evaluate (id=16) {
   "expression": "1"
}
[357.656][SEVERE]: Timed out receiving message from renderer: -0.008
[357.656][INFO]: Done waiting for pending navigations. Status: timeout
[357.656][INFO]: RESPONSE Navigate timeout
  (Session info: headless chrome=59.0.3071.115)
[357.662][INFO]: COMMAND FindElements {
   "using": "id",
   "value": "login_field"
}
[357.662][DEBUG]: DEVTOOLS RESPONSE Runtime.evaluate (id=15) {
   "result": {
      "type": "string",
      "value": "data:,"
   }
}
[357.662][DEBUG]: DEVTOOLS RESPONSE Runtime.evaluate (id=16) {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[357.662][INFO]: Waiting for pending navigations...
[357.662][DEBUG]: DEVTOOLS COMMAND Runtime.evaluate (id=17) {
   "expression": "1"
}
[357.674][DEBUG]: DEVTOOLS RESPONSE Runtime.evaluate (id=17) {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[357.674][DEBUG]: DEVTOOLS COMMAND DOM.getDocument (id=18) {

}
[357.675][DEBUG]: DEVTOOLS RESPONSE DOM.getDocument (id=18) {
   "root": {
      "backendNodeId": 5,
      "baseURL": "data:,",
      "childNodeCount": 1,
      "children": [ {
         "attributes": [  ],
         "backendNodeId": 6,
         "childNodeCount": 2,
         "children": [ {
            "attributes": [  ],
            "backendNodeId": 7,
            "childNodeCount": 0,
            "localName": "head",
            "nodeId": 15,
            "nodeName": "HEAD",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 14
         }, {
            "attributes": [  ],
            "backendNodeId": 8,
            "childNodeCount": 1,
            "localName": "body",
            "nodeId": 16,
            "nodeName": "BODY",
            "nodeType": 1,
            "nodeValue": "",
            "parentId": 14
         } ],
         "frameId": "1834.1",
         "localName": "html",
         "nodeId": 14,
         "nodeName": "HTML",
         "nodeType": 1,
         "nodeValue": "",
         "parentId": 13
      } ],
      "documentURL": "data:,",
      "localName": "",
      "nodeId": 13,
      "nodeName": "#document",
      "nodeType": 9,
      "nodeValue": "",
      "xmlVersion": ""
   }
}
[357.675][DEBUG]: DEVTOOLS COMMAND Runtime.evaluate (id=19) {
   "expression": "var isLoaded = document.readyState == 'complete' ||    document.readyState == 'interactive';if (isLoaded) {  var frame = document.createElement('iframe');  frame.name = 'chromedriver dummy frame'; ..."
}
[357.680][DEBUG]: DEVTOOLS EVENT DOM.childNodeCountUpdated {
   "childNodeCount": 2,
   "nodeId": 16
}
[357.680][DEBUG]: DEVTOOLS EVENT Page.frameAttached {
   "frameId": "1834.2",
   "parentFrameId": "1834.1",
   "stack": {
      "callFrames": [ {
         "columnNumber": 240,
         "functionName": "",
         "lineNumber": 0,
         "scriptId": "30",
         "url": ""
      } ]
   }
}
[357.680][DEBUG]: DEVTOOLS EVENT Page.frameStartedLoading {
   "frameId": "1834.2"
}
[357.680][DEBUG]: DEVTOOLS EVENT Page.frameNavigated {
   "frame": {
      "id": "1834.2",
      "loaderId": "1834.2",
      "mimeType": "text/html",
      "name": "chromedriver dummy frame",
      "parentId": "1834.1",
      "securityOrigin": "://",
      "url": "about:blank"
   }
}
[357.680][DEBUG]: DEVTOOLS EVENT Runtime.executionContextCreated {
   "context": {
      "auxData": {
         "frameId": "1834.2",
         "isDefault": true
      },
      "id": 2,
      "name": "",
      "origin": "://"
   }
}
[357.680][DEBUG]: DEVTOOLS EVENT Page.frameStoppedLoading {
   "frameId": "1834.2"
}
[357.680][DEBUG]: DEVTOOLS RESPONSE Runtime.evaluate (id=19) {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[357.680][INFO]: Done waiting for pending navigations. Status: ok
[357.682][DEBUG]: DEVTOOLS COMMAND Runtime.evaluate (id=20) {
   "expression": "(function() { // Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum f...",
   "returnByValue": true
}
[357.702][DEBUG]: DEVTOOLS RESPONSE Runtime.evaluate (id=20) {
   "result": {
      "type": "object",
      "value": {
         "status": 0,
         "value": [  ]
      }
   }
}
[357.702][INFO]: Waiting for pending navigations...
[357.702][DEBUG]: DEVTOOLS COMMAND Runtime.evaluate (id=21) {
   "expression": "1"
}
[357.703][DEBUG]: DEVTOOLS EVENT DOM.childNodeCountUpdated {
   "childNodeCount": 1,
   "nodeId": 16
}
[357.703][DEBUG]: DEVTOOLS EVENT Runtime.executionContextDestroyed {
   "executionContextId": 2
}
[357.703][DEBUG]: DEVTOOLS EVENT Page.frameDetached {
   "frameId": "1834.2"
}
[357.703][DEBUG]: DEVTOOLS RESPONSE Runtime.evaluate (id=21) {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}
[357.703][INFO]: Done waiting for pending navigations. Status: ok
[357.703][INFO]: RESPONSE FindElements [  ]
[357.709][INFO]: COMMAND Quit {

}
[357.760][INFO]: RESPONSE Quit
[357.760][DEBUG]: Log type 'driver' lost 4 entries on destruction
[357.760][DEBUG]: Log type 'browser' lost 0 entries on destruction
sclevine commented 7 years ago

@johanbrandhorst, I heard from @DanielJonesEB over Slack that the hanging is likely due to a bug or bugs in Chrome headless mode. I'll keep this issue open until it's resolved upstream and working in Agouti.

johanbrandhorst commented 7 years ago

With Chrome 60 I'm getting errors with regards to untrusted certificates - doesn't seem to be a way to turn that warning off until Chrome 62 according to https://bugs.chromium.org/p/chromium/issues/detail?id=721739. So we're getting there!

johanbrandhorst commented 7 years ago

All working with --allow-insecure-localhost in Chrome 62 🍾

ykyuen commented 6 years ago

I am also trying to run Chrome in headless mode and what i did is creating an symbolic link instead of setting the binary in ChromeOptions

ln -s /usr/bin/google-chrome-stable /usr/bin/chromedriver

and with the following ChromeDriver config

driver := agouti.ChromeDriver(
  agouti.ChromeOptions("args", []string{
    "--headless",
    "--allow-insecure-localhost",
    "--disable-gpu",
    "--homepage=about:blank",
    "--no-first-run",
    "--no-default-browser-check",
    "--no-sandbox",
  }),
  agouti.Debug,
)

What i got is panic: runtime error: invalid memory address

[14:14:0903/120001.361127:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
[15:15:0903/120001.366508:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
[22:22:0903/120001.375995:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
[20:20:0903/120001.380170:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
[34:34:0903/120001.383089:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
[23:23:0903/120001.384141:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
[29:29:0903/120001.388809:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
2018/09/03 12:00:11 Failed to start driver: failed to start before timeout
2018/09/03 12:00:11 Failed to close pages and stop WebDriver: failed to stop service: already stopped
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x78161b]

No idea why it complained about the --no-sandbox flag...

I run the agouti in docker and the chrome version is

# google-chrome-stable --version
Google Chrome 68.0.3440.106 
sermojohn commented 6 years ago

I followed this thread, because I am reaching some issues with chromedriver that could possibly be solved by headless chrome.

Is it currently possible for agouti to integrate with headless chrome without going through the chromedriver?