Skip to content

Commit a21c1ce

Browse files
committed
Add "--dash-title" option to customize the Dashboard title
1 parent e82abee commit a21c1ce

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ The code above will leave your browser window open in case there's a failure. (i
484484
--use-auto-ext # (Use Chrome's automation extension.)
485485
--remote-debug # (Enable Chrome's Remote Debugger on http://localhost:9222)
486486
--dashboard # (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
487+
--dash-title=STRING # (Set the title shown for the generated dashboard.)
487488
--swiftshader # (Use Chrome's "--use-gl=swiftshader" feature.)
488489
--incognito # (Enable Chrome's Incognito mode.)
489490
--guest # (Enable Chrome's Guest mode.)

help_docs/customizing_test_runs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pytest my_first_test.py --settings-file=custom_settings.py
157157
--use-auto-ext # (Use Chrome's automation extension.)
158158
--remote-debug # (Enable Chrome's Remote Debugger on http://localhost:9222)
159159
--dashboard # (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
160+
--dash-title=STRING # (Set the title shown for the generated dashboard.)
160161
--swiftshader # (Use Chrome's "--use-gl=swiftshader" feature.)
161162
--incognito # (Enable Chrome's Incognito mode.)
162163
--guest # (Enable Chrome's Guest mode.)

seleniumbase/behave/behave_sb.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
-D use-auto-ext (Use Chrome's automation extension.)
6969
-D remote-debug (Enable Chrome's Remote Debugger on http://localhost:9222)
7070
-D dashboard (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
71+
-D dash-title=STRING (Set the title shown for the generated dashboard.)
7172
-D swiftshader (Use Chrome's "--use-gl=swiftshader" feature.)
7273
-D incognito (Enable Chrome's Incognito mode.)
7374
-D guest (Enable Chrome's Guest mode.)
@@ -177,6 +178,7 @@ def get_configured_sb(context):
177178
sb.time_limit = None
178179
sb.demo_sleep = None
179180
sb.dashboard = False
181+
sb.dash_title = None
180182
sb._dash_initialized = False
181183
sb.message_duration = None
182184
sb.block_images = False
@@ -537,6 +539,10 @@ def get_configured_sb(context):
537539
if low_key == "dashboard":
538540
sb.dashboard = True
539541
continue
542+
# Handle: -D dash-title=TITLE / dash_title=TITLE
543+
if low_key in ["dash-title", "dash_title"]:
544+
sb.dash_title = userdata[key]
545+
continue
540546
# Handle: -D message-duration / message_duration
541547
if low_key in ["message-duration", "message_duration"]:
542548
message_duration = userdata[key]
@@ -689,9 +695,14 @@ def get_configured_sb(context):
689695
sb.protocol = "https"
690696

691697
# Set sb_config
698+
sb_config.browser = sb.browser
699+
sb_config.headless = sb.headless
700+
sb_config.headed = sb.headed
701+
sb_config.xvfb = sb.xvfb
692702
sb_config.save_screenshot = sb.save_screenshot_after_test
693703
sb_config.variables = sb.variables
694704
sb_config.dashboard = sb.dashboard
705+
sb_config.dash_title = sb.dash_title
695706
sb_config.pdb_option = sb.pdb_option
696707
sb_config.rec_behave = sb.rec_behave
697708
sb_config.record_sleep = sb.record_sleep
@@ -720,6 +731,9 @@ def get_configured_sb(context):
720731
sb_config._dash_final_summary = None # Dash status to add to html report
721732
sb_config._html_report_name = None # The name of the pytest html report
722733

734+
if sb_config.dash_title:
735+
constants.Dashboard.TITLE = sb_config.dash_title.replace("_", " ")
736+
723737
log_helper.log_folder_setup(sb.log_path, sb.archive_logs)
724738
download_helper.reset_downloads_folder()
725739
proxy_helper.remove_proxy_zip_if_present()

seleniumbase/plugins/pytest_plugin.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def pytest_addoption(parser):
7979
--use-auto-ext (Use Chrome's automation extension.)
8080
--remote-debug (Enable Chrome's Remote Debugger on http://localhost:9222)
8181
--dashboard (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
82+
--dash-title=STRING (Set the title shown for the generated dashboard.)
8283
--swiftshader (Use Chrome's "--use-gl=swiftshader" feature.)
8384
--incognito (Enable Chrome's Incognito mode.)
8485
--guest (Enable Chrome's Guest mode.)
@@ -831,6 +832,13 @@ def pytest_addoption(parser):
831832
open the dashboard.html file located in the same
832833
folder that the pytest command was run from.""",
833834
)
835+
parser.addoption(
836+
"--dash_title",
837+
"--dash-title",
838+
dest="dash_title",
839+
default=None,
840+
help="Set the title shown for the generated dashboard.",
841+
)
834842
parser.addoption(
835843
"--swiftshader",
836844
action="store_true",
@@ -1174,6 +1182,7 @@ def pytest_configure(config):
11741182
sb_config.disable_gpu = config.getoption("disable_gpu")
11751183
sb_config.remote_debug = config.getoption("remote_debug")
11761184
sb_config.dashboard = config.getoption("dashboard")
1185+
sb_config.dash_title = config.getoption("dash_title")
11771186
sb_config.swiftshader = config.getoption("swiftshader")
11781187
sb_config.incognito = config.getoption("incognito")
11791188
sb_config.guest_mode = config.getoption("guest_mode")
@@ -1256,6 +1265,9 @@ def pytest_configure(config):
12561265
else:
12571266
pass # Use the browser specified using "--browser=BROWSER"
12581267

1268+
if sb_config.dash_title:
1269+
constants.Dashboard.TITLE = sb_config.dash_title.replace("_", " ")
1270+
12591271
from seleniumbase.core import log_helper
12601272
from seleniumbase.core import download_helper
12611273
from seleniumbase.core import proxy_helper

0 commit comments

Comments
 (0)