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

TypeError [ERR_UNESCAPED_CHARACTERS]: When 'browserstack.selenium_version':'3.14.0' is specified in desiredCapabilities #2149

Closed ituradastra closed 4 years ago

ituradastra commented 5 years ago

Test can not be executed ,If I want to specify the 'browserstack.selenium_version' :'3.14.0' property in desiredCapabilities(The error won't appear if I specify other version like 2.53.0 'browserstack.selenium_version' :'2.53.0'). The following error is returned:

Error while running .isElementDisplayed() protocol action: TypeError [ERR_UNESCAPED_CHARACTERS]: Er
ror while trying to create HTTP request for "/wd/hub/session/edc11014c2d603cf4bd512b8368ebcb48502712
f/element/[object Object]/displayed": Request path contains unescaped characters
    at new ClientRequest (_http_client.js:115:13)
    at Object.request (http.js:42:10)
    at HttpRequest.createHttpRequest (\nightwatch\node_modules\nightwatch\
lib\http\request.js:112:55)
    at HttpRequest.send (\nightwatch\node_modules\nightwatch\lib\http\requ
est.js:191:29)
    at Promise (\nightwatch\node_modules\nightwatch\lib\transport\transpor
t.js:189:15)
    at new Promise (<anonymous>)
    at Selenium2Protocol.sendProtocolAction (\nightwatch\node_modules\nigh
twatch\lib\transport\transport.js:187:12)
    at Selenium2Protocol.runProtocolAction (\nightwatch\node_modules\night
watch\lib\transport\jsonwire.js:61:17)
    at Object.isElementDisplayed (\nightwatch\node_modules\nightwatch\lib\
transport\actions.js:54:10)
    at Selenium2Protocol.executeProtocolAction (\nightwatch\node_modules\n
ightwatch\lib\transport\transport.js:235:48)
    at WaitForElementVisible.executeProtocolAction (\nightwatch\node_modul
es\nightwatch\lib\element\command.js:201:27)
    at WaitForElementVisible.protocolAction (\nightwatch\node_modules\nigh
twatch\lib\api\element-commands\_waitForDisplayed.js:5:17)
    at WaitForElementVisible.elementFound (\nightwatch\node_modules\nightw
atch\lib\element\command.js:168:17)
    at action (\nightwatch\node_modules\nightwatch\lib\api\element-command
s\_waitForDisplayed.js:40:36)
    at PeriodicPromise.perform (\nightwatch\node_modules\nightwatch\lib\ut
il\periodic-promise.js:79:29)
    at PeriodicPromise.runAction (nightwatch\node_modules\nightwatch\lib\
util\periodic-promise.js:48:33)

nightwatch-api version: 2.3.0 nightwatch- version: 1.1.12 chrome driver version:75.0.0

Here is my config file

const chromedriver = require('chromedriver');
const seleniumServer = require('selenium-server');
module.exports = {
'custom_assertions_path': '',
'page_objects_path': 'page-objects',
'globals_path': 'globals/globals.js',
'end_session_on_fail': false,
'skip_testcases_on_fail': false,
test_settings: {
default: {
'persist_globals': true,
selenium: {
start_process: false,
host: 'hub-cloud.browserstack.com',
port: 80
},
desiredCapabilities: {
'browserstack.user': 'XXX',
'browserstack.key': 'XXX',
os: 'Windows',
os_version: '10',
resolution: '1280x1024',
'browserstack.selenium_version': '3.14.0'
}
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
args: ['disable-gpu', '--start-maximized']
}
}
},
chromeHeadless: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
args: ['disable-gpu', '--start-maximized', '--headless', 'window-size=1920,1080']
}
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true,
marionette: true
}
},
localChrome: {
'persist_globals': true,
selenium: {
start_process: true,
host: '127.0.0.1',
port: 4444,
server_path: seleniumServer.path,
},
screenshots: {
enabled: true,
path: "screenshots"
},
desiredCapabilities: {
server_path: chromedriver.path,
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
args: ['disable-gpu', '--start-maximized']
}
}
}
}
};
deleonio commented 5 years ago

w3c: false

abu-wizata commented 5 years ago

Also seeing this issue. Very blocking.

node@12.8 chromedriver@75.0.1 selenium-server@3.141.59

Error while running .isElementDisplayed() protocol action: TypeError [ERR_UNESC APED_CHARACTERS]: Request path contains unescaped characters at new ClientRequest (_http_client.js:140:13) at Object.request (http.js:44:10) at HttpRequest.createHttpRequest (C:\Users\UserName\Desktop\git-repos\pr edictive-demo-webui\node_modules\nightwatch\lib\http\request.js:112:55) at HttpRequest.send (C:\Users\UserName\Desktop\git-repos\predictive-demo -webui\node_modules\nightwatch\lib\http\request.js:191:29) at C:\Users\UserName\Desktop\git-repos\predictive-demo-webui\node_module s\nightwatch\lib\transport\transport.js:208:15 at new Promise () at Selenium2Protocol.sendProtocolAction (C:\Users\UserName\Desktop\git-r epos\predictive-demo-webui\node_modules\nightwatch\lib\transport\transport.js:20 6:12) at Selenium2Protocol.runProtocolAction (C:\Users\UserName\Desktop\git-re pos\predictive-demo-webui\node_modules\nightwatch\lib\transport\jsonwire.js:55:1 7) at Object.target. [as isElementDisplayed] (C:\Users\UserName\D esktop\git-repos\predictive-demo-webui\node_modules\nightwatch\lib\transport\act ions.js:46:33) at Selenium2Protocol.executeProtocolAction (C:\Users\UserName\Desktop\gi t-repos\predictive-demo-webui\node_modules\nightwatch\lib\transport\transport.js :451:48) at CommandInstance.checkElementVisible (C:\Users\UserName\Desktop\git-re pos\predictive-demo-webui\node_modules\nightwatch\lib\api\element-commands\_wait ForElement.js:276:20) at CommandInstance.elementFound (C:\Users\UserName\Desktop\git-repos\pre dictive-demo-webui\node_modules\nightwatch\lib\api\element-commands\waitForEleme ntVisible.js:44:17) at C:\Users\UserName\Desktop\git-repos\predictive-demo-webui\node_module s\nightwatch\lib\api\element-commands\_waitForElement.js:258:21 at processTicksAndRejections (internal/process/task_queues.js:85:5) --

Config:

const seleniumServer = require('selenium-server'); const chromedriver = require('chromedriver'); const SCREENSHOT_PATH = './screenshots/'; module.exports = { "src_folders": [ "test/nightwatch-tests"// Where you are storing your Nightwatch e2e tests ], "output_folder": "./reports", // reports (test outcome) output by nightwatch "selenium": { "start_process": true, // tells nightwatch to start/stop the selenium process "server_path": seleniumServer.path, "host": "127.0.0.1", "port": 4444, // standard selenium port "cli_args": { "webdriver.chrome.driver" : chromedriver.path }, 'w3c':false }, "test_settings": { "default": { "screenshots": { "enabled": true, // if you want to keep screenshots "path": SCREENSHOT_PATH // save screenshots here }, "globals": { "waitForConditionTimeout": 20000 // sometimes internet is slow so wait. }, "desiredCapabilities": { // use Chrome as the default browser for tests "browserName": "chrome" } }, "chrome": { "desiredCapabilities": { "browserName": "chrome", "javascriptEnabled": true // turn off to test progressive enhancement } } } }

samirph commented 5 years ago

w3c: false solved my problem I wasn't sure where exactly I should put it, so I'm gonna share the config that worked for me

"test_settings" : {
      "default" : {
        "desiredCapabilities" : {
          "browserName" : "chrome",
          "chromeOptions": {
            "args" : ["--no-sandbox"],
            "w3c": false
          },
          "loggingPrefs": {"driver": "INFO", "server": "OFF", "browser": "INFO"}
        }
      }
}
abu-wizata commented 5 years ago

w3c: false solved my problem I wasn't sure where exactly I should put it, so I'm gonna share the config that worked for me

"test_settings" : {
      "default" : {
        "desiredCapabilities" : {
          "browserName" : "chrome",
          "chromeOptions": {
            "args" : ["--no-sandbox"],
            "w3c": false
          },
          "loggingPrefs": {"driver": "INFO", "server": "OFF", "browser": "INFO"}
        }
      }
}

This also solved the problem on our end. Thanks for the work around.

msnehav1987 commented 5 years ago

Thanks a lot guys..this worked for me as well just after adding "w3c": false in nightwatch.json file.

mudeu commented 4 years ago

w3c: false only can solve the issue on chrome

but how to solve the issue on other browsers?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had any recent activity. If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.