File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 1
1
""" SeleniumBase Exceptions
2
2
NoSuchFileException => Called when self.assert_downloaded_file(...) fails.
3
+ NotConnectedException => Called when Internet is not reachable when needed.
3
4
NotUsingChromeException => Used by Chrome-only methods if not using Chrome.
4
5
NotUsingChromiumException => Used by Chromium-only methods if not Chromium.
5
6
OutOfScopeException => Used by BaseCase methods when setUp() is skipped.
@@ -13,6 +14,10 @@ class NoSuchFileException(Exception):
13
14
pass
14
15
15
16
17
+ class NotConnectedException (Exception ):
18
+ pass
19
+
20
+
16
21
class NotUsingChromeException (Exception ):
17
22
pass
18
23
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ def test_anything(self):
61
61
from seleniumbase.__version__ import __version__
62
62
from seleniumbase.common import decorators
63
63
from seleniumbase.common.exceptions import (
64
+ NotConnectedException,
64
65
NotUsingChromeException,
65
66
NotUsingChromiumException,
66
67
OutOfScopeException,
@@ -249,12 +250,29 @@ def open(self, url):
249
250
or "ERR_CONNECTION_CLOSED" in e.msg
250
251
or "ERR_CONNECTION_RESET" in e.msg
251
252
or "ERR_NAME_NOT_RESOLVED" in e.msg
252
- or "ERR_INTERNET_DISCONNECTED" in e.msg
253
253
):
254
254
shared_utils.check_if_time_limit_exceeded()
255
255
self.__check_browser()
256
256
time.sleep(0.8)
257
257
self.driver.get(url)
258
+ elif (
259
+ "ERR_INTERNET_DISCONNECTED" in e.msg
260
+ or "neterror?e=dnsNotFound" in e.msg
261
+ ):
262
+ shared_utils.check_if_time_limit_exceeded()
263
+ self.__check_browser()
264
+ time.sleep(1.05)
265
+ try:
266
+ self.driver.get(url)
267
+ except Exception as e2:
268
+ if (
269
+ "ERR_INTERNET_DISCONNECTED" in e2.msg
270
+ or "neterror?e=dnsNotFound" in e2.msg
271
+ ):
272
+ message = "Internet unreachable!"
273
+ raise NotConnectedException(message)
274
+ else:
275
+ raise
258
276
elif "Timed out receiving message from renderer" in e.msg:
259
277
page_load_timeout = None
260
278
if selenium4_or_newer:
You can’t perform that action at this time.
0 commit comments