setup_gitops.py 1009 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python3
  2. """Open the GitOps dashboard from solutions/on-git-push/index.adoc."""
  3. import time
  4. from selenium.webdriver.common.by import By
  5. from selenium.webdriver.support.ui import WebDriverWait
  6. def _wait_for_gitops_dashboard(driver, timeout=30):
  7. WebDriverWait(driver, timeout).until(
  8. lambda d: d.find_element(By.TAG_NAME, "body").get_attribute("loaded-dashboard")
  9. == "GitOps"
  10. )
  11. def ready(d):
  12. required_titles = [
  13. "ServerConfiguration Ansible",
  14. "ServerConfiguration Flux",
  15. "ServerConfiguration Prom",
  16. ]
  17. for title in required_titles:
  18. try:
  19. button = d.find_element(By.CSS_SELECTOR, f'[title="{title}"]')
  20. except Exception:
  21. return False
  22. if not button.is_displayed():
  23. return False
  24. return True
  25. WebDriverWait(driver, timeout).until(ready)
  26. def run(driver):
  27. _wait_for_gitops_dashboard(driver)
  28. time.sleep(0.2)