Skip to main content

Page Object constructor for UI automation

Project description

Web-Bricks

Install

python3 -m pip install web-bricks

Usage

from web_bricks import WebBricksConfig, web_resolver, WebBrick, many, checkable
from typing import List


# at PageObject:

# просто какая то функция композиции локаторов
def make_locator(val):
    return {'by': 'css', 'value': val}


class WebElement(WebBrick):
    def click(self):
        return checkable(self).click().apply()
    
    def get_text(self):
        return checkable(self).text  # driver method
    
    def text(self):
        return self.get_text().apply()


class SubElement(WebElement):
    pass


class MoreSubElement(WebElement):
    pass


class RootPage(WebElement):
    @property
    def sub_page(self) -> SubElement:
        locator = make_locator('some')
        return SubElement(self, locator)

    @property
    def sub_elements(self) -> List[MoreSubElement]:
        return many(MoreSubElement(self, locator=make_locator('another')))


# at TearUp:

selenium_resolver_config = WebBricksConfig(
    resolver=web_resolver(waiter=SeleniumWaiter, timeout=10)
)
selenium_driver = webdriver.Remote(...)
root_page = RootPage(selenium_driver, locator=make_locator(':root'), config=selenium_resolver_config)

# at Test:
root_page.sub_page.resolved_element.click()
root_page.sub_elements[1].resolved_element.click()
root_page.sub_elements[1].resolved_element.text

Для тсабильного выполнения без stale element

TODO

Для полного разрешения

TODO

Для каскадного разрешения элементов

TODO

Свой резолвер

TODO

TODO

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

web-bricks-0.1.2.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

web_bricks-0.1.2-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file web-bricks-0.1.2.tar.gz.

File metadata

  • Download URL: web-bricks-0.1.2.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for web-bricks-0.1.2.tar.gz
Algorithm Hash digest
SHA256 944b0516b57585b1b47918ed3a0fe16fc6d51725d15be95a6127c07ae4ab580e
MD5 c4bad311d8319369f4513e68c4d9ea6b
BLAKE2b-256 1c3f472501e1c05cd3388b3ffc8b04b3ef3e1454477d51ee4806b5d2a547587d

See more details on using hashes here.

File details

Details for the file web_bricks-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: web_bricks-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for web_bricks-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05387293b403704fc5eb1f8ac8e3c41871b08eea6fa9033c220b66aa31082a3f
MD5 3611466cf66790d00d3d590e2a94f835
BLAKE2b-256 0662337e6cb8b2bcd5640630f2dfb22e4e50e66414ffb8184643d3cbdb6f3dd2

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