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:
- Download the drive from the Internet e.g. https://github.com/mozilla/geckodriver/releases
- 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:
- On terminal, type
nano ~/.bash_profile
or open as text editor
open ~/.bash_profile
- Inside the file, type:
PATH="absolute_path_of_your_libs_directory:${PATH}"
export PATH
- Save the file:
ctrl + o
- Exit the file:
ctrl + x
- Source the file by typing this on terminal
source ~/.bash_profile
or restart your system
Windows Setup
- Go to My Computer -> Properties -> Advanced System Settings
- Click on Environmental Variable
- In system Variable, select Path and click Edit
- Enter the following information in the variable value:
Example Location:
C:\Users\username\Documents\libs
- Click OK button
- Restart the system.
NOTE: Multiple directories need to be separated by semi colon. Example:
C:\Program Files; C:\Users\username\workspace\libs