Skip to content

Commit e4b10e1

Browse files
François Freitaglukeis
authored andcommitted
Firefox: Actually use launch_browser timeout
Until this commit, _wait_until_connectable waited for 30 seconds, no matter the timeout value given in the Firefox WebDriver __init__(). Fixes SeleniumHQ#1300 Signed-off-by: Luke Inman-Semerau <[email protected]>
1 parent 9c2e49e commit e4b10e1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

py/selenium/webdriver/firefox/extension_connection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def __init__(self, host, firefox_profile, firefox_binary=None, timeout=30):
3434
self.profile = firefox_profile
3535
self.binary = firefox_binary
3636
HOST = host
37+
timeout = int(timeout)
38+
3739
if self.binary is None:
3840
self.binary = FirefoxBinary()
3941

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

4749
self.profile.add_extension()
4850

49-
self.binary.launch_browser(self.profile)
51+
self.binary.launch_browser(self.profile, timeout=timeout)
5052
_URL = "http://%s:%d/hub" % (HOST, PORT)
5153
RemoteConnection.__init__(
5254
self, _URL, keep_alive=True)

py/selenium/webdriver/firefox/firefox_binary.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ def __init__(self, firefox_path=None, log_file=None):
5858
def add_command_line_options(self, *args):
5959
self.command_line = args
6060

61-
def launch_browser(self, profile):
61+
def launch_browser(self, profile, timeout=30):
6262
"""Launches the browser for the given profile name.
6363
It is assumed the profile already exists.
6464
"""
6565
self.profile = profile
6666

6767
self._start_from_profile_path(self.profile.path)
68-
self._wait_until_connectable()
68+
self._wait_until_connectable(timeout=timeout)
6969

7070
def kill(self):
7171
"""Kill the browser.
@@ -89,7 +89,7 @@ def _start_from_profile_path(self, path):
8989
command, stdout=self._log_file, stderr=STDOUT,
9090
env=self._firefox_env)
9191

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

0 commit comments

Comments
 (0)