MuraliKola / robotframework-seleniumlibrary

Automatically exported from code.google.com/p/robotframework-seleniumlibrary
Apache License 2.0
1 stars 0 forks source link

Closing browsers fails if open_browser failed to connect to web server #220

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I have a test that starts with "Open Browser" and has "Close All Browsers" in 
Suite Teardown.

"Open Browser" succeeds to start start Firefox but fails to connect to the 
given url. The started browser should be closed by "Close All Browser" in 
teardown but it doesn't happen.

Selenium Library 2.8
Python 2.6
Ubuntu 10.04

The problem is that when self._selenium.open() fails self._cache.register() 
doesn't get called so other keywords are not aware of the started browsers.

diff --git a/src/SeleniumLibrary/browser.py b/src/SeleniumLibrary/browser.py
index d3b755d..3260605 100644
--- a/src/SeleniumLibrary/browser.py
+++ b/src/SeleniumLibrary/browser.py
@@ -77,9 +77,13 @@ class Browser(RunOnFailure):
                                   url)
         self._connect_to_selenium_server()
         self._selenium.set_timeout(self._timeout * 1000)
-        self._selenium.open(url, ignoreResponseCode=True)
-        self._debug('Opened browser with Selenium session id %s'
-                    % self._selenium.sessionId)
+        try:
+            self._selenium.open(url, ignoreResponseCode=True)
+            self._debug('Opened browser with Selenium session id %s'
+                        % self._selenium.sessionId)
+        except:
+            self._cache.register(self._selenium, alias)
+            raise RuntimeError("Open browser failed")
         return self._cache.register(self._selenium, alias)

     def _get_browser(self, browser):

Original issue reported on code.google.com by mika.bat...@gmail.com on 14 Dec 2011 at 3:46

GoogleCodeExporter commented 8 years ago
Thanks for the patch, we'll fix this to 2.9

Original comment by janne.t....@gmail.com on 15 Dec 2011 at 7:15

GoogleCodeExporter commented 8 years ago
This issue was updated by revision 1310fd9b6e2b.

Target: 2.8.1

Original comment by janne.t....@gmail.com on 19 Dec 2011 at 6:49

GoogleCodeExporter commented 8 years ago

Original comment by janne.t....@gmail.com on 19 Dec 2011 at 7:02