0

I am trying to use Selenium to run some unit tests, but am facing difficulty in getting it to run. Every time i execute my code, chrome starts to open and then immediately crashes.

I have done some research and people suggest this can happen when you have too many instances running or when the chromedriver/chrome version do not align, however I have checked and neither seem to be the issue.

Below is the console error that I receive... (node:76034) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SessionNotCreatedError: session not created exception from disconnected: unable to connect to renderer (Session info: chrome=66.0.3359.117) (Driver info: chromedriver=2.37.544337 (8c0344a12e552148c185f7d5117db1f28d6c9e85),platform=Mac OS X 10.13.4 x86_64)

And this is the code that i am running (this is just a quick example I took to try and get selenium running)... ```

var webdriver = require('selenium-webdriver');
var browser = new webdriver.Builder()
  .usingServer()
  .withCapabilities({ browserName: 'chrome' })
  .build();

browser.get('http://en.wikipedia.org/wiki/Wiki');
browser
  .findElements(webdriver.By.css('[href^="/wiki/"]'))
  .then(function(links) {
    console.log('Found', links.length, 'Wiki links.');
    browser.quit();
  });

Any help would be much appreciated

Phil
  • 1,610
  • 4
  • 26
  • 40
  • have you tried with chromedriver version 2.38 ? – Florent B. Apr 25 '18 at 14:31
  • Are you certain you are using the latest chrome, chromedriver? In most cases, that is the problem. – Siraj K Apr 25 '18 at 14:31
  • Yes i tried using chromedriver version 2.38 and same issue occurs... it was googling that issue where someone suggested using 2.37 so i downgraded – Phil Apr 25 '18 at 14:33
  • Try to disable the gpu with the flag `--disable-gpu`. You should also wait for each promise to be resolved before calling the next command: `var browser = await new webdriver.Builder()`, `await browser.get(...` – Florent B. Apr 25 '18 at 14:43
  • @FlorentB. `--disable-gpu` flag would be used on for _Windows OS_. _Not Applicable_ for _Linux OS_ and _Mac OSX_. Reference [5702](https://github.com/SeleniumHQ/selenium/issues/5702) – undetected Selenium Apr 25 '18 at 14:50
  • @DebanjanB, where did you get that `--disable-gpu` is not applicable to mac and linux? You reference is about `--disable-gpu` used as a workaround for the headless mode which doesn't support hardware acceleration on Windows. – Florent B. Apr 25 '18 at 15:11
  • @Phil Tested your code on Windows platform, with chromedriver versions 2.27 and 2.28; chrome version 66.x. It works perfectly fine. – Barney Apr 25 '18 at 16:57

0 Answers0