nightwatch: Error retrieving a new session (UnsupportedCommandException) when using start_process: true
When automatically starting Selenium using start_process: true I get this error.
$ node node_modules/nightwatch/bin/runner.js --verbose
Starting selenium server... started - PID: 29749
[Google] Test Suite
===================
Running: Visit Google
INFO Request: POST /wd/hub/session
- data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","name":"Google"}}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":129}
ERROR Response 500 POST /wd/hub/session{ sessionId: null,
status: 13,
state: 'unhandled error',
value:
{ message: 'Bad request\nCommand duration or timeout: 107 milliseconds\nBuild info: version: \'2.45.0\', revision: \'5017cb8\', time: \'2015-02-26 23:59:50\'\nSystem info: host: \'reaver\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'4.0.4-1-ARCH\', java.version: \'1.7.0_79\'\nDriver info: org.openqa.selenium.firefox.FirefoxDriver',
suppressed: [],
localizedMessage: 'Bad request\nCommand duration or timeout: 107 milliseconds\nBuild info: version: \'2.45.0\', revision: \'5017cb8\', time: \'2015-02-26 23:59:50\'\nSystem info: host: \'reaver\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'4.0.4-1-ARCH\', java.version: \'1.7.0_79\'\nDriver info: org.openqa.selenium.firefox.FirefoxDriver',
buildInformation:
{ releaseLabel: '2.45.0',
buildTime: '2015-02-26 23:59:50',
class: 'org.openqa.selenium.internal.BuildInfo',
buildRevision: '5017cb8',
hCode: 167058406 },
cause: null,
systemInformation: 'System info: host: \'reaver\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'4.0.4-1-ARCH\', java.version: \'1.7.0_79\'',
supportUrl: null,
class: 'org.openqa.selenium.UnsupportedCommandException',
additionalInformation: '\nDriver info: org.openqa.selenium.firefox.FirefoxDriver',
hCode: 401822801,
screen: null },
class: 'org.openqa.selenium.remote.Response',
hCode: 1453360085 }
Error retrieving a new session from the selenium server
{ sessionId: null,
status: 13,
state: 'unhandled error',
value:
{ buildInformation:
{ releaseLabel: '2.45.0',
buildTime: '2015-02-26 23:59:50',
class: 'org.openqa.selenium.internal.BuildInfo',
buildRevision: '5017cb8',
hCode: 167058406 },
localizedMessage: 'Bad request\nCommand duration or timeout: 107 milliseconds\nBuild info: version: \'2.45.0\', revision: \'5017cb8\', time: \'2015-02-26 23:59:50\'\nSystem info: host: \'reaver\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'4.0.4-1-ARCH\', java.version: \'1.7.0_79\'\nDriver info: org.openqa.selenium.firefox.FirefoxDriver',
cause: null,
message: 'Bad request\nCommand duration or timeout: 107 milliseconds\nBuild info: version: \'2.45.0\', revision: \'5017cb8\', time: \'2015-02-26 23:59:50\'\nSystem info: host: \'reaver\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'4.0.4-1-ARCH\', java.version: \'1.7.0_79\'\nDriver info: org.openqa.selenium.firefox.FirefoxDriver',
systemInformation: 'System info: host: \'reaver\', ip: \'127.0.0.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'4.0.4-1-ARCH\', java.version: \'1.7.0_79\'',
hCode: 401822801,
screen: null,
additionalInformation: '\nDriver info: org.openqa.selenium.firefox.FirefoxDriver',
suppressed: [ [length]: 0 ],
class: 'org.openqa.selenium.UnsupportedCommandException',
supportUrl: null },
class: 'org.openqa.selenium.remote.Response',
hCode: 1453360085 }
Connection refused! Is selenium server started?
nightwatch.json:
{
"src_folders": ["tests"],
"output_folder": false,
"selenium": {
"start_process": true,
"server_path": "selenium-server-standalone-2.45.0.jar"
},
"test_settings": {
"default": {}
}
}
tests/google.js
module.exports = {
'Visit Google': function (browser) {
browser
.url('http://www.google.com')
.waitForElementVisible('body', 1000)
.assert.title("Google")
.end();
}
};
Setting start_process to false and starting Selenium manually with java -jar selenium-server-standalone-2.45.0.jar, everything works:
$ node node_modules/nightwatch/bin/runner.js --verbose
[Google] Test Suite
===================
Running: Visit Google
INFO Request: POST /wd/hub/session
- data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","name":"Google"}}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":129}
INFO Response 200 POST /wd/hub/session{ sessionId: '0de12c13-f012-4bab-93c0-99e1cddd0ac4',
status: 0,
state: null,
value:
{ platform: 'LINUX',
javascriptEnabled: true,
acceptSslCerts: true,
browserName: 'firefox',
rotatable: false,
locationContextEnabled: true,
'webdriver.remote.sessionid': '0de12c13-f012-4bab-93c0-99e1cddd0ac4',
version: '38.0.1',
databaseEnabled: true,
cssSelectorsEnabled: true,
handlesAlerts: true,
webStorageEnabled: true,
nativeEvents: false,
applicationCacheEnabled: true,
takesScreenshot: true },
class: 'org.openqa.selenium.remote.Response',
hCode: 1446382936 }
INFO Got sessionId from selenium 0de12c13-f012-4bab-93c0-99e1cddd0ac4
INFO Request: POST /wd/hub/session/0de12c13-f012-4bab-93c0-99e1cddd0ac4/url
- data: {"url":"http://www.google.com"}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":31}
INFO Response 200 POST /wd/hub/session/0de12c13-f012-4bab-93c0-99e1cddd0ac4/url{ sessionId: '0de12c13-f012-4bab-93c0-99e1cddd0ac4',
status: 0,
state: 'success',
value: null,
class: 'org.openqa.selenium.remote.Response',
hCode: 1795038768 }
LOG → Completed command url (1359 ms)
INFO Request: POST /wd/hub/session/0de12c13-f012-4bab-93c0-99e1cddd0ac4/elements
- data: {"using":"css selector","value":"body"}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":39}
INFO Response 200 POST /wd/hub/session/0de12c13-f012-4bab-93c0-99e1cddd0ac4/elements{ sessionId: '0de12c13-f012-4bab-93c0-99e1cddd0ac4',
status: 0,
state: 'success',
value: [ { ELEMENT: '0' } ],
class: 'org.openqa.selenium.remote.Response',
hCode: 1998041524 }
INFO Request: GET /wd/hub/session/0de12c13-f012-4bab-93c0-99e1cddd0ac4/element/0/displayed
- data:
- headers: {"Accept":"application/json"}
INFO Response 200 GET /wd/hub/session/0de12c13-f012-4bab-93c0-99e1cddd0ac4/element/0/displayed{ sessionId: '0de12c13-f012-4bab-93c0-99e1cddd0ac4',
status: 0,
state: 'success',
value: true,
class: 'org.openqa.selenium.remote.Response',
hCode: 730193816 }
✔ Element <body> was visible after 209 milliseconds.
LOG → Completed command waitForElementVisible (211 ms)
INFO Request: GET /wd/hub/session/0de12c13-f012-4bab-93c0-99e1cddd0ac4/title
- data:
- headers: {"Accept":"application/json"}
INFO Response 200 GET /wd/hub/session/0de12c13-f012-4bab-93c0-99e1cddd0ac4/title{ sessionId: '0de12c13-f012-4bab-93c0-99e1cddd0ac4',
status: 0,
state: 'success',
value: 'Google',
class: 'org.openqa.selenium.remote.Response',
hCode: 270088606 }
✔ Testing if the page title equals "Google".
LOG → Completed command title (41 ms)
LOG → Completed command title (41 ms)
INFO Request: DELETE /wd/hub/session/0de12c13-f012-4bab-93c0-99e1cddd0ac4
- data:
- headers: {"Content-Length":0}
INFO Response 200 DELETE /wd/hub/session/0de12c13-f012-4bab-93c0-99e1cddd0ac4{ sessionId: '0de12c13-f012-4bab-93c0-99e1cddd0ac4',
status: 0,
state: 'success',
value: null,
class: 'org.openqa.selenium.remote.Response',
hCode: 312784151 }
LOG → Completed command end (96 ms)
LOG → Completed command session (96 ms)
INFO FINISHED
OK. 2 assertions passed. (3.563s)
Relevant version info: nightwatch 0.6.12, selenium 2.45, firefox 38.0.1 on Arch Linux 4.0.4-1
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 28 (8 by maintainers)
Commits related to this issue
- test(e2e): Add workaround for selenium failure * adds alternative command 'npm run test-e2e-bg' * workaround https://github.com/nightwatchjs/nightwatch/issues/470 — committed to geloescht/keystone by geloescht 8 years ago
- Fix #470 - disable stdin pipe between selenium java process and nightwatch to address linux issues — committed to nightwatchjs/nightwatch by beatfactor 8 years ago
@ahammar I had the same issue on Arch Linux and the solution really was to adjust the
/etc/hostsas the default file in Arch contains this:I switched the
localhost.localdomainandlocalhostaround and now it works.Alright, we’ll get it merged in the next version.