Selenium with Chromedriver error

Hello,

I am facing an issue with a test with selenium, my tests cannot connect to the server “Connection refused”.

Here is my config:

dependencies:
  pre:
    # Install Chrome driver
    - curl http://chromedriver.storage.googleapis.com/2.23/chromedriver_linux64.zip | gzip -dc > chromedriver
    - chmod +x chromedriver
    # Install Selenium
    - curl http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar > selenium-server-standalone.jar
    - 'java -jar selenium-server-standalone.jar -trustAllSSLCertificates -Dwebdriver.chrome.driver=chromedriver':
        background: true

And the std err:

15:56:28.737 INFO - Launching a standalone Selenium Server
Setting system property webdriver.chrome.driver to chromedriver
15:56:28.779 INFO - Java: Oracle Corporation 25.102-b14
15:56:28.779 INFO - OS: Linux 3.13.0-115-generic amd64
15:56:28.795 INFO - v2.53.1, with Core v2.53.1. Built from revision a36b8b1
15:56:28.900 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
15:56:28.901 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
15:56:28.902 INFO - Driver class not found: com.opera.core.systems.OperaDriver
15:56:28.902 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
15:56:28.905 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform LINUX
15:56:28.906 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
15:56:28.906 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
15:56:29.009 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
15:56:29.009 INFO - Selenium Server is up and running
16:02:27.578 INFO - Executing: [new session: Capabilities [{browser=firefox, name=Behat feature suite, browserName=chrome, ignoreZoomSetting=false, tags=[box5.localdomain, PHP 7.0.11]}]])
16:02:27.590 INFO - Creating a new session for Capabilities [{browser=firefox, name=Behat feature suite, browserName=chrome, ignoreZoomSetting=false, tags=[box5.localdomain, PHP 7.0.11]}]
Starting ChromeDriver 2.23.409687 (c46e862757edc04c06b1bd88724d15a5807b84d1) on port 8696
Only local connections are allowed.
16:02:33.118 INFO - Command failed to close cleanly. Destroying forcefully (v2). [/home/ubuntu/kaya/chromedriver, --port=8696][ {}]
16:02:34.127 ERROR - Unable to kill process with PID 41907
16:02:34.133 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'box5.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-115-generic', java.version: '1.8.0_102'
Driver info: driver.version: unknown
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:183)
	at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:119)
	at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95)
	at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:124)
	at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59)
	at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)
	at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111)
	at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:79)
	at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:204)
	at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:166)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
	at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:132)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	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.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'box5.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-115-generic', java.version: '1.8.0_102'
Driver info: driver.version: unknown
	at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:113)
	at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:97)
	at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
	at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
	at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	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:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103)
	... 9 more
Caused by: org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'box5.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-115-generic', java.version: '1.8.0_102'
Driver info: driver.version: ChromeDriver
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138)
	... 14 more
Caused by: org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8696 [localhost/127.0.0.1] failed: Connection refused
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'box5.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-115-generic', java.version: '1.8.0_102'
Driver info: driver.version: ChromeDriver
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
	... 19 more
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8696 [localhost/127.0.0.1] failed: Connection refused
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
	at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
	at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:162)
	at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:90)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
	... 20 more
Caused by: java.net.ConnectException: Connection refused
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
	... 33 more
16:02:34.143 WARN - Exception: Connection refused

I’m running out of idea. It should be working pretty straightforward but I can’t make it work.

Got this working. You could refer my config.yml https://github.com/abhijeetthorat/java_circleCi/blob/master/.circleci/config.yml

1 Like