nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.78k stars 1.31k forks source link

v3.0.0-alpha.3 -- uknown error: cannot find Chrome binary #3686

Closed reallymello closed 1 year ago

reallymello commented 1 year ago

Description of the bug/issue

When I run npx nightwatch in a default nightwatch init@latest installed project after running npm install nightwatch@v3.0.0-alpha.3 I expect the included tests to run in chrome, but instead I receive error unknown error: Cannot find Chrome binary

Steps to reproduce

  1. npx install nightwatch@latest
  2. Select typescript with default assertion style and chrome, firefox, and edge as preconfigured browser
  3. Verify everything works with npx nightwatch
  4. Run npm install nightwatch@v3.0.0-alpha.3
  5. Rerun npx nightwatch

Response 500 POST /session

Sample test

Default ecosia.ts from scaffolder

Command to run

npx nightwatch

Verbose Output

PS C:\Users\me\projects\example-nightwatch-template> npx nightwatch --verbose
 Now you can run TS tests directly using Nightwatch.
 Launching up to 1 concurrent test worker processes...

Running   default: claims.ts 
┌ ────────────────── ×  default: claims.ts  ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                                                                            │     
│   undefined Now you can run TS tests directly using Nightwatch.                                                                                                            │     
│   undefined [Claims] Test Suite                                                                                                                                            │     
│   undefined ──────────────────────────────────────                                                                                                                         │     
│   undefined Starting ChromeDriver with server_path=C:\Users\me\projects\example-nightwatch-template\node_modules\chromedriver\lib\chromedriver\chromedriver.exe...    │     
│   undefined   Request POST /session                                                                                                                                        │     
│   undefined {                                                                                                                                                              │     
│   undefined      capabilities: {                                                                                                                                           │     
│   undefined        firstMatch: [ {} ],                                                                                                                                     │     
│   undefined        alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': {} }                                                                                        │     
│   undefined      }                                                                                                                                                         │     
│   undefined   }                                                                                                                                                            │     
│   undefined  Error                                                                                                                                                         │     
│   undefined      Response 500 POST /session (20ms)                                                                                                                         │     
│   undefined {                                                                                                                                                              │     
│   undefined      value: {                                                                                                                                                  │     
│   undefined        error: 'unknown error',                                                                                                                                 │     
│   undefined        message: 'unknown error: cannot find Chrome binary',                                                                                                    │     
│   undefined        stacktrace: ''                                                                                                                                          │     
│   undefined      }                                                                                                                                                         │     
│   undefined   }                                                                                                                                                            │     
│                                                                                                                                                                            │     
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘     

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  ️TEST FAILURE (2.588s):
   - 1 error during execution;
   - 0 tests failed;
   - 0/NA tests passed
   - 2 skipped

   × 1) claims

  - OTHER ERRORS:
  Error
    An error occurred while creating a new ChromeDriver session: [WebDriverError] unknown error: cannot find Chrome binary
  Verify if ChromeDriver is configured correctly; using:
  {
     start_process: true,
     server_path: 'C:\\Users\\me\\projects\\example-nightwatch-template\\node_modules\\chromedriver\\lib\\chromedriver\\chromedriver.exe',
     port: undefined,
     host: 'localhost',
     ssl: false,
     default_path_prefix: '',
     proxy: undefined,
     cli_args: {}
  }

  Set webdriver.log_path in your Nightwatch config to retrieve more logs from ChromeDriver.
    SKIPPED:
    - test page title
    - can complete FNOL

 Wrote HTML report file to: C:\Users\me\projects\example-nightwatch-template\tests_output\nightwatch-html-report\index.html

 Wrote JSON report file to: C:\Users\me\projects\example-nightwatch-template\tests_output\claims.json
 Wrote XML report file to: C:\Users\me\projects\example-nightwatch-template\tests_output\claims.xml

Nightwatch Configuration

// Refer to the online docs for more details:
// https://nightwatchjs.org/gettingstarted/configuration/
//

//  _   _  _         _      _                     _          _
// | \ | |(_)       | |    | |                   | |        | |
// |  \| | _   __ _ | |__  | |_ __      __  __ _ | |_   ___ | |__
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
// | |\  || || (_| || | | || |_  \ V  V / | (_| || |_ | (__ | | | |
// \_| \_/|_| \__, ||_| |_| \__|  \_/\_/   \__,_| \__| \___||_| |_|
//             __/ |
//            |___/

module.exports = {
  // An array of folders (excluding subfolders) where your tests are located;
  // if this is not specified, the test source must be passed as the second argument to the test runner.
  src_folders: ['nightwatch/tests'],

  // See https://nightwatchjs.org/guide/concepts/page-object-model.html
  page_objects_path: ['nightwatch/page-objects'],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
  custom_commands_path: [],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
  custom_assertions_path: [],

  // See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html
  plugins: [],

  // See https://nightwatchjs.org/guide/concepts/test-globals.html
  globals_path: '',

  webdriver: {},

  test_workers: {
    enabled: true,
  },

  test_settings: {
    default: {
      disable_error_log: false,
      launch_url: 'http://localhost',

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

      desiredCapabilities: {
        browserName: 'chrome',
      },

      webdriver: {
        start_process: true,
        server_path: '',
      },

      globals: {
      },
    },

    firefox: {
      desiredCapabilities: {
        browserName: 'firefox',
        alwaysMatch: {
          acceptInsecureCerts: true,
          'moz:firefoxOptions': {
            args: [
              // '-headless',
              // '-verbose'
            ],
          },
        },
      },
      webdriver: {
        start_process: true,
        server_path: '',
        cli_args: [
          // very verbose geckodriver logs
          // '-vv'
        ],
      },
    },

    chrome: {
      desiredCapabilities: {
        browserName: 'chrome',
        'goog:chromeOptions': {
          // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
          //
          // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
          w3c: true,
          args: [
            //'--no-sandbox',
            //'--ignore-certificate-errors',
            //'--allow-insecure-localhost',
            //'--headless'
          ],
        },
      },

      webdriver: {
        start_process: true,
        server_path: '',
        cli_args: [
          // --verbose
        ],
      },
    },

    edge: {
      desiredCapabilities: {
        browserName: 'MicrosoftEdge',
        'ms:edgeOptions': {
          w3c: true,
          // More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options
          args: [
            //'--headless'
          ],
        },
      },

      webdriver: {
        start_process: true,
        // Follow https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/?tabs=c-sharp#download-microsoft-edge-webdriver
        // to download the Edge WebDriver and set the location of extracted `msedgedriver` below:
        server_path: '',
        cli_args: [
          // --verbose
        ],
      },
    },
  },
};

Nightwatch.js Version

3.0.0-alpha.3

Node Version

18.15.0

Browser

Chrome 112

Operating System

Windows 11

Additional Information

Happened with both the chrome 111 and chrome 112 drivers

vishalshah133 commented 1 year ago

@garg3133 - I tried the steps on mac and it worked. However, when I tried on Windows 11, it failed with the same error as reported by @reallymello

Just to give you a head-start, it seems to be an issue related to Windows in general or Windows 11 specifically.

reallymello commented 1 year ago

@vishalshah133 like you, my Windows 10 PC is working with the alpha, but I have two colleagues reporting this error under Windows 10. Nobody around me using Windows 11 can get past this error in the alpha though.

vaibhavsingh97 commented 1 year ago

@reallymello @garg3133 this issue is appearing on v2.x as well in windows 11.

I couldn't reproduce the issue, in mine case the chrome wasn't installed

reallymello commented 1 year ago

https://github.com/nightwatchjs/nightwatch/pull/3691 fixed it for me