Adding drivers to System Path - aclaudio123/selenium-tutorial GitHub Wiki

To avoid hard coding absolute paths to drivers or executables, you should add them to system variables.

Mac Setup:

  1. Download the drive from the Internet e.g. https://github.com/mozilla/geckodriver/releases
  2. Extract the driver or executable and save at any location on your computer
    • Assume you have a project folder called SeleniumProject
    • Navigate to the project location using Mac Finder
    • Create a folder and name it “libs”
    • Copy the extracted file to this location
    • Get the complete path of the location
    • Example path: /Users/username/Documents/SeleniumProject/libs

Open terminal: Click command + space keys and type terminal. This will open terminal

Open .bash_profile file:

  1. On terminal, type
nano ~/.bash_profile

or open as text editor
open ~/.bash_profile
  1. Inside the file, type:
PATH="absolute_path_of_your_libs_directory:${PATH}"
export PATH
  1. Save the file: ctrl + o
  2. Exit the file: ctrl + x
  3. Source the file by typing this on terminal source ~/.bash_profile or restart your system

Windows Setup

  1. Go to My Computer -> Properties -> Advanced System Settings
  2. Click on Environmental Variable
  3. In system Variable, select Path and click Edit
  4. Enter the following information in the variable value: Example Location: C:\Users\username\Documents\libs
  5. Click OK button
  6. Restart the system.

NOTE: Multiple directories need to be separated by semi colon. Example:

C:\Program Files; C:\Users\username\workspace\libs