Dbshah
Dbshah

Reputation: 135

My nightwatch.js tests not runs in Chrome headless of CentOS

I run nightwatch.js tests using Nightwatch version 1.0.18 and It's working in windows environment but when I run it in centOS after installment of Xvfb I found below error.

 Error while running .navigateTo() protocol action: invalid session id

 Error while running .locateMultipleElements() protocol action: invalid session id

 Error while running .locateMultipleElements() protocol action: invalid session id

Here is my nightwatch.json file code:

{
  "src_folders": [
    "./tests"
  ],
  "output_folder": "./reports",
  "custom_commands_path": "./custom_commands",
  "custom_assertions_path": "",
  "test_workers": false,
  "webdriver": {
    "start_process": true
  },
  "test_settings": {
    "default": {
      "webdriver": {
        "port": 9515,
        "server_path": "./node_modules/chromedriver/lib/chromedriver/chromedriver",
        "cli_args": [
          "--log",
          "debug"
        ]
      },
      "skip_testcases_on_fail": true,
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "chromeOptions": {
          "args": [
            "headless",
            "no-sandbox",
            "disable-gpu"
          ]
        }
      }
    }
  }
}

am I missing something to run my tests in the centOS environment because it is running in the windows environment?

Upvotes: 4

Views: 6525

Answers (3)

piecioshka
piecioshka

Reputation: 5121

In my situation, when that error occurs:

Error while running .navigateTo() protocol action: invalid session id

I added the following code into .travis.yml:

addons:
  chrome: stable

Upvotes: 0

Anthony Ngene
Anthony Ngene

Reputation: 756

Upgrading to the latest version of chromedriver solved the issue for me. You can find the latest version here; https://www.npmjs.com/package/chromedriver

Upvotes: 1

Amanda Flink
Amanda Flink

Reputation: 86

I had the same issue with Nightwatchjs and the npm chomedriver setup.

Background: Everything was working until I just recently updated Chromium on my system. In addition to the errors in the original post, verbose logging also showed:

{ 
  message: 'unknown error: Chrome failed to start: exited abnormally',
  error: [ 
    "(unknown error: DevToolsActivePort file doesn't exist)",
    '(The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)',
    '(Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.9.0-8-amd64 x86_64)'
  ],
}

After downloading the standalone chromedriver (2.46.628388) to match my Chromium version (72.0.3626.69) it was still showing the same errors.

Solution: I ended up downloading an older version of Chromium (71.0.3578.127) and setting chromeOptions.binary to the new path of the chromium 71 binary. I also had to include 'no-sandbox' with chromeOptions.args.

Here is the snippet from the site mentioned above:

Downloading old builds of Chrome / Chromium

Let's say you want a build of Chrome 44 for debugging purposes. Google does not offer old builds as they do not have up-to-date security fixes.

However, you can get a build of Chromium 44.x which should mostly match the stable release. Here's how you find it:

Upvotes: 7

Related Questions