Metadata-Version: 2.1
Name: selenium-elements
Version: 0.0.1
Summary: Page object model made easy.
Home-page: https://github.com/danclaudiupop/selenium_elements
Author: Dan Claudiu Pop
Author-email: danclaudiupop@gmail.com
License: BSD 2-Clause License
Keywords: selenium,tests,page model
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Utilities
Requires-Python: >=3.7
Requires-Dist: selenium

========
Overview
========



Page object model made easy.

* Free software: BSD 2-Clause License

Installation
============

::

    pip install selenium-elements

Documentation
=============


To use the project:

.. code-block:: python

    import pytest
    from selenium import webdriver
    from selenium.webdriver.common.by import By

    from src.page import Region, Page
    from .elements import PageElement, PageElements
    from .validators import title_matches, url_contains
    from .elements import RegionElements, RegionElement


    class Show(Page):
        path = '/show/{show_slug}/'
        page_title_pattern = '^[A-az-Z] | PBS$'


    class PromoShowRegion(Region):
        title_element = PageElement(By.CLASS_NAME, 'carousel--show-strip__image-link')

        def open(self):
            self.title_element.click()
            return Show(driver=self.driver, base_url=self.base_url, visit=False)

        def title(self):
            return self.title_element.get_attribute('data-gtm-label')


    class Home(Page):
        path = '/'
        load_timeout = 30
        validators = [
            title_matches('^PBS: Public Broadcasting Service$'),
            url_contains('pbs.org/'),
        ]

        promo_show_elements = PageElements(By.CLASS_NAME, 'show-promo')
        promo_shows = RegionElements(
            region_class=PromoShowRegion, root_element=promo_show_elements
        )


    @pytest.fixture
    def driver():
        driver = webdriver.Chrome()
        yield driver
        driver.quit()


    def test_foo(driver):
        home = Home(driver=driver, base_url='https://www.pbs.org')
        breakpoint()
        for show in home.promo_shows:
            print(show.title())
        # show = home.promo_shows[0].open()
        # show_page = Show(driver, base_url='https://www.pbs.org', show_slug='frontline')
        breakpoint()
        assert True




