Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nightwatch.js cannot run chrome in headless mode

I cannot get it to run without it opening a visible browser window. I tried both with "headless" and "--headless" arguments

Note: I am NOT using Selenium.

Acording to this page headless mode is supported in MacOSX since version 60. I'm running version 61

https://developers.google.com/web/updates/2017/04/headless-chrome

Here's my configuration:

"chrome" : { "desiredCapabilities": { "javascriptEnabled": true, "acceptSslCerts": true, "browserName": "chrome", "chromeOptions" : { "args" : ["--headless"], "binary": "google-chrome" } } },

like image 760
J. Araujo Avatar asked Oct 05 '17 20:10

J. Araujo


2 Answers

I came across the same issue earlier and the solution was to add the following args as I don't want a sandbox neither need the gpu.

"args" : ["headless", "no-sandbox", "disable-gpu"]

"chrome" : {
  "desiredCapabilities": {
    "javascriptEnabled": true,
    "acceptSslCerts": true,
    "browserName": "chrome",
    "chromeOptions" : {
      "args" : ["headless", "no-sandbox", "disable-gpu"]
    }
  }
}
like image 180
SylvesterAbreuLoreto Avatar answered Nov 15 '22 22:11

SylvesterAbreuLoreto


If you are on linux please try this, it works perfectly for me :

            "desiredCapabilities": {
            "browserName": "chrome",
            "javascriptEnabled": true,
            "acceptSslCerts": true,
            "chromeOptions": {
                "args": [
                    "headless", "disable-gpu"
                 ],
                 "binary": "/usr/bin/google-chrome"
              }
        }

If you are on Mac, replace your binary path, eg /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome

like image 41
Bao Tran Avatar answered Nov 15 '22 21:11

Bao Tran