@@ -97,6 +97,7 @@ def pytest_addoption(parser):
9797 --visual-baseline (Set the visual baseline for Visual/Layout tests.)
9898 --external-pdf (Set Chromium "plugins.always_open_pdf_externally": True.)
9999 --timeout-multiplier=MULTIPLIER (Multiplies the default timeout values.)
100+ --list-fail-page (After each failing test, list the URL of the failure.)
100101 """
101102 c1 = ""
102103 c2 = ""
@@ -1015,6 +1016,17 @@ def pytest_addoption(parser):
10151016 by the multiplier when waiting for page elements.
10161017 Unused when tests override the default value.""" ,
10171018 )
1019+ parser .addoption (
1020+ "--list-fail-page" ,
1021+ "--list-fail-pages" ,
1022+ action = "store_true" ,
1023+ dest = "fail_page" ,
1024+ default = False ,
1025+ help = """(For debugging) After each failing test, list the URL
1026+ where the failure occurred.
1027+ Useful when you don't have access to the latest_logs/
1028+ folder, such as when running tests in GitHub Actions.""" ,
1029+ )
10181030
10191031 sys_argv = sys .argv
10201032 arg_join = " " .join (sys .argv )
@@ -1274,8 +1286,10 @@ def pytest_configure(config):
12741286 sb_config .visual_baseline = config .getoption ("visual_baseline" )
12751287 sb_config .external_pdf = config .getoption ("external_pdf" )
12761288 sb_config .timeout_multiplier = config .getoption ("timeout_multiplier" )
1289+ sb_config .list_fp = config .getoption ("fail_page" )
12771290 sb_config ._is_timeout_changed = False
12781291 sb_config ._has_logs = False
1292+ sb_config ._fail_page = None
12791293 sb_config ._SMALL_TIMEOUT = settings .SMALL_TIMEOUT
12801294 sb_config ._LARGE_TIMEOUT = settings .LARGE_TIMEOUT
12811295 sb_config .pytest_html_report = config .getoption ("htmlpath" ) # --html=FILE
@@ -1554,6 +1568,8 @@ def pytest_runtest_teardown(item):
15541568 pass
15551569 except Exception :
15561570 pass
1571+ if sb_config ._has_exception and sb_config .list_fp and sb_config ._fail_page :
1572+ sys .stderr .write ("\n => Fail Page: %s\n " % sb_config ._fail_page )
15571573
15581574
15591575def pytest_sessionfinish (session ):
0 commit comments