Skip to main content

A small library for simplifying a table object in selenium

Project description

selenium-datatable

Build Status codecov

Overview

A small library for simplifying a table object in selenium

Installation

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 setup.py install

Example of use

Items list implementation:

# -- FILE: table.py
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: home_page.py
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):
        self.driver.get(self.url)

Use in Unittest:

# -- FILE: test_table.py
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)
        page.open()
        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(item.email.text, 'jsmith@gmail.com')

    def tearDown(self):
            self.driver.close()

Project details


Download files

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

Source Distribution

selenium_datatable-0.2.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

selenium_datatable-0.2.0-py2.py3-none-any.whl (8.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file selenium_datatable-0.2.0.tar.gz.

File metadata

  • Download URL: selenium_datatable-0.2.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.3

File hashes

Hashes for selenium_datatable-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b5c80dce93da5345517c65be6f55016d09a20f3b8d216b65edeccada1aa9c707
MD5 9959a61480f11a31192ac18e9faf625d
BLAKE2b-256 531162940257dbb3abf97562e109f36116ce45acdd78e5c28423994a976fb248

See more details on using hashes here.

File details

Details for the file selenium_datatable-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: selenium_datatable-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.3

File hashes

Hashes for selenium_datatable-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4cd2a9b50100c9ef715ec1bf91b36a459d41c82a2778ac3101fb00323f12f178
MD5 b6d0bfde40840a19d34d9ecd03da1e8d
BLAKE2b-256 db1c4bdba9d8dda68df56612508c07a003e53661e1428739ff5e1ade1e55bffd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page