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

Via Workers + Multiple Environments still doesn't work correctly #2777

Closed irondev84 closed 3 years ago

irondev84 commented 3 years ago

Describe the bug

I think there is still something wrong. I changed nightwatch.conf.js to the default one and entered some necessary values for my project. a few things don't work:

1.if I run on two environments: edge and chrome, both sessions are edge? I don't know why the chromedriver session doesn't get up

2.if I add the --parallel to parameter at the beginning and this is how I get the message: Test workers are disabled when running multiple test environments in parallel.

Please verify my nightwatch.conf.js and explain somehow configure it to, for example, for the command: nightwatch path / to / tests --env edge, firefox, chrome tests performed on 3 different browsers?

At the moment it works so that when I give pairs: 1.firefox + chrome it is ok

  1. edge + chrome this is twice the edge 3.firexo + edge that's ok

Run with command nightwatch path/to/tests/scenario --env edge,chrome,firefox nightwatch path/to/tests/scenario --env edge,chrome,firefox --parallel

Verbose output

debug.log

```txt Test workers are disabled when running multiple test environments in parallel. ``` ```txt chrome [testScenario] Test Suite chrome ======================================================= chrome - Connecting to localhost on port 9515... chrome chrome i Connected to localhost on port 9515 (8140ms). chrome Using: msedge (91.0.864.64) on Windows platform. ```

As seen above msedge drive is running under chrome!

Configuration

// Autogenerated by Nightwatch
// Refer to the online docs for more details: https://nightwatchjs.org/gettingstarted/configuration/
const Services = {}; loadServices()

// function defaultVRTScreenshotPath (nightwatchClient, basePath, fileName) {
//   const moduleName = nightwatchClient.currentTest.module

//   return path.join(basePath, moduleName, fileName)
// }

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: ['tests/spec'],

  // See https://nightwatchjs.org/guide/working-with-page-objects/
  page_objects_path: [
    'tests/pages/loginPages'
  ],

  // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-commands
  custom_commands_path: [
    'tests/commands/'
  ],

  // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-assertions
  custom_assertions_path: [
    './node_modules/nightwatch-vrt/assertions'
  ],

  // See https://nightwatchjs.org/guide/#external-globals
  globals_path: 'tests/globals.js',

  webdriver: {},

  test_settings: {
    default: {
      globals: {
        environment: 'mock',
        configurationFilesLocation: './configuration/mock-default/',
        wcagOnClick: false,
        step: 1,
        serverPorts: {
          port: 5700,
          sslPort: 5701,
          watcherPort: 5702
        }
      },
      disable_error_log: false,

      screenshots: {
        enabled: true,
        path: 'tests/screenshots/mock/',
        on_failure: true,
        on_error: true
      },

      desiredCapabilities: {
        browserName: 'firefox'
      },

      webdriver: {
        start_process: true,
        server_path: (Services.geckodriver ? Services.geckodriver.path : process.env.GECKOWEBDRIVER + '\\geckodriver.exe')
      }
    },

    firefox: {
      desiredCapabilities: {
        browserName: 'firefox',
        alwaysMatch: {
          acceptInsecureCerts: true,
          'moz:firefoxOptions': {
            args: [
              // '-headless',
              // '-verbose'
            ]
          }
        }

      },
      webdriver: {
        start_process: true,
        port: 4444,
        server_path: (Services.geckodriver ? Services.geckodriver.path : process.env.GECKOWEBDRIVER + '\\geckodriver.exe'),
        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/
          //
          // This tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
          w3c: false,
          args: [
            // '--no-sandbox',
            // '--ignore-certificate-errors',
            // '--allow-insecure-localhost',
            // '--headless'
          ]
        }
      },

      webdriver: {
        start_process: true,
        port: 9515,
        server_path: (Services.chromedriver ? Services.chromedriver.path : process.env.CHROMEWEBDRIVER + '\\chromedriver.exe'),
        cli_args: [
          // --verbose
        ]
      }
    },

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

      webdriver: {
        start_process: true,
        // Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/
        //  and set the location below:
        server_path: process.env.EDGEWEBDRIVER + '\\msedgedriver.exe',
        cli_args: [
          // --verbose
        ]
      }
    },

    /// ///////////////////////////////////////////////////////////////////////////////
    // Configuration for when using the Selenium service, either locally or remote,  |
    //  like Selenium Grid                                                           |
    /// ///////////////////////////////////////////////////////////////////////////////
    selenium_server: {
      // Selenium Server is running locally and is managed by Nightwatch
      selenium: {
        start_process: true,
        port: 4444,
        server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
        cli_args: {
          'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
          'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : '')
        }
      }
    },

    'selenium.chrome': {
      extends: 'selenium_server',
      desiredCapabilities: {
        browserName: 'chrome',
        chromeOptions: {
          w3c: false
        }
      }
    },

    'selenium.firefox': {
      extends: 'selenium_server',
      desiredCapabilities: {
        browserName: 'firefox',
        'moz:firefoxOptions': {
          args: [
            // '-headless',
            // '-verbose'
          ]
        }
      }
    }
  }
}

function loadServices () {
  try {
    Services.seleniumServer = require('selenium-server')
  } catch (err) {}

  try {
    Services.chromedriver = require('chromedriver')
  } catch (err) {}

  try {
    Services.geckodriver = require('geckodriver')
  } catch (err) {}
}

My Environment

| nightwatch --version | 1.7.7| | npm --version | 6.14.10| | node --version | 14.15.4|

| Browser driver | Version | | chromedriver | 91.0.4472.114 | |edgedriver|91.0.864.64| | geckodriver |88 | | selenium-server | 3.141 | -->

| OS | Version |

| Windows 10 | 1607 | -->

vaibhavsingh97 commented 3 years ago

Thanks for reporting the problem, I will investigate it and try to reproduce the issue from my side

vaibhavsingh97 commented 3 years ago

@ironeo Thanks for raising the issue 🙌 . I can reproduce the issue, but when I tried to spawn chrome and edge browser, none of the browsers started. I received the error [1625829661.258][SEVERE]: bind() failed: Address already in use (48) for both edge and chrome. I had raised the fix, will soon release a new version with the fix.

As seen above msedge drive is running under chrome!

can you please assist me, how I can reproduce the above issue? IMO, the above fix would solve the issue

irondev84 commented 3 years ago

I dont clearly understand... if you have a fix why you need a help with reproduce a bug? What bug are you trying to reproduce if you said you can reproduce issue?

vaibhavsingh97 commented 3 years ago

oh!! my bad, so as you explained in the bug that msedge drive is running under chrome!, so I was talking about this issue, as I couldn't reproduce this issue

irondev84 commented 3 years ago

ok, so please run the following command: nightwatch path/to/tests/scenario --env edge,chrome --parallel as I said, If you run test on chrome and egde altogether, msedge env is running under chromedriver, it is mean that you will have two Chrome session instead of one on chrome and one on edge. Is it more clear now ?