Permalink
Browse files

fixes #93

skip closed browsers when setting Selenium timeout
  • Loading branch information...
1 parent 966a4c5 commit 5c033cea15aa4f7056885839d78f9ade88fe6578 @ombre42 ombre42 committed Dec 10, 2012
@@ -342,7 +342,7 @@ def set_selenium_timeout(self, seconds):
"""
old_timeout = self.get_selenium_timeout()
self._timeout_in_secs = robot.utils.timestr_to_secs(seconds)
- for browser in self._cache.browsers:
+ for browser in self._cache.get_open_browsers():
browser.set_script_timeout(self._timeout_in_secs)
return old_timeout
@@ -1,6 +1,7 @@
import unittest
from Selenium2Library.keywords._browsermanagement import _BrowserManagementKeywords
from selenium import webdriver
+from mockito import *
class BrowserManagementTests(unittest.TestCase):
@@ -54,6 +55,21 @@ def test_create_remote_browser_with_desired_prefs(self):
self.verify_browser(webdriver.Remote, "chrome", remote="http://127.0.0.1/wd/hub",
desired_capabilities=expected_caps)
+ def test_set_selenium_timeout_only_affects_open_browsers(self):
+ bm = _BrowserManagementKeywords()
+ first_browser, second_browser = mock(), mock()
+ bm._cache.register(first_browser)
+ bm._cache.close()
+ verify(first_browser).quit()
+ bm._cache.register(second_browser)
+ bm.set_selenium_timeout("10 seconds")
+ verify(second_browser).set_script_timeout(10.0)
+ bm._cache.close_all()
+ verify(second_browser).quit()
+ bm.set_selenium_timeout("20 seconds")
+ verifyNoMoreInteractions(first_browser)
+ verifyNoMoreInteractions(second_browser)
+
def verify_browser(self , webdriver_type , browser_name, **kw):
#todo try lambda *x: was_called = true

0 comments on commit 5c033ce

Please sign in to comment.