@@ -2939,21 +2939,28 @@ def assert_raises(self, *args, **kwargs):
2939
2939
self .assertRaises (* args , ** kwargs )
2940
2940
2941
2941
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. """
2943
2946
self .wait_for_ready_state_complete ()
2944
2947
expected = title .strip ()
2945
2948
actual = self .get_page_title ().strip ()
2949
+ error = (
2950
+ "Expected page title [%s] does not match the actual title [%s]!" )
2946
2951
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 ))
2950
2953
except Exception :
2951
2954
self .wait_for_ready_state_complete ()
2952
2955
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 ))
2957
2964
if self .demo_mode :
2958
2965
a_t = "ASSERT TITLE"
2959
2966
if self ._language != "English" :
0 commit comments