Skip to main content

Python based Page Factory.

Project description

Pythium


Python based Page Factory design pattern test library, similar to Java's Page Factory pattern, designed to reduce code redundancy, easy to use, are very descriptive, make the code more readable and understandable and with a high degree of scalability.

  • Supports locate element with annotation
  • Supports multiple positioning methods for the same element
  • Supports dynamically locate element

Install


pip install pythium

Usage


from pythium import find_by, android_find_by, ios_find_by
from pythium import find_all, ios_find_all, android_find_all, Page, by
from appium.webdriver.webelement import WebElement as MobileElement
from selenium.webdriver.remote.webelement import WebElement
from typing import Any, List


class LoginPage(Page):

    @find_by(css=".search")
    @ios_find_by(ios_predicate='value == "Search something"')
    @android_find_by(android_uiautomator='resourceId("com.app:id/search_txtbox")')
    def search_input(self) -> WebElement: ...

    @property
    @find_by(css=".search")
    @ios_find_by(ios_predicate='value == "Search something"')
    @android_find_by(android_uiautomator='resourceId("com.app:id/search_txtbox")')
    def search_input_with_property(self) -> WebElement: ...

    @property
    @find_all(by(css=".icon-logo1"), by(css=".icon-logo"))
    def find_all_web_test(self) -> WebElement: return Any

    @property
    @ios_find_all(by(ios_predicate='value == "Search something"'), by(ios_predicate='value == "Search result"'))
    @android_find_all(by(android_uiautomator='resourceId("com.app:id/search_txtbox")'),
                      by(android_uiautomator='resourceId("com.app:id/search_txtbox")'))
    def find_all_mobile_test(self) -> WebElement: return Any

    # for dynamical locator
    @find_by(xpath="//div[{n}]/a[{k}]/div[{m}]/{f}")
    @ios_find_by(xpath="//div[1]/a[{n}]/div[{k}]")
    def dynamical_locator(self, n, k, m=4, f=6) -> WebElement: ...

    # for list WebElements
    @find_by(css=".login")
    def list_web_elements(self) -> List[MobileElement]: ...

    def _is_loaded(self):
        print("implement something...")


if __name__ == '__main__':
    from selenium import webdriver

    driver = webdriver.Chrome()
    login = LoginPage(driver)
    # no @property
    login.search_input().click()
    # with @property
    login.search_input_with_property.click()
    # for dynamical locator
    login.dynamical_locator(2, 3, 4, 5).click()
    # for list WebElement
    print(len(login.list_web_elements()))

The@find_all, @ios_find_all, @android_find_all annotations locates the web element using more than one criteria,

given that at least one criteria match. it uses an OR conditional relationship between the multiple @xxx_find_by.

example: @find_all(by(css=".icon-logo1"), by(id="icon"))

first will find element by(css=".icon-logo1"), if found, return WebElement;

if not found, will find element by(id="icon"), if found, return WebElement, if not found, will raise Exception.

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

pythium-1.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

pythium-1.1.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file pythium-1.1.0.tar.gz.

File metadata

  • Download URL: pythium-1.1.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.2

File hashes

Hashes for pythium-1.1.0.tar.gz
Algorithm Hash digest
SHA256 ef68f972e9888c7f5f75d925c56066d1ed4a20be6a7e6a7463f0b51777f9dfdc
MD5 4001efa3d358301ddd7d1da53be7c380
BLAKE2b-256 4b482d6823297f2e0337b388b03ffcf2172e1a5338d8f736e211e31a1efb149c

See more details on using hashes here.

File details

Details for the file pythium-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pythium-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.2

File hashes

Hashes for pythium-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f95c4e6b4ba45726122ddefbfc743c0a5ae09bb00cfe59cbe47c5cf91325c97
MD5 529a1af7ee672672a404542eec01fc9e
BLAKE2b-256 3254b48a08c67841444a278d5b50566c60d19076f8cf3b82abf5cf64c5449d4b

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