Skip to main content

A small library for simplifying a table object in selenium

Project description


Build Status codecov


A small library for simplifying a table object in selenium


If you have pip on your system, you can simply install or upgrade the Python bindings:

pip install selenium-datatable

Alternately, you can download the source code and run:

python install

Example of use

Items list implementation:

# -- FILE:
from selenium_datatable import RowItem, Container

class UserItem(RowItem):
    locators_template = {
        'last_name': ("css", "tr:nth-of-type({row}) td:nth-of-type(1)"),
        'first_name': ("css", "tr:nth-of-type({row}) td:nth-of-type(2)"),
        'email': ("css", "tr:nth-of-type({row}) td:nth-of-type(3)"),
        'due': ("css", "tr:nth-of-type({row}) td:nth-of-type(4)"),
        'web_site': ("css", "tr:nth-of-type({row}) td:nth-of-type(5)"),
        'delete_button': ("css", "tr:nth-of-type({row}) td:nth-of-type(6) a[href='#delete']"),
        'edit_button': ("css", "tr:nth-of-type({row}) td:nth-of-type(6) a[href='#edit']"),

class UserItems(Container):
    item = UserItem()
    rows_locator = ("css selector", "tbody > tr")
    headers_locator = ("css selector", "tbody > tr")    

Example of page object class implementation:

# -- FILE:
from table import UserItems

class HomePage:    
    items_list = UserItems("id", "table1")

    def __init__(self, driver, url='http://localhost/tables'):
        self.driver = driver
        self.url = url           

    def open(self):

Use in Unittest:

# -- FILE:
import unittest
from selenium.webdriver import Chrome
from home_page import HomePage

class TestTable(unittest.TestCase):

    def setUp(self):
        self.driver = Chrome()

    def test_get_item_from_first_row(self):
        page = HomePage(self.driver)
        item = page.items_list.get_item_by_position(1)

        self.assertEqual(item.first_name.text, 'John')
        self.assertEqual(item.last_name.text, 'Smith')
        self.assertEqual(, '')

    def tearDown(self):

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for selenium-datatable, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size selenium_datatable-0.2.0-py2.py3-none-any.whl (8.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size selenium_datatable-0.2.0.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page