Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error retrieving a new session (UnsupportedCommandException) when using start_process: true #470

Closed
ahammar opened this issue May 21, 2015 · 28 comments

Comments

@ahammar
Copy link

ahammar commented May 21, 2015

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

@beatfactor
Copy link
Member

This is probably not a nightwatch issue. Could this be related to your problem? http://stackoverflow.com/questions/16214915/unable-to-call-firefoxdriver-constructor

@ahammar
Copy link
Author

ahammar commented May 27, 2015

No, I don't have anything like that in my /etc/hosts, and as I said it works when I run the selenium server manually so there must be something with how nightwatch is running it.

I tried adding the -host argument to see if that makes a difference, but again running it manually with

java -jar selenium-server-standalone-2.45.0.jar -port 4444 -host 127.0.0.1

works, while running it through nightwatch doesn't. This is exactly the same arguments nightwatch is passing it, so I suspected it might be concurrency related. I instrumented nightwatch to give me the stderr of the child process, and indeed it reveals a java.util.concurrent.ExecutionException:

00:40:33.839 INFO - Launching a standalone server
00:40:33.859 INFO - Java: Oracle Corporation 24.79-b02
00:40:33.860 INFO - OS: Linux 4.0.4-2-ARCH amd64
00:40:33.868 INFO - v2.45.0, with Core v2.45.0. Built from revision 5017cb8
00:40:33.919 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match with current platform: LINUX
00:40:33.942 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
00:40:33.943 INFO - Version Jetty/5.1.x
00:40:33.944 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
00:40:33.944 INFO - Started HttpContext[/selenium-server,/selenium-server]
00:40:33.944 INFO - Started HttpContext[/,/]
00:40:33.970 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@e9e963a
00:40:33.970 INFO - Started HttpContext[/wd,/wd]
00:40:33.972 INFO - Started SocketListener on 0.0.0.0:4444
00:40:33.972 INFO - Started org.openqa.jetty.jetty.Server@71201ad7
00:40:34.123 INFO - Executing: [new session: Capabilities [{platform=ANY, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, name=Google}]])
00:40:34.130 INFO - Creating a new session for Capabilities [{platform=ANY, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, name=Google}]
00:40:35.782 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'reaver', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.0.4-2-ARCH', java.version: '1.7.0_79'
Driver info: driver.version: unknown
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
    at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:175)
    at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:111)
    at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:88)
    at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:109)
    at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:57)
    at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)
    at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:110)
    at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:172)
    at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:201)
    at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:163)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:129)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
    at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680)
    at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571)
    at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
    at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
    at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)
    at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
    at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
    at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
    at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
    at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)
    at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'reaver', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.0.4-2-ARCH', java.version: '1.7.0_79'
Driver info: driver.version: unknown
    at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:69)
    at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:53)
    at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:54)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:214)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:168)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:59)
    ... 9 more
Caused by: org.openqa.selenium.UnsupportedCommandException: Bad request
Command duration or timeout: 111 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'reaver', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.0.4-2-ARCH', java.version: '1.7.0_79'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:104)
    ... 14 more
00:40:35.786 WARN - Exception: Bad request
Command duration or timeout: 111 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'reaver', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.0.4-2-ARCH', java.version: '1.7.0_79'
Driver info: org.openqa.selenium.firefox.FirefoxDriver

I'm not sure what is causing this, though.

@ahammar
Copy link
Author

ahammar commented May 28, 2015

I did some more debugging and it appears that the problem is caused by the pipe that child_process.spawn attaches to the stdin of the child process. Changing line 50 of lib/runner/selenium.js to

this.process = child_process.spawn('java', this.cliOpts, { stdio: ['ignore', 'pipe', 'pipe' ] });

so that the stdin gets attached to /dev/null instead makes it work perfectly.

@beatfactor
Copy link
Member

Ah, I see. Good catch. This must be a Linux specific issue then?

@beatfactor
Copy link
Member

Do you know why would the stdin pipe would cause this exception? This is pretty non-standard and I'd like to have more insight into the problem.

@ahammar
Copy link
Author

ahammar commented May 28, 2015

This must be a Linux specific issue then?

I'm not sure.

Do you know why would the stdin pipe would cause this exception? This is pretty non-standard and I'd like to have more insight into the problem.

No. I initially thought something in selenium might be blocking on the pipe, but the error happens even if I call .end() on it, so it appears that something weirder is going on.

I'd love to understand this better myself, but regardless it makes sense to avoid creating a pipe to stdin since it's not going to write anything to it anyway.

@beatfactor
Copy link
Member

But the behaviour might change in the future. The way I see it, this is more like a workaround to the actual issue so I'd prefer at least to know what the issue is. Are you using a docker or Xvfb? Does this issue following offer any new insight? Or this one?

@ahammar
Copy link
Author

ahammar commented May 28, 2015

No, I'm not using docker or xvfb, so none of those issues seem relevant.

I've dug a little deeper and so far it looks like node (via libuv) is actually using a unix domain socket instead of a pipe. I've been able to reproduce the problem using this script.

import os
import socket
import subprocess
import sys

(a, b) = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM | socket.SOCK_CLOEXEC, 0)

with subprocess.Popen(sys.argv[1:], stdin=b.fileno(), stdout=1, stderr=2):
    print("Subprocess started")
    pass

print("Subprocess exited")

Still not sure why this causes problems, though.

@beatfactor
Copy link
Member

which type of Linux are you using?

On Thu, May 28, 2015 at 6:47 PM, Andreas Hammar [email protected]
wrote:

No, I'm not using docker or xvfb, so none of those issues seem relevant.

I've dug a little deeper and so far it looks like node (via libuv) is
actually using a unix domain socket instead of a pipe. I've been able to
reproduce the problem using this script.

import os
import socket
import subprocess
import sys

(a, b) = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM | socket.SOCK_CLOEXEC, 0)

with subprocess.Popen(sys.argv[1:], stdin=b.fileno(), stdout=1, stderr=2):
print("Subprocess started")
pass

print("Subprocess exited")

Still not sure why this causes problems, though.


Reply to this email directly or view it on GitHub
https://github.com/beatfactor/nightwatch/issues/470#issuecomment-106481214
.

@ahammar
Copy link
Author

ahammar commented May 28, 2015

Arch Linux

@beatfactor
Copy link
Member

Hmm ok, I've only used nightwatch on Ubuntu and I think the majority of
Linux users as well so perhaps it's something specific to your distro?

On Thu, May 28, 2015 at 10:16 PM, Andreas Hammar [email protected]
wrote:

Arch Linux


Reply to this email directly or view it on GitHub
https://github.com/beatfactor/nightwatch/issues/470#issuecomment-106584230
.

@beatfactor
Copy link
Member

How about reporting an issue to libuv then?

@NirLevanon-zz
Copy link

@ahammar Thanks! This solved my issue after I've solved https://github.com/beatfactor/nightwatch/issues/266#issuecomment-109352785 .

@beatfactor This is happening on my Kubuntu 15.04. Would it be possible to expect a fix for this thing so that it would work for Ubuntu as well as the other native OSs (Windows, Mac)?

@benmarten
Copy link

+1 as i am seeing the same issue as initially reported on os x yosemite with latest packages...

@sknopf
Copy link
Collaborator

sknopf commented Jun 23, 2015

@benmarten I can't reproduce on yosemite - what's your package.json look like and what versions are you running?

@benmarten
Copy link

@sknopf Oh sorry, false alert... It works with firefox and phantomjs. Previously I was testing it with chrome.... which wasn't working. But it's probably a chromedriver issue in my setup...

@sknopf
Copy link
Collaborator

sknopf commented Jun 23, 2015

@benmarten ok - yeah sounds like it..

@gregmuellegger
Copy link

@ahammar I had the same issue on Arch Linux and the solution really was to adjust the /etc/hosts as the default file in Arch contains this:

#
# /etc/hosts: static lookup table for host names
#

#<ip-address>   <hostname.domain.org>      <hostname>
127.0.0.1       localhost.localdomain       localhost
::1             localhost.localdomain       localhost

I switched the localhost.localdomain and localhost around and now it works.

@davidosomething
Copy link

#470 (comment)
@gregmuellegger that works, can you explain why?

@gregmuellegger
Copy link

Nope, I have no idea why. But it made it work.

@osaris
Copy link

osaris commented Jan 4, 2016

I confirm that the "fix" by @gregmuellegger is the "solution" for arch ...

@madprog
Copy link

madprog commented Jan 16, 2016

I have found an interesting thing about this problem.

First of all, here is the beginning my /etc/hosts file, as on most ArchLinux distributions:

127.0.0.1       localhost.localdomain localhost
::1             localhost.localdomain localhost

As @gregmuellegger remarked, when the first line starts with localhost, nightwatch and selenium communicate correctly.

However, it would be better not to need root access, right?

My guess was that ArchLinux resolves localhost to ::1 when it is not starting the line (why? no idea).

And then, nightwatch communicates well with selenium on my computer if selenium.host is either ::1 (ipv6-only localhost) or 0.0.0.0 (all interfaces; you may want to set up a firewall!).

You can also use ipv4 addresses for both configurations (127.0.0.1 in selenium.host and test_settings.*.selenium_host as well).

Hope that it helps!

@geloescht
Copy link

I see this on Ubuntu. Swapping localhost and localhost.localdomain in /etc/hosts works, but this really shouldn't be required. Please re-open, as this issue is not fixed. Editing /etc/hosts is only a workaround.
I believe @ahammar 's patch in https://github.com/ahammar/nightwatch/commit/b597bdd85077c7c0e04824a356f02dc1599b6a4f is quite effective. There is really no reason to keep a pipe to selenium's stdin, because it doesn't accept any input anyway.

@beatfactor
Copy link
Member

Alright, we'll get it merged in the next version.

@beatfactor beatfactor reopened this May 16, 2016
@geloescht
Copy link

Awesome! Thank you!

geloescht added a commit to geloescht/keystone that referenced this issue May 16, 2016
* adds alternative command 'npm run test-e2e-bg'
* workaround nightwatchjs/nightwatch#470
@geloescht
Copy link

Any news on this?

@kevinbader
Copy link

A similar behavior seems to be reproducable using Windows 10 as well. Fortunately, I managed to fix it:

  • The desiredCapabilities setting of the default configuration was wrongly nested in another object.
  • Perhaps an interesting inconsistency: when including host: "localhost" in the selenium options, nightwatch tells me "The host argument has been removed from Selenium 3 and will throw an exception.". However, with host: "127.0.0.1" I don't get this hint. I'm putting this here as it could be related to the hostname issues mentioned in previous posts.

Anyway, hth

@VarLong
Copy link

VarLong commented Jan 11, 2018

i got a different issue and it seems have some samiler with this issue , i want test android web app automation on chrome, but i got error value when using the function browser.contexts(),
like that:
{ status: -1,
value:
{ additionalInformation: '\nDriver info: driver.version: unknown',
localizedMessage: 'Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'\nSystem info: host: 'TV14', ip: '10.100.00.00', os.name: 'Windows 8.1', os.a
rch: 'x86', os.version: '6.3', java.version: '1.8.0_151'\nDriver info: driver.version: unknown',
systemInformation: 'System info: host: 'TV14', ip: '10.100.00.00', os.name: 'Windows 8.1', os.arch: 'x86', os.version: '6.3', java.version: '1.8.0_151'',
supportUrl: null,
cause: null,
suppressed: [],
message: 'Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'\nSystem info: host: 'TV14', ip: '10.100.00.00', os.name: 'Windows 8.1', os.arch: 'x8
6', os.version: '6.3', java.version: '1.8.0_151'\nDriver info: driver.version: unknown',
hCode: 17537991,
class: 'org.openqa.selenium.UnsupportedCommandException',
buildInformation: null },
errorStatus: 13,
error: 'An unknown server-side error occurred while processing the command.' }
On Windows 8.1, chrome,

i start selenium-server local by command:
java -jar node_modules\selenium-server\lib\runner\selenium-server-standalone-2.52.0.jar -role hub -Dwebdriver.chrome.driver=node_modules/.bin/chromedriver.cmd

java -Xms456m -Xmx1000m -jar node_modules\selenium-server\lib\runner\selenium-server-standalone-2.52.0.jar -role webdriver -hub http://127.0.0.1:4444/grid/register/ -maxSession 15 -browser "browserName=chrome, maxInstances=15, platform=WIN8" -Dwebdriver.chrome.driver=node_modules/.bin/chromedriver.cmd

in linux the function browser.contextx() will return 👍
{ status: 0,
sessionId: '767324d4520b4e76912a39786c0d3329',
value: [ 'NATIVE_APP', 'CHROMIUM' ] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests