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

Nightwatchjs claims support for edge in API documentation, but edge browser does not seem to be supported #2514

Closed tsibiski closed 3 years ago

tsibiski commented 3 years ago

Describe the bug

There is extremely little documentation explaining how to run any browsers in Nightwatchjs outside of chrome and firefox. I was able to get Safari working, but nothing I try will allow Edge (chromium) to work. There were a few posts here and there about people trying to get it to work, but nothing mentioned in those StackOverflow etc threads works. Everything that I've tried results in an "unsupported browser" error.

Sample test

The issue is not in a test. It occurs in "/lib/runner/webdriver-server.js"


  switch (browserName) {
      case BrowserName.CHROME:
        WebDriverImpl = ChromeDriver;
        break;
      case BrowserName.SAFARI:
        WebDriverImpl = SafariDriver;
        break;

      case BrowserName.FIREFOX:
        WebDriverImpl = GeckoDriver;
        break;

      default:
        throw new Error(`Unsupported browser: ${browserName}. There is no available driver.`);
    }

Run with command N/A

Verbose output

debug.log

```txt 0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli '/Users/tsibiski/.nvm/versions/node/v12.16.1/bin/node', 1 verbose cli '/Users/tsibiski/.nvm/versions/node/v12.16.1/bin/npm', 1 verbose cli 'run', 1 verbose cli 'test:all:edge' 1 verbose cli ] 2 info using npm@6.13.4 3 info using node@v12.16.1 4 verbose run-script [ 'pretest:all:edge', 'test:all:edge', 'posttest:all:edge' ] 5 info lifecycle product-nightwatchjs-automation@1.0.0~pretest:all:edge: product-nightwatchjs-automation@1.0.0 6 info lifecycle product-nightwatchjs-automation@1.0.0~test:all:edge: product-nightwatchjs-automation@1.0.0 7 verbose lifecycle product-nightwatchjs-automation@1.0.0~test:all:edge: unsafe-perm in lifecycle true 8 verbose lifecycle product-nightwatchjs-automation@1.0.0~test:all:edge: PATH: /Users/tsibiski/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/tsibiski/product-funnel-e2e-test/node_modules/.bin:/Users/tsibiski/.nvm/versions/node/v12.16.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/tsibiski/.nvm/versions/node/v12.16.1/bin 9 verbose lifecycle product-nightwatchjs-automation@1.0.0~test:all:edge: CWD: /Users/tsibiski/product-funnel-e2e-test 10 silly lifecycle product-nightwatchjs-automation@1.0.0~test:all:edge: Args: [ 10 silly lifecycle '-c', 10 silly lifecycle "RUN_ID='' NIGHTWATCH_ENV=edge ./node_modules/cucumber/bin/cucumber-js ./tests/features -r cucumber.conf.js -r ./tests/stepDefinitions -r @babel/register --format json:report/local_cucumber_report.json" 10 silly lifecycle ] 11 silly lifecycle product-nightwatchjs-automation@1.0.0~test:all:edge: Returned: code: 1 signal: null 12 info lifecycle product-nightwatchjs-automation@1.0.0~test:all:edge: Failed to exec test:all:edge script 13 verbose stack Error: product-nightwatchjs-automation@1.0.0 test:all:edge: `RUN_ID='' NIGHTWATCH_ENV=edge ./node_modules/cucumber/bin/cucumber-js ./tests/features -r cucumber.conf.js -r ./tests/stepDefinitions -r @babel/register --format json:report/local_cucumber_report.json` 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (/Users/tsibiski/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:311:20) 13 verbose stack at ChildProcess. (/Users/tsibiski/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:311:20) 13 verbose stack at maybeClose (internal/child_process.js:1021:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) 14 verbose pkgid product-nightwatchjs-automation@1.0.0 15 verbose cwd /Users/tsibiski/product-funnel-e2e-test 16 verbose Darwin 19.6.0 17 verbose argv "/Users/tsibiski/.nvm/versions/node/v12.16.1/bin/node" "/Users/tsibiski/.nvm/versions/node/v12.16.1/bin/npm" "run" "test:all:edge" 18 verbose node v12.16.1 19 verbose npm v6.13.4 20 error code ELIFECYCLE 21 error errno 1 22 error product-nightwatchjs-automation@1.0.0 test:all:edge: `RUN_ID='' NIGHTWATCH_ENV=edge ./node_modules/cucumber/bin/cucumber-js ./tests/features -r cucumber.conf.js -r ./tests/stepDefinitions -r @babel/register --format json:report/local_cucumber_report.json` 22 error Exit status 1 23 error Failed at the product-nightwatchjs-automation@1.0.0 test:all:edge script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ] ```

Configuration

nightwatch.json

```js // Autogenerated by Nightwatch // Refer to the online docs for more details: https://nightwatchjs.org/gettingstarted/configuration/ const Services = {}; function loadServices() { try { Services.seleniumServer = require('selenium-server'); } catch (err) {} try { Services.chromedriver = require('chromedriver'); } catch (err) {} try { Services.geckodriver = require('geckodriver'); } catch (err) {} try { Services.edgedriver = require('edgedriver'); } catch (err) {} try { Services.operadriver = require('operadriver'); } catch (err) {} try { Services.safardriver = require('safaridriver'); } catch (err) {} } loadServices(); 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: [], // See https://nightwatchjs.org/guide/working-with-page-objects/ page_objects_path: './tests/pageObjects', // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-commands custom_commands_path: '', // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-assertions custom_assertions_path: '', // See https://nightwatchjs.org/guide/#external-globals globals_path : 'globalsModule.js', webdriver: {}, test_settings: { test_workers: true, default: { disable_error_log: false, launch_url: 'localhost:80', screenshots: { enabled: false, path: 'screens', on_failure: true }, desiredCapabilities: { browserName : 'firefox' }, webdriver: { start_process: true, server_path: (Services.geckodriver ? Services.geckodriver.path : '') } }, selenium: { port: 4567, host: 'selenium-hub', server_path: "node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.59.jar", cli_args: { "webdriver.chrome.driver": "bin/chromedriver", "webdriver.gecko.driver": "bin/geckodriver", "webdriver.opera.driver": "bin/operadriver", "webdriver.edge.driver": "bin/edgedriver" } }, /*parallelChromeHeadless: { detailed_output: false, selenium: { port: 4567, host: 'selenium-hub', server_path: "node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.59.jar", cli_args: { "webdriver.chrome.driver": "bin/chromedriver", "webdriver.gecko.driver": "bin/geckodriver", "webdriver.opera.driver": "bin/operadriver" } }, desiredCapabilities: { browserName: 'chrome', javascriptEnabled: true, acceptSslCerts: true, chromeOptions: { args : ["disable-web-security", "ignore-certificate-errors", "headless", "no-sandbox", "disable-gpu"] } }, desiredCapabilities: { browserName: 'firefox', javascriptEnabled: true, acceptSslCerts: true, alwaysMatch: { acceptInsecureCerts: true, 'moz:firefoxOptions': { args : ["--headless"] } } } }, firefox: { desiredCapabilities : { browserName : 'firefox', javascriptEnabled: true, acceptSslCerts: true, marionette: true, alwaysMatch: { acceptInsecureCerts: true, 'moz:firefoxOptions': { args : [] } } }, webdriver: { start_process: true, port: 4446, server_path: (Services.geckodriver ? Services.geckodriver.path : ''), cli_args: [ // very verbose geckodriver logs // '-vv' ] } }, firefoxHeadless: { desiredCapabilities: { browserName: 'firefox', javascriptEnabled: true, acceptSslCerts: true, marionette: true, alwaysMatch: { acceptInsecureCerts: true, 'moz:firefoxOptions': { args : ["--headless"] } } }, webdriver: { start_process: true, port: 4447, server_path: (Services.geckodriver ? Services.geckodriver.path : ''), cli_args: [ // --verbose ] } }, chrome: { desiredCapabilities : { browserName : 'chrome', chromeOptions : { args : ["disable-web-security", "ignore-certificate-errors", "no-sandbox", "disable-gpu"] } }, webdriver: { start_process: true, port: 4444, server_path: (Services.chromedriver ? Services.chromedriver.path : ''), cli_args: [ // --verbose ] } }, chromeHeadless: { desiredCapabilities: { browserName: 'chrome', javascriptEnabled: true, acceptSslCerts: true, chromeOptions: { args : ["disable-web-security", "ignore-certificate-errors", "headless", "no-sandbox", "disable-gpu"] } }, webdriver: { start_process: true, port: 4445, server_path: (Services.chromedriver ? Services.chromedriver.path : ''), cli_args: [ // --verbose ] } },*/ edgeTesting: { desiredCapabilities: { alwaysMatch: { 'ms:edgeOptions': { args: ['--headless'] } }, browserName: 'MicrosoftEdge', javascriptEnabled: true, acceptSslCerts: true, edgeOptions:{ w3c: false, } }, start_process: false, webdriver: { default_path_prefix: '', server_path: (Services.edgedriver ? './node_modules/edgedriver/bin/edgedriver' : ''), start_process: true, use_legacy_jsonwire: true } },/* edge: { desiredCapabilities : { browserName : 'MicrosoftEdge', edgeOptions : { args : ["disable-web-security", "ignore-certificate-errors", "no-sandbox", "disable-gpu"] } }, webdriver: { start_process: true, port: 4555, server_path: (Services.edgedriver ? Services.edgedriver.path : ''), cli_args: [ // --verbose ] } }, edgeHeadless: { desiredCapabilities: { browserName: 'microsoftedge', javascriptEnabled: true, acceptSslCerts: true, edgeOptions: { args : ["disable-web-security", "ignore-certificate-errors", "headless", "no-sandbox", "disable-gpu"] } }, webdriver: { start_process: true, port: 4449, server_path: (Services.edgedriver ? Services.edgedriver.path : ''), cli_args: [ // --verbose ] } }, opera: { desiredCapabilities : { browserName : 'opera', operaOptions : { args : ["disable-web-security", "ignore-certificate-errors", "no-sandbox", "disable-gpu"] } }, webdriver: { start_process: true, port: 4450, server_path: (Services.operadriver ? Services.operadriver.path : ''), cli_args: [ // --verbose ] } }, operaHeadless: { desiredCapabilities: { browserName: 'opera', javascriptEnabled: true, acceptSslCerts: true, operaOptions: { args : ["disable-web-security", "ignore-certificate-errors", "headless", "no-sandbox", "disable-gpu"] } }, webdriver: { start_process: true, port: 4451, server_path: (Services.operadriver ? Services.operadriver.path : ''), cli_args: [ // --verbose ] } }, safari: { desiredCapabilities : { browserName : 'safari', safariOptions : { args : ["disable-web-security", "ignore-certificate-errors", "no-sandbox", "disable-gpu"] } }, webdriver: { start_process: true, port: 4452, server_path: (Services.safaridriver ? Services.safaridriver.path : ''), cli_args: [ // --verbose ] } }*/ } }; ```

Your Environment

Executable Version
nightwatch --version 1.4.2
npm --version 6.13.4
yarn --version N/A
node --version 12.16.1
Browser driver Version
NAME VERSION
OS Version
NAME VERSION
tsibiski commented 3 years ago

I went ahead and added the code to make the edge driver work in Nightwatchjs

node_modules/nightwatch/lib/runner/wd-instances/edgedriver.js

Also, add const EdgeDriver = require('./wd-instances/edgedriver.js'); and

case BrowserName.EDGE:
        WebDriverImpl = EdgeDriver;
        break;

to node_modules/nightwatch/lib/runner/webdriver-server.js

pawlakmaly commented 3 years ago

@beatfactor Can we add support for Edge in upcoming version ? I think edgedriver is available via npm package now.

gravityvi commented 3 years ago

Fixed in Nightwatch v1.7 https://github.com/nightwatchjs/nightwatch/commit/c0b93cc74beb91721b75b99769b0729b08ec266d