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

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.0.tar.gz (11.4 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.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: web-bricks-0.1.0.tar.gz
  • Upload date:
  • Size: 11.4 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.0.tar.gz
Algorithm Hash digest
SHA256 7b42f0f0893c8f4bcc5c0a0e560bead148162cbdf6839dc4b1db9029b63bd5f3
MD5 829f8b8edb29ba2d060e9974e8426cff
BLAKE2b-256 dc467e47b78d022f020e32c362fee3084863fda2b7c71c75b0e26e62479d6392

See more details on using hashes here.

File details

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

File metadata

  • Download URL: web_bricks-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 747725aa2757f23dd7d4e1de8dd7cfca403db8cee952bd46da1a91f74b66102a
MD5 6a311180f059a302ec5dd3e8c8bd0c34
BLAKE2b-256 501a49123a56dbc821483f8212c6aadd25afd461a32b804255b1248a75e6916d

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