This is great option to use when you’re unit testing a web-based application or need to do testing that revolves around using a Web browser.

Selenium is an open-source automation tool used in this situation — . You can use Selenium with pretty much any language you want, but in this example, I’m choosing to use Python 3.

Very easy guide can be found at which will give you the basics on how to install Selenium via pip.

Once you have this installed, you’ll need to make sure you have WebDrivers for each browser you wish to use. In my case, I’m just using Firefox. It’s not explained too well how to use the driver, but essentially you just need to add the driver directory or copy the driver into a directory that is present in your environment path (my OS of choice is Fedora, so this will be the $PATH environment variable).

I’ve taken the example shown in the easy guide, and adjusted based on an excellent tutorial at to show how Python’s unittest library and Selenium work together — I made two small Python files to handle the test:

import unittest
from selenium import webdriver

class BrowserTestCase(unittest.TestCase):

def setUp(self):
    self.browser = webdriver.Firefox()

def testPageTitle(self):
    self.assertIn('Nathan', self.browser.title)

import unittest

# Import our browser test case

import browser_test

# Init test suite

test_loader = unittest.TestLoader()

test_suite = unittest.TestSuite()

# Add tests to suite


# Run the test!

test_runner = unittest.TextTestRunner(verbosity=2)

test_result =

Testing it out…

Leave a Reply

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