Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js complaining that "The ChromeDriver could not be found on the current PATH" even though chromedriver is on the path

Tags:

I’m using node 5.10.0 on Linux. Having some issues running my script, which are displayed below

[davea@mydevbox mydir]$ node SkyNet.js  Validation Complete /home/davea/node_modules/selenium-webdriver/chrome.js:185       throw Error(       ^  Error: The ChromeDriver could not be found on the current PATH. Please download the latest version of the ChromeDriver from http://chromedriver.storage.googleapis.com/index.html and   ensure it can be found on your PATH.     at Error (native)     at new ServiceBuilder (/home/davea/node_modules/selenium-webdriver/chrome.js:185:13)     at getDefaultService (/home/davea/node_modules/selenium-webdriver/chrome.js:362:22)     at Driver (/home/davea/node_modules/selenium-webdriver/chrome.js:771:34)     at Builder.build (/home/davea/node_modules/selenium-webdriver/builder.js:464:16)     at Object.<anonymous> (/home/davea/mydir/js/Optimus.js:14:4)     at Module._compile (module.js:413:34)     at Object.Module._extensions..js (module.js:422:10)     at Module.load (module.js:357:32)     at Function.Module._load (module.js:314:12) 

It is saying chromedriver isn’t on my path, but I just downloaded the appropriate version from here — http://chromedriver.storage.googleapis.com/index.html?path=2.9/ , and as you can see, it is on my PATH

[davea@mydevbox mydir]$ echo $PATH /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/davea/bin:/home/davea/bin:/usr/lib/chromedriver 

with the following permissions …

[davea@mydevbox mydir]$ ls -al /usr/lib/chromedriver -rwxr-xr-x 1 davea evotext 5503600 Feb  3  2014 /usr/lib/chromedriver 

So I am confused as to why I’m getting this error. Any help is appreciated, - Dave

like image 571
Dave Avatar asked Apr 04 '16 18:04

Dave


People also ask

How do I fix ChromeDriver executable in path?

To solve the Selenium error "WebDriverException: Message: 'chromedriver' executable needs to be in PATH", install and import the webdriver-manager module by running pip install webdriver-manager . The module simplifies management of binary drivers for different browsers.

What is the default location of ChromeDriver?

Chromium/Google Chrome Note : For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary. You can also override the Chrome binary location following Using a Chrome executable in a non-standard location .

How do I know if ChromeDriver is working?

Execute google.py - A new chrome browser is open and redirect to www.google.com. Execute yahoo.py - If webdriver. Chrome is executed/existed, then assign the browser to driver variable. Else launch new browser.


1 Answers

To add to Niels' answer, for those not using Babel

  1. First install the chromedrive package using npm. If you install globally ensure to have node packages in your path
npm install -g chromedriver 

If PATH errors persist, just save it to the local project's dependencies

npm install --save-dev chromedriver 
  1. For those not using Babel
const webdriver = require('selenium-webdriver'); const chrome = require('selenium-webdriver/chrome'); const chromedriver = require('chromedriver');  chrome.setDefaultService(new chrome.ServiceBuilder(chromedriver.path).build()); 
like image 143
Nick Mitchell Avatar answered Sep 27 '22 22:09

Nick Mitchell