@@ -97,6 +97,7 @@ def pytest_addoption(parser):
97
97
--visual-baseline (Set the visual baseline for Visual/Layout tests.)
98
98
--external-pdf (Set Chromium "plugins.always_open_pdf_externally": True.)
99
99
--timeout-multiplier=MULTIPLIER (Multiplies the default timeout values.)
100
+ --list-fail-page (After each failing test, list the URL of the failure.)
100
101
"""
101
102
c1 = ""
102
103
c2 = ""
@@ -1015,6 +1016,17 @@ def pytest_addoption(parser):
1015
1016
by the multiplier when waiting for page elements.
1016
1017
Unused when tests override the default value.""" ,
1017
1018
)
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
+ )
1018
1030
1019
1031
sys_argv = sys .argv
1020
1032
arg_join = " " .join (sys .argv )
@@ -1274,8 +1286,10 @@ def pytest_configure(config):
1274
1286
sb_config .visual_baseline = config .getoption ("visual_baseline" )
1275
1287
sb_config .external_pdf = config .getoption ("external_pdf" )
1276
1288
sb_config .timeout_multiplier = config .getoption ("timeout_multiplier" )
1289
+ sb_config .list_fp = config .getoption ("fail_page" )
1277
1290
sb_config ._is_timeout_changed = False
1278
1291
sb_config ._has_logs = False
1292
+ sb_config ._fail_page = None
1279
1293
sb_config ._SMALL_TIMEOUT = settings .SMALL_TIMEOUT
1280
1294
sb_config ._LARGE_TIMEOUT = settings .LARGE_TIMEOUT
1281
1295
sb_config .pytest_html_report = config .getoption ("htmlpath" ) # --html=FILE
@@ -1554,6 +1568,8 @@ def pytest_runtest_teardown(item):
1554
1568
pass
1555
1569
except Exception :
1556
1570
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 )
1557
1573
1558
1574
1559
1575
def pytest_sessionfinish (session ):
0 commit comments