Skip to content

Commit 687c273

Browse files
committed
Improve compatibility for older versions of Python
1 parent bd8e0e3 commit 687c273

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6137,7 +6137,14 @@ def __recalculate_selector(self, selector, by, xp_ok=True):
61376137
If "xp_ok" is False, don't call convert_css_to_xpath(), which is
61386138
used to make the ":contains()" selector valid outside JS calls. """
61396139
_type = type(selector) # First make sure the selector is a string
6140-
if _type is not str:
6140+
not_string = False
6141+
if sys.version_info[0] < 3:
6142+
if _type is not str and _type is not unicode: # noqa
6143+
not_string = True
6144+
else:
6145+
if _type is not str:
6146+
not_string = True
6147+
if not_string:
61416148
msg = 'Expecting a selector of type: "<class \'str\'>" (string)!'
61426149
raise Exception('Invalid selector type: "%s"\n%s' % (_type, msg))
61436150
if page_utils.is_xpath_selector(selector):
@@ -6740,7 +6747,14 @@ def __has_exception(self):
67406747
if hasattr(self._outcome, 'errors') and self._outcome.errors:
67416748
has_exception = True
67426749
else:
6743-
has_exception = sys.exc_info()[1] is not None
6750+
if sys.version_info[0] >= 3:
6751+
has_exception = sys.exc_info()[1] is not None
6752+
else:
6753+
if not hasattr(self, "_using_sb_fixture_class") and (
6754+
not hasattr(self, "_using_sb_fixture_no_class")):
6755+
has_exception = sys.exc_info()[1] is not None
6756+
else:
6757+
has_exception = (len(str(sys.exc_info()[1]).strip()) > 0)
67446758
return has_exception
67456759

67466760
def __get_test_id(self):

0 commit comments

Comments
 (0)