Question

So I had a Chromedriver / Selenium setup working before, but now trying to install everything on a new machine (64Bit Linux) it is giving me problems and not really telling me what is tripping up.

I am using Selenium's stand-alone server version 2.37.0 with nodejs and the latest version of Chromedriver available on Google right now (I also tried Chromedriver 2.0, an earlier version that I had working before, with the same results).

As is shown in the output below, when I try to run a script utilizing the webdriver I get an error that includes: Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally. I am getting no log output from chromedriver, only output from Selenium (with the error) and from Node.js (in its attempt to run the test script).

Can anyone give me an idea of what I am doing wrong here?

EDIT: I forgot to add that after the failure there is a process with Chromedriver running, so that piece is okay, and my Chrome executable is indeed at /etc/bin/google-chrome like Chromedriver wants it to be.

Output:

Once I had selenium up and running I was attempting to run a simple test script with the contents:

var webdriverjs = require("webdriverjs");
var client = webdriverjs.remote({desiredCapabilities:{browserName:"chrome"}}); // to run in chrome
client
.init()
.url("https://github.com/")
.end();

The Node.js console output from running the test script looks like this:

[1;33m=====================================================================================[0m

Selenium 2.0/webdriver protocol bindings implementation with helper commands in nodejs by Camilo Tapia.
For a complete list of commands, visit [1;32mhttp://code.google.com/p/selenium/wiki/JsonWireProtocol[0m. 
Not all commands are implemented yet. visit [1;32mhttps://github.com/Camme/webdriverjs[0m for more info on webdriverjs. 

[1;33m=====================================================================================[0m

[1;30m[21:31:09]: [0m [0;35mCOMMAND [0mPOST      "/wd/hub/session"
[1;30m[21:31:09]: [0m [0;33mDATA         [0m{"desiredCapabilities":{"browserName":"chrome","version":"","javascriptEnabled":true,"platform":"ANY"},"sessionId":null}


[1;30m[21:31:32]: [0m [1;31mERROR   [0mCOULDNT GET A SESSION ID
[1;30m[21:31:32]: [0m Exiting process with 1

Finally, the output from Selenium when it starts up and when attempting to run the script follows. For some reason, I am not getting a chromedriver.log file at all.

java -jar /usr/local/automation/framework/selenium/selenium-server-standalone-2.37.0.jar -Dwebdriver.chrome.driver='/usr/local/automation/framework/selenium/chromedriver' &
[1] 21293
ubuntu@ip-10-0-0-35:/usr/local/automation/framework/selenium$ Nov 15, 2013 9:30:31 PM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
Setting system property webdriver.chrome.driver to /usr/local/automation/framework/selenium/chromedriver
21:30:32.240 INFO - Java: Oracle Corporation 23.5-b02
21:30:32.241 INFO - OS: Linux 3.2.0-48-virtual amd64
21:30:32.289 INFO - v2.37.0, with Core v2.37.0. Built from revision a7c61cb
21:30:32.586 INFO - Default driver org.openqa.selenium.iphone.IPhoneDriver registration is skipped: registration capabilities Capabilities [{platform=MAC, browserName=iPhone, version=}] does not match with current platform: LINUX
21:30:32.626 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
21:30:32.774 INFO - Default driver org.openqa.selenium.iphone.IPhoneDriver registration is skipped: registration capabilities Capabilities [{platform=MAC, browserName=iPad, version=}] does not match with current platform: LINUX
21:30:32.913 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
21:30:32.918 INFO - Version Jetty/5.1.x
21:30:32.919 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
21:30:32.920 INFO - Started HttpContext[/selenium-server,/selenium-server]
21:30:32.920 INFO - Started HttpContext[/,/]
21:30:32.968 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@3b3d8503
21:30:32.968 INFO - Started HttpContext[/wd,/wd]
21:30:32.974 INFO - Started SocketListener on 0.0.0.0:4444
21:30:32.975 INFO - Started org.openqa.jetty.jetty.Server@3e724328

ubuntu@ip-10-0-0-35:/usr/local/automation/framework/selenium$ 21:31:10.116 INFO - Executing: [new session: {platform=ANY, javascriptEnabled=true, browserName=chrome, version=}] at URL: /session)
21:31:10.164 INFO - Creating a new session for Capabilities [{platform=ANY, javascriptEnabled=true, browserName=chrome, version=}]
Starting ChromeDriver (v2.6.232917) on port 17624
[0.797][WARNING]: PAC support disabled because there is no system implementation
21:31:32.375 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'ip-10-0-0-35', ip: '10.0.0.35', os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-48-virtual', java.version: '1.7.0_09'
Driver info: driver.version: unknown
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
    at java.util.concurrent.FutureTask.get(FutureTask.java:111)
    at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:176)
    at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:112)
    at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:89)
    at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:104)
    at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:63)
    at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:205)
    at org.openqa.selenium.remote.server.JsonHttpRemoteConfig.handleRequest(JsonHttpRemoteConfig.java:192)
    at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:201)
    at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:167)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:139)
    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:677)
    at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
    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:914)
    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:357)
    at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'ip-10-0-0-35', ip: '10.0.0.35', os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-48-virtual', java.version: '1.7.0_09'
Driver info: driver.version: unknown
    at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:72)
    at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:56)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:215)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
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:525)
    at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:62)
    ... 9 more
Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.6.232917,platform=Linux 3.2.0-48-virtual x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 20.99 seconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'ip-10-0-0-35', ip: '10.0.0.35', os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-48-virtual', java.version: '1.7.0_09'
Driver info: org.openqa.selenium.chrome.ChromeDriver
    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:525)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:150)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:129)
    ... 14 more
21:31:32.413 WARN - Exception: unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.6.232917,platform=Linux 3.2.0-48-virtual x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 20.99 seconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'ip-10-0-0-35', ip: '10.0.0.35', os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-48-virtual', java.version: '1.7.0_09'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Était-ce utile?

La solution

Ok, after posting all of this I just figured out what I was doing wrong!

The issue was that I was starting selenium from one terminal via SSH and then running the test script from a terminal on the desktop via VNC. Apparently Selenium, WebdriverJS, or Chromedriver does not like this.

It works fine when I start Selenium and run the test script both from the terminal on the desktop.

Autres conseils

It seems like your selenium server cannot launch chrome. This typically happens in the absence of an X environment. In your case, since you're invoking selenium through an ssh session, you should have

  1. A running X display (VNC's display does count, but I am not sure if it can be accessed through the SSH session)
  2. An environment variable in the SSH session, called DISPLAY, whose value is set to an active X window / display

Whether your SSH session has access to an X window or not can be very easily tested. When you connect through SSH to the machine, before running java -jar , just run google-chrome. If it throws an error that indicates it couldn't find a display and aborts, your SSH session does not have access to an X server instance.

Should that be the case, you can try one of the following before launching selenium server:

  1. export DISPLAY=<display-which-is-being-used-by-vnc> if this doesn't work, try 2.
  2. setup Xvfb (X Virtual Frame Buffer) which allows you to simulate an X server instance without actually having one. Browsers work with Xvfb just fine. Once Xvfb is setup and running, say it is running on display 0 and screen 1 (which you will specify in its invocation), execute export DISPLAY=:0.1 and then run selenium in the same SSH session.

If one of the above works for you, you will need to make the DISPLAY environment variable persistent across SSH sessions. You could either add the line to /etc/environment to effect a global change, or put it in your .${SHELL}rc so that it is added to the environment on login.

Have you tried setting a DISPLAY environment variable? I had to set mine with 'export DISPLAY=:1' to get chromedriver working in a ssh session with a separate vnc session.

In your vnc session, open up a terminal and use 'echo $DISPLAY' to see what the setting should be in your ssh session/

no-sandbox was a critical piece of the puzzle for windows jenkins running selenium. Our solution is a maven/code approach vs a jenkins plugin approach. I favor these as I can debug more easily and provide a use case on the desktop that mirrors the build machine.

chromedriver fails on windows jenkins slave running in foreground

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top