setup_fieldset.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env python3
  2. """Open My First Dashboard from dashboards/2-fieldsets.adoc."""
  3. import time
  4. from selenium.webdriver.common.by import By
  5. from selenium.webdriver.support.ui import WebDriverWait
  6. def _wait_for_fieldset_dashboard(driver, timeout=30):
  7. WebDriverWait(driver, timeout).until(
  8. lambda d: d.find_element(By.TAG_NAME, "body").get_attribute("loaded-dashboard")
  9. == "My First Dashboard"
  10. )
  11. def ready(d):
  12. try:
  13. folder1 = d.find_element(
  14. By.XPATH,
  15. '//button[contains(@class, "directory-button")]//span[contains(@class, "title") and text()="Folder 1"]',
  16. )
  17. folder2 = d.find_element(
  18. By.XPATH,
  19. '//button[contains(@class, "directory-button")]//span[contains(@class, "title") and text()="Folder 2"]',
  20. )
  21. except Exception:
  22. return False
  23. return all(element.is_displayed() for element in (folder1, folder2))
  24. WebDriverWait(driver, timeout).until(ready)
  25. def run(driver):
  26. _wait_for_fieldset_dashboard(driver)
  27. time.sleep(0.2)