Skip to content

Commit a5dafad

Browse files
committed
Better error output in assert methods
1 parent 3fbf5b3 commit a5dafad

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,13 @@ def is_downloaded_file_present(self, file):
17041704

17051705
def assert_downloaded_file(self, file):
17061706
""" Asserts that the file exists in the Downloads Folder. """
1707-
assert os.path.exists(self.get_path_of_downloaded_file(file))
1707+
self.assertTrue(os.path.exists(self.get_path_of_downloaded_file(file)),
1708+
"File [%s] was not found in the downloads folder [%s]!"
1709+
"" % (file, self.get_downloads_folder()))
1710+
if self.demo_mode:
1711+
messenger_post = ("ASSERT DOWNLOADED FILE: [%s]" % file)
1712+
js_utils.post_messenger_success_message(
1713+
self.driver, messenger_post, self.message_duration)
17081714

17091715
def assert_true(self, expr, msg=None):
17101716
self.assertTrue(expr, msg=msg)
@@ -1736,7 +1742,11 @@ def assert_not_equal(self, first, second, msg=None):
17361742

17371743
def assert_title(self, title):
17381744
""" Asserts that the web page title matches the expected title. """
1739-
assert self.get_title() == title
1745+
expected = title
1746+
actual = self.get_title()
1747+
self.assertEqual(expected, actual, "Expected page title [%s] "
1748+
"does not match the actual page title [%s]!"
1749+
"" % (expected, actual))
17401750
if self.demo_mode:
17411751
messenger_post = ("ASSERT TITLE: {%s}" % title)
17421752
js_utils.post_messenger_success_message(

0 commit comments

Comments
 (0)