Skip to content

Commit

Permalink
Firefox: Actually use launch_browser timeout
Browse files Browse the repository at this point in the history
Until this commit, _wait_until_connectable waited for 30 seconds, no
matter the timeout value given in the Firefox WebDriver __init__().

Fixes #1300

Signed-off-by: Luke Inman-Semerau <luke.semerau@gmail.com>
  • Loading branch information
François Freitag authored and lukeis committed Feb 10, 2016
1 parent 9c2e49e commit e4b10e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion py/selenium/webdriver/firefox/extension_connection.py
Expand Up @@ -34,6 +34,8 @@ def __init__(self, host, firefox_profile, firefox_binary=None, timeout=30):
self.profile = firefox_profile
self.binary = firefox_binary
HOST = host
timeout = int(timeout)

if self.binary is None:
self.binary = FirefoxBinary()

Expand All @@ -46,7 +48,7 @@ def __init__(self, host, firefox_profile, firefox_binary=None, timeout=30):

self.profile.add_extension()

self.binary.launch_browser(self.profile)
self.binary.launch_browser(self.profile, timeout=timeout)
_URL = "http://%s:%d/hub" % (HOST, PORT)
RemoteConnection.__init__(
self, _URL, keep_alive=True)
Expand Down
8 changes: 4 additions & 4 deletions py/selenium/webdriver/firefox/firefox_binary.py
Expand Up @@ -58,14 +58,14 @@ def __init__(self, firefox_path=None, log_file=None):
def add_command_line_options(self, *args):
self.command_line = args

def launch_browser(self, profile):
def launch_browser(self, profile, timeout=30):
"""Launches the browser for the given profile name.
It is assumed the profile already exists.
"""
self.profile = profile

self._start_from_profile_path(self.profile.path)
self._wait_until_connectable()
self._wait_until_connectable(timeout=timeout)

def kill(self):
"""Kill the browser.
Expand All @@ -89,7 +89,7 @@ def _start_from_profile_path(self, path):
command, stdout=self._log_file, stderr=STDOUT,
env=self._firefox_env)

def _wait_until_connectable(self):
def _wait_until_connectable(self, timeout=30):
"""Blocks until the extension is connectable in the firefox."""
count = 0
while not utils.is_connectable(self.profile.port):
Expand All @@ -98,7 +98,7 @@ def _wait_until_connectable(self):
raise WebDriverException("The browser appears to have exited "
"before we could connect. If you specified a log_file in "
"the FirefoxBinary constructor, check it for details.")
if count == 30:
if count >= timeout:
self.kill()
raise WebDriverException("Can't load the profile. Profile "
"Dir: %s If you specified a log_file in the "
Expand Down

1 comment on commit e4b10e1

@ralphiech
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sorting this! Just saved me a lot of pain i guess :)

Please sign in to comment.