diff --git a/plinth/modules/ttrss/tests/test_functional.py b/plinth/modules/ttrss/tests/test_functional.py index 89009f9bc..c67d99f52 100644 --- a/plinth/modules/ttrss/tests/test_functional.py +++ b/plinth/modules/ttrss/tests/test_functional.py @@ -49,18 +49,27 @@ def _click_main_menu_item(browser, text): def _subscribe(browser): """Subscribe to a feed in TT-RSS.""" + + def _already_subscribed_message(): + return browser.is_text_present( + 'You are already subscribed to this feed.') + _ttrss_load_main_interface(browser) _click_main_menu_item(browser, 'Subscribe to feed...') browser.find_by_id('feedDlg_feedUrl').fill( 'https://planet.debian.org/atom.xml') browser.find_by_text('Subscribe').click() - if browser.is_text_present('You are already subscribed to this feed.'): + add_dialog = browser.find_by_css('#feedAddDlg') + functional.eventually( + lambda: not add_dialog.visible or _already_subscribed_message()) + if _already_subscribed_message(): browser.find_by_text('Cancel').click() + functional.eventually(lambda: not add_dialog.visible) expand = browser.find_by_css('span.dijitTreeExpandoClosed') if expand: - expand.first.click() + functional.eventually(expand.first.click) assert functional.eventually(_is_feed_shown, [browser]) diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py index 9ea5bc4bb..5a75812d9 100644 --- a/plinth/tests/functional/__init__.py +++ b/plinth/tests/functional/__init__.py @@ -64,8 +64,11 @@ def eventually(function, args=[], timeout=30): end_time = time.time() + timeout current_time = time.time() while current_time < end_time: - if function(*args): - return True + try: + if function(*args): + return True + except Exception: + pass time.sleep(0.1) current_time = time.time()