base.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. from selenium.webdriver.common.by import By
  2. class BasePage:
  3. """Base class for PageObjects"""
  4. def __init__(self, browser):
  5. self.browser = browser
  6. @property
  7. def driver(self):
  8. return self.browser.driver
  9. def wait_until_loaded(self):
  10. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  11. class BaseElement:
  12. def __init__(self, element):
  13. self.element = element
  14. class ButtonElement(BaseElement):
  15. label_attr = "aria-label"
  16. disabled_attr = "aria-disabled"
  17. @property
  18. def disabled(self):
  19. return self.element.get_attribute(self.disabled_attr)
  20. @property
  21. def label(self):
  22. return self.element.get_attribute(self.label_attr)
  23. def click(self):
  24. self.element.click()
  25. class ButtonWithIconElement(ButtonElement):
  26. @property
  27. def icon_href(self):
  28. return self.element.find_element(by=By.TAG_NAME, value="use").get_attribute("href")
  29. class TextBoxElement(BaseElement):
  30. pass
  31. class ModalElement(BaseElement):
  32. pass