MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / log_page_source

Function log_page_source

seleniumbase/core/log_helper.py:356–388  ·  view source on GitHub ↗
(test_logpath, driver, source=None)

Source from the content-addressed store, hash-verified

354
355
356def log_page_source(test_logpath, driver, source=None):
357 html_file_name = settings.PAGE_SOURCE_NAME
358 if source:
359 page_source = source
360 else:
361 try:
362 page_source = None
363 if __is_cdp_swap_needed(driver):
364 page_source = driver.cdp.get_page_source()
365 else:
366 page_source = driver.page_source
367 page_source = get_html_source_with_base_href(driver, page_source)
368 except Exception:
369 source = constants.Warnings.PAGE_SOURCE_UNDEFINED
370 page_source = constants.Warnings.PAGE_SOURCE_UNDEFINED
371 if source == constants.Warnings.PAGE_SOURCE_UNDEFINED:
372 page_source = (
373 "<h3>Warning: "
374 + source
375 + (
376 "</h3>\n<h4>The browser window was either unreachable, "
377 "unresponsive, or closed prematurely!</h4>"
378 )
379 )
380 if not os.path.exists(test_logpath):
381 with suppress(Exception):
382 os.makedirs(test_logpath)
383 html_file_path = os.path.join(test_logpath, html_file_name)
384 with suppress(Exception):
385 html_file = open(html_file_path, mode="w+", encoding="utf-8")
386 html_file.write(page_source)
387 html_file.close()
388 shared_utils.make_writable(html_file_path)
389
390
391def get_test_id(test):

Callers

nothing calls this directly

Calls 5

writeMethod · 0.80
closeMethod · 0.80
__is_cdp_swap_neededFunction · 0.70
get_page_sourceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…