Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium & ChromeDriver: session not created, unable to connect to renderer

I am trying to run automated tests via Webdriver.io, Selenium and ChromeDriver on Mac. I am using the latest versions of all involved software:

  • Selenium 3.9.1
  • ChromeDriver 2.35
  • Chrome 64
  • OS: macOS High Sierra 10.13.3

When I try to run wdio from the CLI, I get the following output:

$ ./node_modules/.bin/wdio --spec ./test_js/specs/features/aggregated/dataAccessControl.feature.js

----------
selenium-standalone installation starting
----------

---
selenium install:
from: https://selenium-release.storage.googleapis.com/3.9/selenium-server-standalone-3.9.1.jar
to: /PROJECT_PATH/node_modules/selenium-standalone/.selenium/selenium-server/3.9.1-server.jar
---
chrome install:
from: https://chromedriver.storage.googleapis.com/2.35/chromedriver_mac64.zip
to: /PROJECT_PATH/node_modules/selenium-standalone/.selenium/chromedriver/2.35-x64-chromedriver
---
File from https://selenium-release.storage.googleapis.com/3.9/selenium-server-standalone-3.9.1.jar has already been downloaded
---
File from https://chromedriver.storage.googleapis.com/2.35/chromedriver_mac64.zip has already been downloaded


-----
selenium-standalone installation finished
-----
A service failed in the 'onPrepare' hook
Error: Unable to connect to selenium
    at Timeout.hasStarted [as _onTimeout] (/PROJECT_PATH/node_modules/selenium-standalone/lib/check-started.js:17:10)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)

Continue...
ERROR: session not created exception
from disconnected: unable to connect to renderer
chrome
    at new RuntimeError (/PROJECT_PATH/node_modules/webdriverio/build/lib/utils/ErrorHandler.js:144:12)
    at Request._callback (/PROJECT_PATH/node_modules/webdriverio/build/lib/utils/RequestHandler.js:313:39)
    at Request.self.callback (/PROJECT_PATH/node_modules/request/request.js:186:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/PROJECT_PATH/node_modules/request/request.js:1163:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/PROJECT_PATH/node_modules/request/request.js:1085:12)
    at Object.onceWrapper (events.js:313:30)

The process then stops. The Chrome icon pops up for a moment on the dock, then disappears immediately.

I have tried starting the Selenium standalone server from the CLI, navigating to http://localhost:4444/wd/hub/static/resource/hub.html and trying to start a Chrome session manually there, but the result is the same: the Chrome icon pops up, disappears, and Selenium throws an error "Unable to create new session."

I have also tried downloading an older version of Chromium and forcing ChromeDriver to use that, but it's just unable to launch the executable.

like image 294
Máté Safranka Avatar asked Dec 23 '22 10:12

Máté Safranka


1 Answers

Found the solution here: https://github.com/Polymer/web-component-tester/issues/573#issuecomment-310828303

Quote:

Finally i got it fixed after lot of struggle. It was happening because my localhost was mapped according to new Ipv6 standard like [::1] but the selenium needed the ipv4 address like 127.0.0.1. so i had to change it using the command in my system like this :

Open a terminal window and type this line:

sudo open -a TextEdit /etc/hosts

You will be prompt to type in your admin password and your host file will open in TextEdit. Add this line in your host file :

127.0.0.1 localhost

Save the file and close. That's it.

(addendum: TextEdit refused to save the file for me, even as superuser, so I used sudo vim /etc/hosts instead)

like image 145
Máté Safranka Avatar answered Apr 27 '23 00:04

Máté Safranka