Categories
90 Seconds Video

≤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).

Steps:

1.

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

2.

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

3.

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

4.

sudo cp geckodriver /usr/lib

5.

pip3 install selenium

6.

vi verify.py
#!/usr/bin/env python
from selenium import webdriver
browser = webdriver.Firefox() 
browser.get('http://www.google.com/')

7.

python verify.py

8.

vi test_selenium.py
from selenium import webdriver
class TestGoogle(unittest.TestCase):
  def setUp(self):
    self.browser = webdriver.FireFox()
  def test_title(self): 
    self.browser.get('http://www.google.com/') 
    self.assertIn('Google', self.browser.title)
  def tearDown(self):
    self.browser.close()

if __name__ == '__main__':
  unittest.main()

9.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Your subscription could not be saved. Please try again.
Your subscription has been successful.

 Join our mailing list!

 Be the first to know about new articles and videos.