Β· Steve Grice Β· 90 seconds or less  Β· 1 min read

≀90s: Install Selenium for Python on Ubuntu

In this video, we learn how to set up Selenium in 90 seconds or less! Made using Ubuntu on Windows (WSL). You may need to start an Xming server if you use this method (I did).


1. Install packages.

sudo apt update && sudo apt install python3 python3-pip firefox

2. Download geckodriver.

wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz

3. Untar geckodriver.

tar xvf geckodriver-v0.26.0-linux64.tar.gz

4. Copy geckodriver into system PATH.

Edit: /usr/local/lib may be more appropriate than /usr/lib because /usr/local/lib is typically the place for user-installed software (whereas /usr/lib is for the package manager). Use whichever you prefer, but if you decide to use /usr/local/lib, make sure that it is in your $PATH environment variable.

sudo cp geckodriver /usr/lib

5. Install the selenium Python package.

pip3 install selenium

6. Edit verify.py and make sure Selenium is working.

vi verify.py
#!/usr/bin/env python
from selenium import webdriver
browser = webdriver.Firefox() 

7. Run the test script.

python verify.py

8. Try writing a unit test with Selenium.

vi test_selenium.py
from selenium import webdriver

class TestGoogle(unittest.TestCase):
  def setUp(self):
    self.browser = webdriver.FireFox()
  def test_title(self): 
    self.assertIn('Google', self.browser.title)
  def tearDown(self):

if __name__ == '__main__':

9. Run your test.

python test_selenium.py

Need Python? We have a tutorial for that, too! Install Python in 90 seconds or less on Windows or on Ubuntu.

Back to Blog