Skip to content

Commit 9f4b412

Browse files
committed
Display latest_logs link if files were saved to the logs
1 parent 547ae19 commit 9f4b412

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

seleniumbase/behave/behave_sb.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ def get_configured_sb(context):
735735
sb_config.maximize_option = sb.maximize_option
736736
sb_config.xvfb = sb.xvfb
737737
sb_config.save_screenshot = sb.save_screenshot_after_test
738+
sb_config._has_logs = False
738739
sb_config.variables = sb.variables
739740
sb_config.dashboard = sb.dashboard
740741
sb_config.dash_title = sb.dash_title
@@ -1070,7 +1071,11 @@ def _perform_behave_terminal_summary_():
10701071
if sb_config.dashboard:
10711072
# Print link a second time because the first one may be off-screen
10721073
print("%s- Dashboard:%s %s" % (c2, cr, dash_path))
1073-
if sb_config._has_exception or sb_config.save_screenshot:
1074+
if (
1075+
sb_config._has_exception
1076+
or sb_config.save_screenshot
1077+
or sb_config._has_logs
1078+
):
10741079
# Log files are generated during test failures and Screenshot Mode
10751080
print("%s--- LogPath:%s %s" % (c2, cr, latest_logs_dir))
10761081
if (

seleniumbase/fixtures/base_case.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3259,6 +3259,7 @@ def save_screenshot_to_logs(
32593259
origin = self.get_origin()
32603260
action = ["ss_tl", "", origin, time_stamp]
32613261
self.__extra_actions.append(action)
3262+
sb_config._has_logs = True
32623263
return page_actions.save_screenshot(self.driver, name, test_logpath)
32633264

32643265
def save_page_source(self, name, folder=None):
@@ -12970,6 +12971,7 @@ def save_teardown_screenshot(self):
1297012971
self.__set_last_page_screenshot()
1297112972
self.__set_last_page_url()
1297212973
self.__set_last_page_source()
12974+
sb_config._has_logs = True
1297312975
if self.is_pytest:
1297412976
self.__add_pytest_html_extra()
1297512977

@@ -13050,6 +13052,7 @@ def tearDown(self):
1305013052
if has_exception:
1305113053
self.__add_pytest_html_extra()
1305213054
sb_config._has_exception = True
13055+
sb_config._has_logs = True
1305313056
if (
1305413057
self.with_testing_base
1305513058
and not has_exception
@@ -13067,6 +13070,7 @@ def tearDown(self):
1306713070
self.__last_page_screenshot_png,
1306813071
)
1306913072
self.__add_pytest_html_extra()
13073+
sb_config._has_logs = True
1307013074
if self.with_testing_base and has_exception:
1307113075
test_logpath = os.path.join(self.log_path, test_id)
1307213076
self.__create_log_path_as_needed(test_logpath)

seleniumbase/plugins/pytest_plugin.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,7 @@ def pytest_configure(config):
12091209
sb_config.external_pdf = config.getoption("external_pdf")
12101210
sb_config.timeout_multiplier = config.getoption("timeout_multiplier")
12111211
sb_config._is_timeout_changed = False
1212+
sb_config._has_logs = False
12121213
sb_config._SMALL_TIMEOUT = settings.SMALL_TIMEOUT
12131214
sb_config._LARGE_TIMEOUT = settings.LARGE_TIMEOUT
12141215
sb_config.pytest_html_report = config.getoption("htmlpath") # --html=FILE
@@ -1474,7 +1475,11 @@ def pytest_terminal_summary(terminalreporter):
14741475
# Print link a second time because the first one may be off-screen
14751476
dashboard_file = os.getcwd() + "/dashboard.html"
14761477
terminalreporter.write_sep("-", "Dashboard: %s" % dashboard_file)
1477-
if sb_config._has_exception or sb_config.save_screenshot:
1478+
if (
1479+
sb_config._has_exception
1480+
or sb_config.save_screenshot
1481+
or sb_config._has_logs
1482+
):
14781483
# Log files are generated during test failures and Screenshot Mode
14791484
terminalreporter.write_sep("-", "LogPath: %s" % latest_logs_dir)
14801485

0 commit comments

Comments
 (0)