Selenium TestCases with Holmium in Python

Reading Time: 1 minute

Holmium core is nose plugin that provides utilities for simplifying the creation and maintenance of tests that rely on Selenium. Holmium introduce concept of Page Objects reduces the coupling and allow test authors to separate the layout of the page under test and the functional behaviour being tested.This separation also results in more maintainable test code.

Installation of the Holmium:
Assuming you have Nose module installed on the Machine. If not check out my Nose installation post.

[code]pip install holmium.core[/code]

Importing Holmium in Project:
First you have to Import the the TestCase, Page , Element and Locators.

[python]from holmium.core import TestCase, Page, Element, Locators, ElementMap
import unittest[/python]

Adding Test Cases:
Lets add Login Test Cases into the project with the Login functionality. Create a class LoginPage ( A Page object class) with inherit the Page of the Holmium.core and will be used to get the elements on the that page and sending keys to them.

[python]class LoginPage(Page):
userNameText = Element(Locators.NAME, ‘userName’)
passwordText = Element(Locators.NAME, ‘password’)
submitButton = Element(Locators.NAME, ‘login’)</pre>
def login(self):

Lets add another class LoginTest which inherit the Test Case from the Holmium.core and only be used to assert the desired functionality.

[python]class LoginTest(TestCase):
def setUp(self): = LoginPage(self.driver,

def test_Login(self):
"Find a Flight: Mercury Tours:")

def tearDown(self):

Running the Code with the nose:

Final code with Running Test results.

Source Code Here.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.