Nightwatch E2E browsers don't work on Github Actions

Viewed 429

I've started a new project using create-nuxt-app command and selected Nightwatch as a testing framework. Locally both Chrome and Geckodriver (firefox) works fine: Nightwatch launches and does OK tests. But on Github Actions both Chrome and Geckodriver don't work.

Chrome throws this error:

Error: An error occurred while retrieving a new session: "unknown error: Chrome failed to start: exited abnormally."

Geckodriver throws this error:

Error: An error occurred while retrieving a new session: "Process unexpectedly closed with status 1"

What I've tried:

  1. Tried using either chrome or geckodriver.
  2. For chrome tried "--no-sandbox" without luck.
  3. For geckodriver tried "--headless" without luck.
  4. Tried different version for Chrome, like 77, 87, 88.

I've followed these instructions thoroughly. https://nightwatchjs.org/gettingstarted/browser-drivers-setup/ So I didn't forget to set appropriate ports for each setup and etc.

The setup is absolutely fresh, without any additional configs.

1 Answers

I got it working with the following configuration:

test_settings: {
default: {
  disable_error_log: false,
  launch_url: 'https://nightwatchjs.org',

  screenshots: {
    enabled: false,
    path: 'screens',
    on_failure: true
  },

  desiredCapabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: ['--headless', '--no-sandbox']
    }
  },

  webdriver: {
    start_process: true,
    server_path: require('chromedriver').path,
    port: 9515
  }
}, 
.........

Pay close attention to this block:

desiredCapabilities: {
    browserName: 'chrome',
    chromeOptions: {
      args: ['--headless', '--no-sandbox']
    }
  },

I haven't used these two settings simultaneously, but it did work eventually:

     args: ['--headless', '--no-sandbox']

The main requirement is to use --headless with ChromeDriver, which I didn't do before.

Related