setup_dropdown_entities.py 911 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python3
  2. """Prepare the entity-backed dropdown screenshot."""
  3. import time
  4. from selenium.webdriver.common.by import By
  5. from selenium.webdriver.support.ui import WebDriverWait
  6. def _wait_for_body_attr(driver, attr, timeout=15):
  7. WebDriverWait(driver, timeout).until(
  8. lambda d: bool(d.find_element(By.TAG_NAME, "body").get_attribute(attr))
  9. )
  10. def _open_choice_list(driver, input_id):
  11. combobox_input = driver.find_element(By.ID, input_id)
  12. combobox_input.click()
  13. WebDriverWait(driver, 15).until(
  14. lambda d: len(d.find_elements(By.CSS_SELECTOR, ".choice-combobox-list li")) >= 2
  15. )
  16. def run(driver):
  17. _wait_for_body_attr(driver, "loaded-dashboard")
  18. driver.find_element(By.CSS_SELECTOR, '[title="restart container"]').click()
  19. _wait_for_body_attr(driver, "loaded-argument-form")
  20. _open_choice_list(driver, "containerToRestart")
  21. time.sleep(0.2)