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.1.tar.gz
(11.3 kB
view hashes)
Built Distribution
web_bricks-0.1.1-py3-none-any.whl
(12.7 kB
view hashes)
Close
Hashes for web_bricks-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 484fa20a0ba5838b0da1b10fdb01d38373fc0ca129eb6e293c0c407ef657ec17 |
|
MD5 | 2ff3267d16f61d953a81d8bac420a884 |
|
BLAKE2b-256 | a832b6cb5edb3be57116e50016c26eae78859d54691daceb7882c84405a7ffc5 |