From dd39ebec03b0ea0be44f3497fda8e2f563bca583 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Wed, 3 Jul 2013 11:46:58 -0400 Subject: [PATCH] If success_condition fails, raise an exception --- common/djangoapps/terrain/ui_helpers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index 474a6c8cfe..39856da3dc 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -73,8 +73,9 @@ 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 success_condition(): - return + if not success_condition(): + raise Exception("unsuccessful click") + return except WebDriverException: # Occasionally, MathJax or other JavaScript can cover up # an element temporarily. @@ -85,6 +86,8 @@ def css_click(css_selector, index=0, max_attempts=5, success_condition=lambda: T else: # try once more, letting exceptions raise world.css_find(css_selector)[index].click() + if not success_condition(): + raise Exception("unsuccessful click") @world.absorb