From 05669faddeface208e753134648c0ff6428ade9d Mon Sep 17 00:00:00 2001 From: Will Daly Date: Wed, 2 Oct 2013 11:20:25 -0400 Subject: [PATCH] Catch WebDriver exceptions when creating selenium browser --- common/djangoapps/terrain/browser.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/djangoapps/terrain/browser.py b/common/djangoapps/terrain/browser.py index f40108eb3a..2699dc8dfc 100644 --- a/common/djangoapps/terrain/browser.py +++ b/common/djangoapps/terrain/browser.py @@ -99,16 +99,18 @@ def initial_setup(server): success = False num_attempts = 0 while (not success) and num_attempts < MAX_VALID_BROWSER_ATTEMPTS: - world.browser = Browser(browser_driver) - # Try to visit the main page - # If the browser session is invalid, this will + # Load the browser and try to visit the main page + # If the browser couldn't be reached or + # the browser session is invalid, this will # raise a WebDriverException try: + world.browser = Browser(browser_driver) world.visit('/') except WebDriverException: - world.browser.quit() + if hasattr(world, 'browser'): + world.browser.quit() num_attempts += 1 else: