Skip to content

Instantly share code, notes, and snippets.

@corysimmons
Last active July 17, 2018 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corysimmons/30ed8a33f1b831c591206f384aa9c135 to your computer and use it in GitHub Desktop.
Save corysimmons/30ed8a33f1b831c591206f384aa9c135 to your computer and use it in GitHub Desktop.
How to get Selenium + chromedriver + Nightwatch working.

https://npm.im/selenium-standalone doesn't work with recent versions of JDK and will cause Nightwatch to explode.

selenium-standalone

export JAVA_HOME=/usr/libexec/java_home -v 1.8
  • Restart shell
  • cd ~/Your Project
  • yarn add -D selenium-standalone
  • selenium-standalone install
  • selenium-standalone start
  • Nightwatch tests should work.

OR

java Command

Download/install the following from their websites in whatever order:

Run this command:

java -Dwebdriver.chrome.driver=/absolute/path/to/chromedriver -jar /absolute/path/to/selenium-server-standalone-3.12.0.jar

Now your Nightwatch tests should work with Chrome.

@mpelzsherman
Copy link

Did you just run selenium-standalone install, or did you have to install manually? Normally it installs chromedriver for you.

@mpelzsherman
Copy link

Also I'm pretty sure the Java install script will handle setting JAVA_HOME for you if you use the Mac OS Preferences app.

@mpelzsherman
Copy link

selenium-standalone is already a dev dependency in ag.js and should be installed by yarn. You shouldn't need to install it with npm.

@corysimmons
Copy link
Author

corysimmons commented Jun 7, 2018

Sorry, added a huge OR to the instructions. Use one method or the other.

selenium-standlone lives in node_modules and makes selenium-standalone install available. selenium-standalone install will install all the drivers to their respective folders in node_modules/selenium-standalone/.selenium, but selenium-standalone doesn't work with JDK 10, so you need to make sure you're using JDK 8 (not sure if 9 works—didn't test it—but 8 works and 7 should).

If you're referring to the Java Preferences under System Preferences, then I didn't see anywhere you could tweak $JAVA_HOME in it. I did see a lot of stuff about certs and I suspect certs might be why JDK 10 wasn't working, but didn't test on an http site.

I think Java will initially handle setting $JAVA_HOME, but if you happen to install JDK 10, then install 8, I don't think it overwrites it ($ java will still refer to 10), so it's safer to instruct people to just manually do it on the chance they did install 10 before 8.

Updated to refer to yarn rather than npm (but this gist can help people other than us, so I'd like to leave in the adding part).

@LinnJS
Copy link

LinnJS commented Jul 17, 2018

Dude thank you for this going through these troubles now... Miss you man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment