Skip to content

Commit a9cd002

Browse files
authored
Merge pull request #1856 from seleniumbase/not-connected-exception-handling
Not-connected exception-handling
2 parents 1ee9ee9 + 25e96f5 commit a9cd002

File tree

7 files changed

+30
-10
lines changed

7 files changed

+30
-10
lines changed

examples/test_repeat_tests.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010
class RepeatTests(BaseCase):
1111
@parameterized.expand([[]] * 2)
1212
def test_repeat_this_test_with_parameterized(self):
13-
self.page_load_strategy = "none"
1413
self.open("seleniumbase.github.io")
1514
self.click('a[href="help_docs/method_summary/"]')
1615
self.assert_text("API Reference", "h1")
1716

1817

1918
@pytest.mark.parametrize("", [[]] * 2)
2019
def test_repeat_this_test_with_pytest_parametrize(sb):
21-
sb.page_load_strategy = "none"
2220
sb.open("seleniumbase.github.io")
2321
sb.click('a[href="seleniumbase/console_scripts/ReadMe/"]')
2422
sb.assert_text("Console Scripts", "h1")
@@ -27,7 +25,6 @@ def test_repeat_this_test_with_pytest_parametrize(sb):
2725
class RepeatTestsWithPytest:
2826
@pytest.mark.parametrize("", [[]] * 2)
2927
def test_repeat_test_with_pytest_parametrize(self, sb):
30-
sb.page_load_strategy = "none"
3128
sb.open("seleniumbase.github.io")
3229
sb.click('a[href="help_docs/customizing_test_runs/"]')
3330
sb.assert_text("Command Line Options", "h1")

mkdocs_build/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ click==8.1.3
1414
ghp-import==2.1.0
1515
readme-renderer==37.3
1616
pymdown-extensions==9.11
17-
importlib-metadata==6.5.0
17+
importlib-metadata==6.6.0
1818
pipdeptree==2.7.0
1919
bleach==6.0.0
2020
lunr==0.6.2
2121
nltk==3.8.1
22-
tornado==6.3
22+
tornado==6.3.1
2323
watchdog==3.0.0
2424
cairocffi==1.5.1
2525
cairosvg==2.7.0
2626
cssselect2==0.7.0
2727
tinycss2==1.2.1
2828
defusedxml==0.7.1
2929
mkdocs==1.4.2
30-
mkdocs-material==9.1.6
30+
mkdocs-material==9.1.7
3131
mkdocs-exclude-search==0.6.5
3232
mkdocs-simple-hooks==0.1.5
3333
mkdocs-material-extensions==1.1.1

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pip>=21.3.1;python_version<"3.7"
2-
pip>=23.1;python_version>="3.7"
2+
pip>=23.1.1;python_version>="3.7"
33
packaging>=21.3;python_version<"3.7"
44
packaging>=23.1;python_version>="3.7"
55
setuptools>=59.6.0;python_version<"3.7"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.14.1"
2+
__version__ = "4.14.2"

seleniumbase/common/exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" SeleniumBase Exceptions
22
NoSuchFileException => Called when self.assert_downloaded_file(...) fails.
3+
NotConnectedException => Called when Internet is not reachable when needed.
34
NotUsingChromeException => Used by Chrome-only methods if not using Chrome.
45
NotUsingChromiumException => Used by Chromium-only methods if not Chromium.
56
OutOfScopeException => Used by BaseCase methods when setUp() is skipped.
@@ -13,6 +14,10 @@ class NoSuchFileException(Exception):
1314
pass
1415

1516

17+
class NotConnectedException(Exception):
18+
pass
19+
20+
1621
class NotUsingChromeException(Exception):
1722
pass
1823

seleniumbase/fixtures/base_case.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def test_anything(self):
6161
from seleniumbase.__version__ import __version__
6262
from seleniumbase.common import decorators
6363
from seleniumbase.common.exceptions import (
64+
NotConnectedException,
6465
NotUsingChromeException,
6566
NotUsingChromiumException,
6667
OutOfScopeException,
@@ -249,12 +250,29 @@ def open(self, url):
249250
or "ERR_CONNECTION_CLOSED" in e.msg
250251
or "ERR_CONNECTION_RESET" in e.msg
251252
or "ERR_NAME_NOT_RESOLVED" in e.msg
252-
or "ERR_INTERNET_DISCONNECTED" in e.msg
253253
):
254254
shared_utils.check_if_time_limit_exceeded()
255255
self.__check_browser()
256256
time.sleep(0.8)
257257
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
258276
elif "Timed out receiving message from renderer" in e.msg:
259277
page_load_timeout = None
260278
if selenium4_or_newer:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
python_requires=">=3.6",
124124
install_requires=[
125125
'pip>=21.3.1;python_version<"3.7"',
126-
'pip>=23.1;python_version>="3.7"',
126+
'pip>=23.1.1;python_version>="3.7"',
127127
'packaging>=21.3;python_version<"3.7"',
128128
'packaging>=23.1;python_version>="3.7"',
129129
'setuptools>=59.6.0;python_version<"3.7"',

0 commit comments

Comments
 (0)