From 1ba37d95b5a8bc8fb889530cc5a0779d38047b2a Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Mon, 7 Aug 2023 16:13:02 +0000 Subject: [PATCH] More concise wait. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4391 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- tools/autotest.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/autotest.py b/tools/autotest.py index 83939034c..70e373d4e 100644 --- a/tools/autotest.py +++ b/tools/autotest.py @@ -23,6 +23,7 @@ try: options = webdriver.FirefoxOptions() #options.add_argument('--headless') driver = webdriver.Firefox(options = options) + wait = WebDriverWait(driver, 30) driver.get('http://localhost:8888') driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.LINK_TEXT, 'login').click() driver.find_element(By.ID, 'register').click() @@ -32,15 +33,15 @@ try: driver.find_element(By.ID, 'loginButton').click() driver.switch_to.frame(driver.find_element(By.ID, 'document')) - WebDriverWait(driver, 30).until(expected_conditions.presence_of_element_located((By.LINK_TEXT, 'ssb'))).click() + wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, 'ssb'))).click() driver.switch_to.default_content() - driver.switch_to.frame(WebDriverWait(driver, 30).until(expected_conditions.presence_of_element_located((By.ID, 'document')))) - tf_app = WebDriverWait(driver, 30).until(expected_conditions.presence_of_element_located((By.TAG_NAME, 'tf-app'))).shadow_root - WebDriverWait(driver, 30).until(expected_conditions.element_to_be_clickable(tf_app.find_element(By.ID, 'create_identity'))).click() - WebDriverWait(driver, 30).until(expected_conditions.alert_is_present()).accept() + driver.switch_to.frame(wait.until(expected_conditions.presence_of_element_located((By.ID, 'document')))) + tf_app = wait.until(expected_conditions.presence_of_element_located((By.TAG_NAME, 'tf-app'))).shadow_root + wait.until(expected_conditions.element_to_be_clickable(tf_app.find_element(By.ID, 'create_identity'))).click() + wait.until(expected_conditions.alert_is_present()).accept() - tf_tab_news = WebDriverWait(driver, 30).until(exists_in_shadow_root(tf_app, By.ID, 'tf-tab-news')).shadow_root + tf_tab_news = wait.until(exists_in_shadow_root(tf_app, By.ID, 'tf-tab-news')).shadow_root tf_tab_news.find_element(By.ID, 'tf-compose').shadow_root.find_element(By.ID, 'edit').send_keys('Hello, world!') tf_tab_news.find_element(By.ID, 'tf-compose').shadow_root.find_element(By.ID, 'submit').click()