Skip to content

Commit 186bd1a

Browse files
authored
Merge pull request #1153 from seleniumbase/refactoring-and-dependencies
Refactoring and dependencies
2 parents d84f11e + 969ea86 commit 186bd1a

File tree

6 files changed

+35
-21
lines changed

6 files changed

+35
-21
lines changed

examples/edge_test.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
"""
22
This test is only for Microsoft Edge (Chromium)!
3-
(Tested on Edge Version 89.0.774.54)
3+
(Tested on Edge Version 96.0.1054.62)
44
"""
55
from seleniumbase import BaseCase
66

77

88
class EdgeTests(BaseCase):
99
def test_edge(self):
1010
if self.browser != "edge":
11+
self.open("data:,")
1112
print("\n This test is only for Microsoft Edge (Chromium)!")
1213
print(' (Run this test using "--edge" or "--browser=edge")')
1314
self.skip('Use "--edge" or "--browser=edge"')
1415
if self.headless:
16+
self.open("data:,")
1517
print("\n This test is NOT designed for Headless Mode!")
1618
self.skip('Do NOT use "--headless" with this test!')
1719
self.open("edge://settings/help")

examples/test_shadow_dom.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ def download_tar_file_from_pypi(self, package):
2020

2121
def test_shadow_dom(self):
2222
if self.browser != "chrome":
23+
self.open("data:,")
2324
print("\n This test is for Google Chrome only!")
2425
self.skip("This test is for Google Chrome only!")
2526
if self.headless:
27+
self.open("data:,")
2628
print("\n This test doesn't run in headless mode!")
2729
self.skip("This test doesn't run in headless mode!")
2830

requirements.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ idna==2.10;python_version<"3.6"
2727
idna==3.3;python_version>="3.6"
2828
chardet==3.0.4;python_version<"3.5"
2929
chardet==4.0.0;python_version>="3.5"
30-
charset-normalizer==2.0.9;python_version>="3.5"
30+
charset-normalizer==2.0.10;python_version>="3.5"
3131
urllib3==1.26.7
32-
requests==2.26.0;python_version<"3.5"
32+
requests==2.27.0;python_version<"3.5"
3333
requests==2.25.1;python_version>="3.5" and python_version<"3.6"
34-
requests==2.26.0;python_version>="3.6"
34+
requests==2.27.0;python_version>="3.6"
3535
nose==1.3.7
3636
sniffio==1.2.0;python_version>="3.7"
3737
trio==0.19.0;python_version>="3.7"
@@ -105,7 +105,8 @@ virtualenv>=20.13.0
105105
pycparser==2.21
106106
pymysql==0.10.1;python_version<"3.6"
107107
pymysql==1.0.2;python_version>="3.6"
108-
pyotp==2.6.0
108+
pyotp==2.3.0;python_version<"3.5"
109+
pyotp==2.6.0;python_version>="3.5"
109110
boto==2.49.0
110111
cffi==1.15.0
111112
toml==0.10.2

seleniumbase/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "2.3.7"
2+
__version__ = "2.3.8"

seleniumbase/fixtures/base_case.py

+19-11
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def test_anything(self):
6666
logging.getLogger("urllib3").setLevel(logging.ERROR)
6767
urllib3.disable_warnings()
6868
LOGGER.setLevel(logging.WARNING)
69+
python3 = True
6970
if sys.version_info[0] < 3:
71+
python3 = False
7072
reload(sys) # noqa: F821
7173
sys.setdefaultencoding("utf8")
7274
selenium4 = False
@@ -144,9 +146,8 @@ def open(self, url):
144146
pre_action_url = self.driver.current_url
145147
except Exception:
146148
pass
147-
if type(url) is str:
148-
url = url.strip() # Remove leading and trailing whitespace
149-
if (type(url) is not str) or not self.__looks_like_a_page_url(url):
149+
url = str(url).strip() # Remove leading and trailing whitespace
150+
if not self.__looks_like_a_page_url(url):
150151
# url should start with one of the following:
151152
# "http:", "https:", "://", "data:", "file:",
152153
# "about:", "chrome:", "opera:", or "edge:".
@@ -742,7 +743,7 @@ def refresh(self):
742743
def get_current_url(self):
743744
self.__check_scope()
744745
current_url = self.driver.current_url
745-
if "%" in current_url and sys.version_info[0] >= 3:
746+
if "%" in current_url and python3:
746747
try:
747748
from urllib.parse import unquote
748749

@@ -2386,6 +2387,8 @@ def open_html_file(self, html_file):
23862387
def execute_script(self, script, *args, **kwargs):
23872388
self.__check_scope()
23882389
self.__check_browser()
2390+
if not python3:
2391+
script = unicode(script.decode('latin-1')) # noqa: F821
23892392
return self.driver.execute_script(script, *args, **kwargs)
23902393

23912394
def execute_async_script(self, script, timeout=None):
@@ -2520,6 +2523,8 @@ def set_content_to_frame(self, frame, timeout=None):
25202523
url = self.execute_script(
25212524
"""return document.querySelector('%s').src;""" % frame
25222525
)
2526+
if not python3:
2527+
url = str(url)
25232528
if url and len(url) > 0:
25242529
if ("http:") in url or ("https:") in url or ("file:") in url:
25252530
pass
@@ -3547,7 +3552,7 @@ def __process_recorded_actions(self):
35473552
cleaned_actions.append(srt_actions[n])
35483553
for action in srt_actions:
35493554
if action[0] == "begin" or action[0] == "_url_":
3550-
if "%" in action[2] and sys.version_info[0] >= 3:
3555+
if "%" in action[2] and python3:
35513556
try:
35523557
from urllib.parse import unquote
35533558

@@ -3556,7 +3561,7 @@ def __process_recorded_actions(self):
35563561
pass
35573562
sb_actions.append('self.open("%s")' % action[2])
35583563
elif action[0] == "f_url":
3559-
if "%" in action[2] and sys.version_info[0] >= 3:
3564+
if "%" in action[2] and python3:
35603565
try:
35613566
from urllib.parse import unquote
35623567

@@ -10464,7 +10469,7 @@ def __recalculate_selector(self, selector, by, xp_ok=True):
1046410469
used to make the ":contains()" selector valid outside JS calls."""
1046510470
_type = type(selector) # First make sure the selector is a string
1046610471
not_string = False
10467-
if sys.version_info[0] < 3:
10472+
if not python3:
1046810473
if _type is not str and _type is not unicode: # noqa: F821
1046910474
not_string = True
1047010475
else:
@@ -11123,7 +11128,7 @@ def __set_last_page_source(self):
1112311128
def __get_exception_info(self):
1112411129
exc_message = None
1112511130
if (
11126-
sys.version_info[0] >= 3
11131+
python3
1112711132
and hasattr(self, "_outcome")
1112811133
and (hasattr(self._outcome, "errors") and self._outcome.errors)
1112911134
):
@@ -11234,11 +11239,11 @@ def __has_exception(self):
1123411239
has_exception = False
1123511240
if hasattr(sys, "last_traceback") and sys.last_traceback is not None:
1123611241
has_exception = True
11237-
elif sys.version_info[0] >= 3 and hasattr(self, "_outcome"):
11242+
elif python3 and hasattr(self, "_outcome"):
1123811243
if hasattr(self._outcome, "errors") and self._outcome.errors:
1123911244
has_exception = True
1124011245
else:
11241-
if sys.version_info[0] >= 3:
11246+
if python3:
1124211247
has_exception = sys.exc_info()[1] is not None
1124311248
else:
1124411249
if not hasattr(self, "_using_sb_fixture_class") and (
@@ -11247,7 +11252,10 @@ def __has_exception(self):
1124711252
has_exception = sys.exc_info()[1] is not None
1124811253
else:
1124911254
has_exception = len(str(sys.exc_info()[1]).strip()) > 0
11250-
if hasattr(self, "_using_sb_fixture") and self.__will_be_skipped:
11255+
if (
11256+
self.__will_be_skipped
11257+
and (hasattr(self, "_using_sb_fixture") or not python3)
11258+
):
1125111259
has_exception = False
1125211260
return has_exception
1125311261

setup.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@
147147
'idna==3.3;python_version>="3.6"', # Must stay in sync with "requests"
148148
'chardet==3.0.4;python_version<"3.5"', # Stay in sync with "requests"
149149
'chardet==4.0.0;python_version>="3.5"', # Stay in sync with "requests"
150-
'charset-normalizer==2.0.9;python_version>="3.5"', # Sync "requests"
150+
'charset-normalizer==2.0.10;python_version>="3.5"', # Sync "requests"
151151
"urllib3==1.26.7", # Must stay in sync with "requests"
152-
'requests==2.26.0;python_version<"3.5"',
152+
'requests==2.27.0;python_version<"3.5"',
153153
'requests==2.25.1;python_version>="3.5" and python_version<"3.6"',
154-
'requests==2.26.0;python_version>="3.6"',
154+
'requests==2.27.0;python_version>="3.6"',
155155
"nose==1.3.7",
156156
'sniffio==1.2.0;python_version>="3.7"',
157157
'trio==0.19.0;python_version>="3.7"',
@@ -225,7 +225,8 @@
225225
"pycparser==2.21",
226226
'pymysql==0.10.1;python_version<"3.6"',
227227
'pymysql==1.0.2;python_version>="3.6"',
228-
"pyotp==2.6.0",
228+
'pyotp==2.3.0;python_version<"3.5"',
229+
'pyotp==2.6.0;python_version>="3.5"',
229230
"boto==2.49.0",
230231
"cffi==1.15.0",
231232
"toml==0.10.2",

0 commit comments

Comments
 (0)