Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Quality Assurance Introduction to Selenium Test Drive Selenium Installation

Alex P
Alex P
99 Points

I´m sorry but I´m still getting Error: The ChromeDriver could not be found on the current PATH. Pls help.

I´m getting Error: The ChromeDriver could not be found on the current PATH. Please download the latest version... ...http://chromedriver.storage.googleapis.com/index.html and ensure...

I downloaded lates version (right now is v2.33) and still stuck in it.

This is the [...mypath] where installed "chrome.js": (C:\Users\MyName\selenium-basics\node_modules\selenium-webdriver\chrome.js

And getting the message: at Error (native) at ServiceBuilder [...mypath: (numbers) ] at getDefaultService [...mypath: (numbers)] at Function.createSession [...mypath: (numbers)] at createDriver [...mypath: (numbers)] at Builder.buil [...mypath: (numbers)]

at repl:1:60 at sigintHandlersWrap (vm.js.22:35) at sigintHandlersWrap (vm.js:73:12) at ContextifyScript.Script.runInThisContext

Please help! Thanks in advance .

Daniel Riches
Daniel Riches
19,847 Points

I'm getting the same error. I'm using Windows 10 and I'm not sure what to specify in my Environment Variables or where I should actually install ChromeDriver.

This gave me somewhat of more understanding, but ultimately I'm still lost too.: https://simpleprogrammer.com/2014/02/03/selenium-with-node-js/

I watched a couple of other videos on YouTube, but still no luck. This one kind of helps in that I can run ChromeDriver from the command line when I'm in the folder where I installed the chromedriver and specified in my Environment Variables, but not from the folder where I have Selenium: https://www.youtube.com/watch?v=dz59GsdvUF8.

Looking forward to any exact directions to get it working in a folder structure t=similar to this video.

I later went and watched this and thought I had found the answer, but... not quite: https://teamtreehouse.com/library/console-foundations/environment-and-redirection/environment-variables

Maybe it will help you though. If you figure it out, please let me know

5 Answers

Daniel Riches
Daniel Riches
19,847 Points

I think that I might have a solution. I previously added a comment with some links to information. I will soon try and find out if I needed to actually change the Environment Variable of Path or not, but that was part of my solution.

While in my directory for selenium-basics which I created for this course and have all of the program files, in the console I did the command 'where chromedriver' and I got the file path to the folder where the .exe file exists. I then added this file path to my PATH Environment Variable. It still did not work so I'm not sure whether I needed to do that. I'm pretty sure that changing the PATH for me was unnecessary. I think maybe you just need to add require('chromedriver');

What ultimately fixed the issue was this line at the top of my file: require('chromedriver');

I would try adding that first if you do not have it

I'll watch the tutorial again to see if I missed it, but found this info here: https://www.npmjs.com/package/chromedriver

So, ultimately I created this file: first_test.js

which contains this code:

require('chromedriver'); const selenium = require('selenium-webdriver'); const driver = new selenium.Builder().forBrowser("chrome").build(); const url = "http://google.com";

driver.get(url);

then node first_test.js

It worked in the console too. I hope this helps. Sorry for the rambling, I'm testing it as I write. Good luck.

Alex P
Alex P
99 Points

Thanks so much Daniel! It now worked!

This is what I did in the cmd line :

cd selenium-basics 
node
require('chromedriver');
const selenium = require('selenium-webdriver'); 
const driver = new selenium.Builder().forBrowser("chrome").build(); 
const url = "http://port...etc...treehouse-app.com/";
driver.get(url);

then I had to give "pop-up" permissions on the specific url in order to reach the treehouse page correctly.

I'm using Windows 7

Bryce Gerard
PLUS
Bryce Gerard
Courses Plus Student 375 Points

It's still not working for me. How come an official answer hasn't been posted yet? This question has been up for months.

Aleksey Papushin
Aleksey Papushin
5,554 Points

If you experiencing this issue on Windows, consider following solution which helped me.

  1. Install chromedriver locally - from command line opened in your project folder and without '-g' flag: npm install chromedriver
  2. Then use firstly require('chromedriver'); and then use commands that provided in lesson. Good luck!
Richard Preske
Richard Preske
Courses Plus Student 4,356 Points

This is the error I get: C:\Windows>cd C:\Windows

C:\Windows>cd ..

C:>cd program files

C:\Program Files>cd nodejs

C:\Program Files\nodejs>cd selenium basics

C:\Program Files\nodejs\selenium basics>chromedriver --version ChromeDriver 81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776})

C:\Program Files\nodejs\selenium basics>node Welcome to Node.js v12.16.1. Type ".help" for more information.

require('chromedriver'); Uncaught Error: Cannot find module 'chromedriver' Require stack:

  • <repl> at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15) at Function.Module._load (internal/modules/cjs/loader.js:864:27) at Module.require (internal/modules/cjs/loader.js:1044:19) at require (internal/modules/cjs/helpers.js:77:18) { code: 'MODULE_NOT_FOUND', requireStack: [ '<repl>' ] }

I'll try installing locally. Thanks.

Uri Ben Jacob
Uri Ben Jacob
2,223 Points

I'm getting the same error but i got the latest version(v2.35) and it seems the error comes from a different problem connecting to something else .

I'm bumping this question! I was even directed to enter:

const selenium = require("selenium-webdriver@3");

However, everything I enter comes up with an error, even:

require('chromedriver');