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.83k stars 1.32k forks source link

npm init nightwatch undefined (reading 'split') error launching ChromeDriver #3842

Open reallymello opened 1 year ago

reallymello commented 1 year ago

Description of the bug/issue

When I run npm init nightwatch to setup Nightwatch 3.1.1, select TypeScript end-to-end testing, and run npx nightwatch I expect the sample tests to run, but instead I receive error

 - OTHER ERRORS:
  Error

┌──────────────────────────────────────────────────────────────────────────────┐│                                                                              ││   Unable to create the ChromeDriver process: Cannot read properties of       ││   undefined (reading 'split')                                                ││   ; verify if webdriver is configured correctly; using:                      ││   {                                                                          ││   start_process: true,
                           ││   server_path: '',                                                           ││   port: undefined,                                                           ││   host: 'localhost',
 ││   ssl: false,                                                                ││   default_path_prefix: '',                                                   ││   proxy: undefined,                                                          ││   cli_args: {}        
                                                       ││   }                                                                          ││                                                                              ││
                             ││                                                                              │└──────────────────────────────────────────────────────────────────────────────┘

image

Steps to reproduce

Run npm init nightwatch@latest on Windows 10 with Chrome as the selected driver with TypeScript end-to-end tests

Sample test

n/a

Command to run

npx nightwatch

Verbose Output

npx nightwatch --verbose
 Launching up to 4 concurrent test worker processes...

Running   default: nightwatch\duckDuckGo.ts  
Running   default: nightwatch\ecosia.ts 
Running   default: nightwatch\github.ts 
Running   default: nightwatch\google.ts 
┌ ────────────────── ×  default: nightwatch\google.ts  ─────────────────────┐
│                                                                           │
│   default [Nightwatch\google] Test Suite                                  │
│   default ────────────────────────────────────────────────────────────    │
│                                                                           │
└───────────────────────────────────────────────────────────────────────────┘
┌ ────────────────── ×  default: nightwatch\ecosia.ts  ─────────────────┐
│                                                                       │
│   default [Ecosia.org Demo] Test Suite                                │
│   default ────────────────────────────────────────────────────────    │
│                                                                       │
└───────────────────────────────────────────────────────────────────────┘
┌ ────────────────── ×  default: nightwatch\duckDuckGo.ts  ───────────────────┐
│                                                                             │
│   default [duckduckgo example] Test Suite                                   │
│   default ──────────────────────────────────────────────────────────────    │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘
┌ ────────────────── ×  default: nightwatch\github.ts  ─────────────────────┐
│                                                                           │
│   default [Nightwatch\github] Test Suite                                  │
│   default ────────────────────────────────────────────────────────────    │
│                                                                           │
└───────────────────────────────────────────────────────────────────────────┘

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

  ️TEST FAILURE (1.953s):
   - 4 errors during execution;
   - 0 tests failed;
   - 0/NA tests passed
   - 7 skipped

   × 1) nightwatch\google

  - OTHER ERRORS:
  Error

┌──────────────────────────────────────────────────────────────────────────────┐│                                                                              ││   Unable to create the ChromeDriver process: Cannot read properties of       ││   undefined (reading 'split')                                                ││   ; verify if webdriver is configured correctly; using:                      ││   {                                                                          ││   start_process: true,
                           ││   server_path: '',                                                           ││   port: undefined,                                                           ││   host: 'localhost',
 ││   ssl: false,                                                                ││   default_path_prefix: '',                                                   ││   proxy: undefined,                                                          ││   cli_args: {}        
                                                       ││   }                                                                          ││                                                                              ││
                             ││                                                                              │└──────────────────────────────────────────────────────────────────────────────┘

    SKIPPED (at runtime):
    - Google title test
    - Google search test
   × 2) nightwatch\ecosia

  - OTHER ERRORS:
  Error

┌──────────────────────────────────────────────────────────────────────────────┐│                                                                              ││   Unable to create the ChromeDriver process: Cannot read properties of       ││   undefined (reading 'split')                                                ││   ; verify if webdriver is configured correctly; using:                      ││   {                                                                          ││   start_process: true,
                           ││   server_path: '',                                                           ││   port: undefined,                                                           ││   host: 'localhost',
 ││   ssl: false,                                                                ││   default_path_prefix: '',                                                   ││   proxy: undefined,                                                          ││   cli_args: {}        
                                                       ││   }                                                                          ││                                                                              ││
                             ││                                                                              │└──────────────────────────────────────────────────────────────────────────────┘

    SKIPPED (at runtime):
    - Demo test ecosia.org
   × 3) nightwatch\duckDuckGo

  - OTHER ERRORS:
  Error

┌──────────────────────────────────────────────────────────────────────────────┐│                                                                              ││   Unable to create the ChromeDriver process: Cannot read properties of       ││   undefined (reading 'split')                                                ││   ; verify if webdriver is configured correctly; using:                      ││   {                                                                          ││   start_process: true,
                           ││   server_path: '',                                                           ││   port: undefined,                                                           ││   host: 'localhost',
 ││   ssl: false,                                                                ││   default_path_prefix: '',                                                   ││   proxy: undefined,                                                          ││   cli_args: {}        
                                                       ││   }                                                                          ││                                                                              ││
                             ││                                                                              │└──────────────────────────────────────────────────────────────────────────────┘

    SKIPPED (at runtime):
    - Search Nightwatch.js and check results
   × 4) nightwatch\github

  - OTHER ERRORS:
  Error

┌──────────────────────────────────────────────────────────────────────────────┐│                                                                              ││   Unable to create the ChromeDriver process: Cannot read properties of       ││   undefined (reading 'split')                                                ││   ; verify if webdriver is configured correctly; using:                      ││   {                                                                          ││   start_process: true,
                           ││   server_path: '',                                                           ││   port: undefined,                                                           ││   host: 'localhost',
 ││   ssl: false,                                                                ││   default_path_prefix: '',                                                   ││   proxy: undefined,                                                          ││   cli_args: {}        
                                                       ││   }                                                                          ││                                                                              ││
                             ││                                                                              │└──────────────────────────────────────────────────────────────────────────────┘

    SKIPPED (at runtime):
    - Github Title test
    - Github search for nightwatch repository
    - Github login with fake credentials

 Wrote HTML report file to: C:\Projects\nw31Test\tests_output\nightwatch-html-report\index.html

 Wrote Rerun Json report file to: C:\Projects\nw31Test\tests_output\minimal_report.json
 Wrote JSON report file to: C:\Projects\nw31Test\tests_output\nightwatch\google.json
 Wrote JSON report file to: C:\Projects\nw31Test\tests_output\nightwatch\duckDuckGo.json
 Wrote JSON report file to: C:\Projects\nw31Test\tests_output\nightwatch\github.json
 Wrote JSON report file to: C:\Projects\nw31Test\tests_output\nightwatch\ecosia.json
 Wrote XML report file to: C:\Projects\nw31Test\tests_output\nightwatch\ecosia.xml
 Wrote XML report file to: C:\Projects\nw31Test\tests_output\nightwatch\duckDuckGo.xml
 Wrote XML report file to: C:\Projects\nw31Test\tests_output\nightwatch\google.xml
 Wrote XML report file to: C:\Projects\nw31Test\tests_output\nightwatch\github.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: ['test','nightwatch'],

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

  // 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: ''
      },

    },

    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
        ]
      }
    },

  },

};

Nightwatch.js Version

3.1.1

Node Version

18.16.0

Browser

Chrome

Operating System

Windows 10

Additional Information

nw31Test.zip

reallymello commented 1 year ago

After, if I manually run npm install chromedriver@latest everything works. In previous revisions of create-nightwatch it installed chromedriver as a dependency during the init.

garg3133 commented 1 year ago

I tried to run npm init on a Windows 11 machine with Chrome 115 and Node 18.16 and the setup is working fine, not able to reproduce this issue.

Seems to me like something to do with selenium-manager not working properly on your machine. If you uninstall chromedriver from your some other project using Nightwatch v3, does it run fine or give the same error?

gravityvi commented 1 year ago

Hey @reallymello, Did @garg3133's comment resolve your issue here?