Skip to content

Commit 0f73528

Browse files
committed
Update "assert_title()"
1 parent ceaaf01 commit 0f73528

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,21 +2939,28 @@ def assert_raises(self, *args, **kwargs):
29392939
self.assertRaises(*args, **kwargs)
29402940

29412941
def assert_title(self, title):
2942-
""" Asserts that the web page title matches the expected title. """
2942+
""" Asserts that the web page title matches the expected title.
2943+
When a web page initially loads, the title starts as the URL,
2944+
but then the title switches over to the actual page title.
2945+
A slow connection could delay the actual title from displaying. """
29432946
self.wait_for_ready_state_complete()
29442947
expected = title.strip()
29452948
actual = self.get_page_title().strip()
2949+
error = (
2950+
"Expected page title [%s] does not match the actual title [%s]!")
29462951
try:
2947-
self.assertEqual(expected, actual, "Expected page title [%s] "
2948-
"does not match the actual page title [%s]!"
2949-
"" % (expected, actual))
2952+
self.assertEqual(expected, actual, error % (expected, actual))
29502953
except Exception:
29512954
self.wait_for_ready_state_complete()
29522955
self.sleep(settings.MINI_TIMEOUT)
2953-
actual = self.get_page_title()
2954-
self.assertEqual(expected, actual, "Expected page title [%s] "
2955-
"does not match the actual page title [%s]!"
2956-
"" % (expected, actual))
2956+
actual = self.get_page_title().strip()
2957+
try:
2958+
self.assertEqual(expected, actual, error % (expected, actual))
2959+
except Exception:
2960+
self.wait_for_ready_state_complete()
2961+
self.sleep(settings.MINI_TIMEOUT)
2962+
actual = self.get_page_title().strip()
2963+
self.assertEqual(expected, actual, error % (expected, actual))
29572964
if self.demo_mode:
29582965
a_t = "ASSERT TITLE"
29592966
if self._language != "English":

0 commit comments

Comments
 (0)