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

Chrome 75 and Nightwatch 1.1.12 Broke waitForElementVisible/isElementDisplayed #2126

Closed HarlowCS closed 5 years ago

HarlowCS commented 5 years ago

Looks like upgrading to Chromedriver 75.0.0 and Nightwatch 1.1.12 has caused every single test I have in all my suites to start returning the below error:

Error while running .isElementDisplayed() protocol action: TypeError [ERR_UNESCAPED_CHARACTERS]: Error while trying to create HTTP request for "/wd/hub/session/494e24fc3e278a655d9bc1be891d5bfe/element/[object Object]/displayed": Request path contains unescaped characters
    at new ClientRequest (_http_client.js:114:13)
    at Object.request (http.js:41:10)
    at HttpRequest.createHttpRequest (/Users/harlow/Repos/nwjs-netlistener/node_modules/nightwatch/lib/http/request.js:112:55)
    at HttpRequest.send (/Users/harlow/Repos/nwjs-netlistener/node_modules/nightwatch/lib/http/request.js:191:29)
    at Promise (/Users/harlow/Repos/nwjs-netlistener/node_modules/nightwatch/lib/transport/transport.js:189:15)
    at new Promise (<anonymous>)
    at Selenium2Protocol.sendProtocolAction (/Users/harlow/Repos/nwjs-netlistener/node_modules/nightwatch/lib/transport/transport.js:187:12)
    at Selenium2Protocol.runProtocolAction (/Users/harlow/Repos/nwjs-netlistener/node_modules/nightwatch/lib/transport/jsonwire.js:61:17)
    at Object.isElementDisplayed (/Users/harlow/Repos/nwjs-netlistener/node_modules/nightwatch/lib/transport/actions.js:54:10)
    at Selenium2Protocol.executeProtocolAction (/Users/harlow/Repos/nwjs-netlistener/node_modules/nightwatch/lib/transport/transport.js:235:48)

I tried running a test with a single waitForElementVisible() and got tons of that error so I assume it definitely has something to do with that or isElementDisplayed()

Config:

{
  "src_folders" : ["lib/e2e.js"],
  "output_folder" : "reports/test",
  "custom_commands_path" : "lib/commands",
  "custom_assertions_path" : "lib/asserts",
  "page_objects_path" : "",
  "globals_path" : "global-config.js",
  "disable_colors": true,
  "skip_testcases_on_fail": false,

  "selenium" : {
    "start_process" : true,
    "server_path" : "./node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.5.jar",
    "log_path" : "reports/test",
    "port" : 4444,
    "host": "localhost",
    "cli_args" : {
      "webdriver.chrome.driver" : "./node_modules/.bin/chromedriver"
    }
  },

  "test_settings" : {
    "default" : {
      "selenium_port"  : 4444,
      "selenium_host"  : "localhost",
      "silent": true,
      "screenshots" : {
        "enabled" : true,
        "path" : "./",
        "on_failure": true,
        "on_error": true
      },
      "desiredCapabilities": {
        "browserName": "chrome",
            "chromeOptions" : {
                "args" : ["--no-sandbox", "--window-size=1536,1152", "--privileged"]
            }
      }
    }
  }
}
beatfactor commented 5 years ago

Have a look at the release notes.

You need to set w3c: false:

chromeOptions: {
    w3c: false
  }

Also, looking at your config, there's no reason why you should be using Selenium if you are only using ChromeDriver.

HarlowCS commented 5 years ago

@beatfactor Mind pointing me to an example that uses just ChromeDriver without Selenium?

beatfactor commented 5 years ago

Sure, it's on our website: https://nightwatchjs.org/gettingstarted#browser-drivers-setup. Let me know if something is unclear.

beatfactor commented 5 years ago

You can also check out our sample tests project: https://github.com/nightwatchjs/nightwatch-website-tests.

wswebcreation commented 5 years ago

@beatfactor

Just a question based on this conversation. There is not visibility check anymore in the W3C specs, they removed the endpoint and so did Chrome + Safari + Edge. You are now referring to fall back to the JSONWP for Chrome. Does that mean that mean that NightwatchJS is not supporting W3C? Because from what I've seen in the documentation NightwatchJS can only send the desiredCapabilities (which is JSONWP) and not the capabilities (which is W3C), see https://www.w3.org/TR/webdriver1/#processing-capabilities