base.py 989 B

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