Skip to content

Commit 9338fcb

Browse files
committed
Output the last page during test failures in verbose mode
1 parent 95c336e commit 9338fcb

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

seleniumbase/plugins/pytest_plugin.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,7 @@ def pytest_addoption(parser):
11581158
Unused when tests override the default value.""",
11591159
)
11601160
parser.addoption(
1161+
"--lfp",
11611162
"--list-fail-page",
11621163
"--list-fail-pages",
11631164
action="store_true",
@@ -1503,13 +1504,15 @@ def pytest_configure(config):
15031504
if (
15041505
"-n" in sys_argv
15051506
or " -n=" in arg_join
1507+
or " -n" in arg_join
15061508
or "-c" in sys_argv
15071509
or (
15081510
python3
15091511
and "addopts" in config.inicfg.keys()
15101512
and (
15111513
"-n=" in config.inicfg["addopts"]
15121514
or "-n " in config.inicfg["addopts"]
1515+
or "-n" in config.inicfg["addopts"]
15131516
)
15141517
)
15151518
):
@@ -1594,6 +1597,21 @@ def pytest_configure(config):
15941597
if sb_config.save_screenshot and sb_config.no_screenshot:
15951598
sb_config.save_screenshot = False # "no_screenshot" has priority
15961599

1600+
if (
1601+
"-v" in sys_argv and not sb_config._multithreaded
1602+
or (
1603+
python3
1604+
and hasattr(config, "invocation_params")
1605+
and "-v" in config.invocation_params.args
1606+
and (
1607+
"-n=1" in config.invocation_params.args
1608+
or "-n1" in config.invocation_params.args
1609+
or "-n 1" in " ".join(config.invocation_params.args)
1610+
)
1611+
)
1612+
):
1613+
sb_config.list_fp = True # List the fail pages in console output
1614+
15971615
if (
15981616
sb_config._multithreaded
15991617
and "--co" not in sys_argv
@@ -1808,7 +1826,11 @@ def pytest_runtest_teardown(item):
18081826
pass
18091827
except Exception:
18101828
pass
1811-
if sb_config._has_exception and sb_config.list_fp and sb_config._fail_page:
1829+
if (
1830+
(sb_config._has_exception or python3_11_or_newer)
1831+
and sb_config.list_fp
1832+
and sb_config._fail_page
1833+
):
18121834
sys.stderr.write("\n=> Fail Page: %s\n" % sb_config._fail_page)
18131835

18141836

0 commit comments

Comments
 (0)