diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index 08e2f04254..c238ff862a 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -73,9 +73,8 @@ def css_click(css_selector, index=0, max_attempts=5, success_condition=lambda: T for _ in range(max_attempts): try: world.css_find(css_selector)[index].click() - if not success_condition(): - raise Exception("unsuccessful click") - return + if success_condition(): + return except WebDriverException: # Occasionally, MathJax or other JavaScript can cover up # an element temporarily. @@ -118,6 +117,8 @@ def css_check(css_selector, index=0, max_attempts=5, success_condition=lambda: T else: # try once more, letting exceptions raise world.css_find(css_selector)[index].check() + if not success_condition(): + raise Exception("unsuccessful check") @world.absorb