This is the fool proof method to install geckodriver (for Friefox) or chromedriver (for Google Chrome) in Ubuntu.
Step 1: quickly update your computer
$ sudo apt update
$ sudo apt upgrade
Step 2: Next visit ChromeDriver’s website and Geckodriver’s website to download the appropriate version
To see which version you currently have installed
$ google-chrome --version
$ firefox --version // you dont need to know the version for firefox
To download and unzip (my version is 94):
$ wget https://chromedriver.storage.googleapis.com/94.0.4606.61/chromedriver_linux64.zip
$ unzip chromedriver_linux64.zip$ wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz
$ tar -zxvf geckodriver-v0.30.0-linux64.tar.gz
Step 3: Moved the files to PATH in an organised manner
Moved them in bin so that they are at an organised location but also in PATH.
$ sudo mv chromedriver /usr/bin/chromedriver
$ sudo chown root:root /usr/bin/chromedriver
$ sudo chmod +x /usr/bin/chromedriver$ sudo mv geckodriver /usr/bin/geckodriver
$ sudo chown root:root /usr/bin/geckodriver
$ sudo chmod +x /usr/bin/geckodriver
Done!!
Now the following code can be run without specifying the exact location of the geckodriver and
from selenium import webdriver
browser = webdriver.Chrome()
browser.get('https://medium.com/@seehleung')