@@ -4075,6 +4075,7 @@ def __process_recorded_actions(self):
4075
4075
ext_actions.append("hi_li")
4076
4076
ext_actions.append("as_lt")
4077
4077
ext_actions.append("as_ti")
4078
+ ext_actions.append("as_tc")
4078
4079
ext_actions.append("as_df")
4079
4080
ext_actions.append("do_fi")
4080
4081
ext_actions.append("as_at")
@@ -4406,6 +4407,12 @@ def __process_recorded_actions(self):
4406
4407
sb_actions.append('self.%s("%s")' % (method, action[1]))
4407
4408
else:
4408
4409
sb_actions.append("self.%s('%s')" % (method, action[1]))
4410
+ elif action[0] == "as_tc":
4411
+ method = "assert_title_contains"
4412
+ if '"' not in action[1]:
4413
+ sb_actions.append('self.%s("%s")' % (method, action[1]))
4414
+ else:
4415
+ sb_actions.append("self.%s('%s')" % (method, action[1]))
4409
4416
elif action[0] == "as_df":
4410
4417
method = "assert_downloaded_file"
4411
4418
if '"' not in action[1]:
@@ -6354,7 +6361,50 @@ def assert_title(self, title):
6354
6361
from seleniumbase.fixtures.words import SD
6355
6362
6356
6363
a_t = SD.translate_assert_title(self._language)
6357
- messenger_post = "%s: {%s}" % (a_t, title)
6364
+ messenger_post = "%s: {%s}" % (a_t, expected)
6365
+ self.__highlight_with_assert_success(messenger_post, "html")
6366
+ if self.recorder_mode:
6367
+ url = self.get_current_url()
6368
+ if url and len(url) > 0:
6369
+ if ("http:") in url or ("https:") in url or ("file:") in url:
6370
+ if self.get_session_storage_item("pause_recorder") == "no":
6371
+ time_stamp = self.execute_script("return Date.now();")
6372
+ origin = self.get_origin()
6373
+ action = ["as_ti", expected, origin, time_stamp]
6374
+ self.__extra_actions.append(action)
6375
+ return True
6376
+
6377
+ def assert_title_contains(self, substring):
6378
+ """Asserts that the title substring appears in the web page title.
6379
+ When a web page initially loads, the title starts as the URL,
6380
+ but then the title switches over to the actual page title.
6381
+ In Recorder Mode, this assertion is skipped because the Recorder
6382
+ changes the page title to the selector of the hovered element.
6383
+ """
6384
+ self.wait_for_ready_state_complete()
6385
+ expected = substring.strip()
6386
+ actual = self.get_page_title().strip()
6387
+ error = (
6388
+ "Expected title substring [%s] does not appear "
6389
+ "in the actual page title [%s]!"
6390
+ )
6391
+ try:
6392
+ if not self.recorder_mode:
6393
+ self.assertIn(expected, actual, error % (expected, actual))
6394
+ except Exception:
6395
+ self.wait_for_ready_state_complete()
6396
+ time.sleep(2)
6397
+ actual = self.get_page_title().strip()
6398
+ try:
6399
+ self.assertIn(expected, actual, error % (expected, actual))
6400
+ except Exception:
6401
+ self.wait_for_ready_state_complete()
6402
+ time.sleep(2)
6403
+ actual = self.get_page_title().strip()
6404
+ self.assertIn(expected, actual, error % (expected, actual))
6405
+ if self.demo_mode and not self.recorder_mode:
6406
+ a_t = "ASSERT TITLE CONTAINS"
6407
+ messenger_post = "%s: {%s}" % (a_t, expected)
6358
6408
self.__highlight_with_assert_success(messenger_post, "html")
6359
6409
if self.recorder_mode:
6360
6410
url = self.get_current_url()
@@ -6363,7 +6413,7 @@ def assert_title(self, title):
6363
6413
if self.get_session_storage_item("pause_recorder") == "no":
6364
6414
time_stamp = self.execute_script("return Date.now();")
6365
6415
origin = self.get_origin()
6366
- action = ["as_ti ", title , origin, time_stamp]
6416
+ action = ["as_tc ", expected , origin, time_stamp]
6367
6417
self.__extra_actions.append(action)
6368
6418
return True
6369
6419
0 commit comments