Skip to content

Commit 3534400

Browse files
committed
Refactoring and better error-handling
1 parent 1f88a5a commit 3534400

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

seleniumbase/core/report_helper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def process_failures(test, test_count, browser_type, duration):
4949
bad_page_image = "failure_%s.png" % test_count
5050
bad_page_data = "failure_%s.txt" % test_count
5151
screenshot_path = "%s/%s" % (LATEST_REPORT_DIR, bad_page_image)
52-
with open(screenshot_path, "wb") as file:
53-
file.write(test._last_page_screenshot)
52+
if hasattr(test, "_last_page_screenshot"):
53+
with open(screenshot_path, "wb") as file:
54+
file.write(test._last_page_screenshot)
5455
page_actions.save_test_failure_data(
5556
test.driver, bad_page_data, browser_type, folder=LATEST_REPORT_DIR
5657
)
@@ -69,6 +70,8 @@ def process_failures(test, test_count, browser_type, duration):
6970
exc_message = sys.last_value
7071
except Exception:
7172
exc_message = "(Unknown Exception)"
73+
if not hasattr(test, "_last_page_url"):
74+
test._last_page_url = "about:blank"
7275
return '"%s","%s","%s","%s","%s","%s","%s","%s","%s","%s"' % (
7376
test_count,
7477
"FAILED!",

seleniumbase/fixtures/base_case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5834,7 +5834,7 @@ def skip(self, reason=""):
58345834
self.__passed_then_skipped = True
58355835
self.__will_be_skipped = True
58365836
sb_config._results[test_id] = "Skipped"
5837-
if self.with_db_reporting:
5837+
if hasattr(self, "with_db_reporting") and self.with_db_reporting:
58385838
if self.is_pytest:
58395839
self.__skip_reason = reason
58405840
else:

seleniumbase/fixtures/page_actions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,12 @@ def is_attribute_present(
124124
element = driver.find_element(by=by, value=selector)
125125
found_value = element.get_attribute(attribute)
126126
if found_value is None:
127-
raise Exception()
128-
127+
return False
129128
if value is not None:
130129
if found_value == value:
131130
return True
132131
else:
133-
raise Exception()
132+
return False
134133
else:
135134
return True
136135
except Exception:

0 commit comments

Comments
 (0)