4
0

setup_args2.py 860 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python3
  2. """Prepare the argument-form 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_form(driver):
  11. _wait_for_body_attr(driver, "loaded-dashboard")
  12. action = driver.find_element(By.CSS_SELECTOR, '[title="Print a message"]')
  13. action.click()
  14. _wait_for_body_attr(driver, "loaded-argument-form")
  15. def run(driver):
  16. _open_form(driver)
  17. driver.execute_script(
  18. """
  19. const input = document.getElementById('message');
  20. if (input && !input.value) {
  21. input.value = 'Hello World';
  22. }
  23. """
  24. )
  25. time.sleep(0.2)