Skip to content

Not-connected exception-handling #1856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions examples/test_repeat_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
class RepeatTests(BaseCase):
@parameterized.expand([[]] * 2)
def test_repeat_this_test_with_parameterized(self):
self.page_load_strategy = "none"
self.open("seleniumbase.github.io")
self.click('a[href="help_docs/method_summary/"]')
self.assert_text("API Reference", "h1")


@pytest.mark.parametrize("", [[]] * 2)
def test_repeat_this_test_with_pytest_parametrize(sb):
sb.page_load_strategy = "none"
sb.open("seleniumbase.github.io")
sb.click('a[href="seleniumbase/console_scripts/ReadMe/"]')
sb.assert_text("Console Scripts", "h1")
Expand All @@ -27,7 +25,6 @@ def test_repeat_this_test_with_pytest_parametrize(sb):
class RepeatTestsWithPytest:
@pytest.mark.parametrize("", [[]] * 2)
def test_repeat_test_with_pytest_parametrize(self, sb):
sb.page_load_strategy = "none"
sb.open("seleniumbase.github.io")
sb.click('a[href="help_docs/customizing_test_runs/"]')
sb.assert_text("Command Line Options", "h1")
6 changes: 3 additions & 3 deletions mkdocs_build/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ click==8.1.3
ghp-import==2.1.0
readme-renderer==37.3
pymdown-extensions==9.11
importlib-metadata==6.5.0
importlib-metadata==6.6.0
pipdeptree==2.7.0
bleach==6.0.0
lunr==0.6.2
nltk==3.8.1
tornado==6.3
tornado==6.3.1
watchdog==3.0.0
cairocffi==1.5.1
cairosvg==2.7.0
cssselect2==0.7.0
tinycss2==1.2.1
defusedxml==0.7.1
mkdocs==1.4.2
mkdocs-material==9.1.6
mkdocs-material==9.1.7
mkdocs-exclude-search==0.6.5
mkdocs-simple-hooks==0.1.5
mkdocs-material-extensions==1.1.1
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip>=21.3.1;python_version<"3.7"
pip>=23.1;python_version>="3.7"
pip>=23.1.1;python_version>="3.7"
packaging>=21.3;python_version<"3.7"
packaging>=23.1;python_version>="3.7"
setuptools>=59.6.0;python_version<"3.7"
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.14.1"
__version__ = "4.14.2"
5 changes: 5 additions & 0 deletions seleniumbase/common/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" SeleniumBase Exceptions
NoSuchFileException => Called when self.assert_downloaded_file(...) fails.
NotConnectedException => Called when Internet is not reachable when needed.
NotUsingChromeException => Used by Chrome-only methods if not using Chrome.
NotUsingChromiumException => Used by Chromium-only methods if not Chromium.
OutOfScopeException => Used by BaseCase methods when setUp() is skipped.
Expand All @@ -13,6 +14,10 @@ class NoSuchFileException(Exception):
pass


class NotConnectedException(Exception):
pass


class NotUsingChromeException(Exception):
pass

Expand Down
20 changes: 19 additions & 1 deletion seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def test_anything(self):
from seleniumbase.__version__ import __version__
from seleniumbase.common import decorators
from seleniumbase.common.exceptions import (
NotConnectedException,
NotUsingChromeException,
NotUsingChromiumException,
OutOfScopeException,
Expand Down Expand Up @@ -249,12 +250,29 @@ def open(self, url):
or "ERR_CONNECTION_CLOSED" in e.msg
or "ERR_CONNECTION_RESET" in e.msg
or "ERR_NAME_NOT_RESOLVED" in e.msg
or "ERR_INTERNET_DISCONNECTED" in e.msg
):
shared_utils.check_if_time_limit_exceeded()
self.__check_browser()
time.sleep(0.8)
self.driver.get(url)
elif (
"ERR_INTERNET_DISCONNECTED" in e.msg
or "neterror?e=dnsNotFound" in e.msg
):
shared_utils.check_if_time_limit_exceeded()
self.__check_browser()
time.sleep(1.05)
try:
self.driver.get(url)
except Exception as e2:
if (
"ERR_INTERNET_DISCONNECTED" in e2.msg
or "neterror?e=dnsNotFound" in e2.msg
):
message = "Internet unreachable!"
raise NotConnectedException(message)
else:
raise
elif "Timed out receiving message from renderer" in e.msg:
page_load_timeout = None
if selenium4_or_newer:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
python_requires=">=3.6",
install_requires=[
'pip>=21.3.1;python_version<"3.7"',
'pip>=23.1;python_version>="3.7"',
'pip>=23.1.1;python_version>="3.7"',
'packaging>=21.3;python_version<"3.7"',
'packaging>=23.1;python_version>="3.7"',
'setuptools>=59.6.0;python_version<"3.7"',
Expand Down