Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Nodejs CHROMEDRIVER path

Tried with "npm install selenium-webdriver" I'm still getting the error below. Any idea where the path is sops to be at?

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 (<anonymous>)
    at new ServiceBuilder (/var/www/nodejs/node_modules/selenium-webdriver/chrome.js:51:11)
    at getDefaultService (/var/www/nodejs/node_modules/selenium-webdriver/chrome.js:216:22)
    at new Driver (/var/www/nodejs/node_modules/selenium-webdriver/chrome.js:470:32)
    at Builder.build (/var/www/nodejs/node_modules/selenium-webdriver/builder.js:302:14)
    at Object.handle (/var/www/nodejs/node.js:31:4)
    at next_layer (/var/www/nodejs/node_modules/express/lib/router/route.js:103:13)
    at Route.dispatch (/var/www/nodejs/node_modules/express/lib/router/route.js:107:5)
    at c (/var/www/nodejs/node_modules/express/lib/router/index.js:195:24)
    at Function.proto.process_params (/var/www/nodejs/node_modules/express/lib/router/index.js:251:12)
like image 681
CodeGuru Avatar asked Oct 04 '14 08:10

CodeGuru


People also ask

How do I find my ChromeDriver path?

Help WebDriver find the downloaded ChromeDriver executableinclude the ChromeDriver location in your PATH environment variable. (Java only) specify its location via the webdriver. chrome. driver system property (see sample below)

Where should I put ChromeDriver for Selenium?

Now we need to move ChromeDriver somewhere that Python and Selenium will be able to find it (a.k.a. in your PATH ). The easiest place to put it is in C:\Windows . So move it there!

Does ChromeDriver need to be in path?

By saving chromedriver.exe in the same folder als your Python working directory, there's no need to specify the path.


2 Answers

Ok assuming you are using Windows please try the following steps:

  • Download the latest version of ChromeDriver from here ChromeDriver

  • Extract the zip and place the contents somewhere you know where it is for example "C:\Users\UserName\AppData\ChromeDriver"

  • Go to your Control Panel -> System -> Edit the System Variables. Click on the "environment variables" button.

  • In the system variables box there will be a variable named "Path" select it and click edit. Copy and paste the path to the containing directory of the chromedriver.exe you downloaded onto the end of the variable value and end it with a semi-colon.

  • Click ok and again to close environment variables and again to close system properties.

  • Close and reopen your terminal window.

  • Run the command again.

I hope this helps - there is a good tutorial here

like image 59
BlinkingCahill Avatar answered Oct 06 '22 18:10

BlinkingCahill


Even after adding the driver path in the System variables it didnt worked.

But by creating & setting own default chrome service, it worked

var webdriver = require('selenium-webdriver');
var chrome = require('selenium-webdriver/chrome');
var path = require('chromedriver').path;

var service = new chrome.ServiceBuilder(path).build();
chrome.setDefaultService(service);

var driver = new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.chrome())
.build();
like image 20
rarunp04 Avatar answered Oct 06 '22 18:10

rarunp04