Add "--dash-title" option to customize the Dashboard title

This commit is contained in:
Michael Mintz 2022-06-03 16:58:10 -04:00
parent e82abee400
commit a21c1ce41a
4 changed files with 28 additions and 0 deletions

View File

@ -484,6 +484,7 @@ The code above will leave your browser window open in case there's a failure. (i
--use-auto-ext # (Use Chrome's automation extension.)
--remote-debug # (Enable Chrome's Remote Debugger on http://localhost:9222)
--dashboard # (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
--dash-title=STRING # (Set the title shown for the generated dashboard.)
--swiftshader # (Use Chrome's "--use-gl=swiftshader" feature.)
--incognito # (Enable Chrome's Incognito mode.)
--guest # (Enable Chrome's Guest mode.)

View File

@ -157,6 +157,7 @@ pytest my_first_test.py --settings-file=custom_settings.py
--use-auto-ext # (Use Chrome's automation extension.)
--remote-debug # (Enable Chrome's Remote Debugger on http://localhost:9222)
--dashboard # (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
--dash-title=STRING # (Set the title shown for the generated dashboard.)
--swiftshader # (Use Chrome's "--use-gl=swiftshader" feature.)
--incognito # (Enable Chrome's Incognito mode.)
--guest # (Enable Chrome's Guest mode.)

View File

@ -68,6 +68,7 @@ behave -D agent="User Agent String" -D demo
-D use-auto-ext (Use Chrome's automation extension.)
-D remote-debug (Enable Chrome's Remote Debugger on http://localhost:9222)
-D dashboard (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
-D dash-title=STRING (Set the title shown for the generated dashboard.)
-D swiftshader (Use Chrome's "--use-gl=swiftshader" feature.)
-D incognito (Enable Chrome's Incognito mode.)
-D guest (Enable Chrome's Guest mode.)
@ -177,6 +178,7 @@ def get_configured_sb(context):
sb.time_limit = None
sb.demo_sleep = None
sb.dashboard = False
sb.dash_title = None
sb._dash_initialized = False
sb.message_duration = None
sb.block_images = False
@ -537,6 +539,10 @@ def get_configured_sb(context):
if low_key == "dashboard":
sb.dashboard = True
continue
# Handle: -D dash-title=TITLE / dash_title=TITLE
if low_key in ["dash-title", "dash_title"]:
sb.dash_title = userdata[key]
continue
# Handle: -D message-duration / message_duration
if low_key in ["message-duration", "message_duration"]:
message_duration = userdata[key]
@ -689,9 +695,14 @@ def get_configured_sb(context):
sb.protocol = "https"
# Set sb_config
sb_config.browser = sb.browser
sb_config.headless = sb.headless
sb_config.headed = sb.headed
sb_config.xvfb = sb.xvfb
sb_config.save_screenshot = sb.save_screenshot_after_test
sb_config.variables = sb.variables
sb_config.dashboard = sb.dashboard
sb_config.dash_title = sb.dash_title
sb_config.pdb_option = sb.pdb_option
sb_config.rec_behave = sb.rec_behave
sb_config.record_sleep = sb.record_sleep
@ -720,6 +731,9 @@ def get_configured_sb(context):
sb_config._dash_final_summary = None # Dash status to add to html report
sb_config._html_report_name = None # The name of the pytest html report
if sb_config.dash_title:
constants.Dashboard.TITLE = sb_config.dash_title.replace("_", " ")
log_helper.log_folder_setup(sb.log_path, sb.archive_logs)
download_helper.reset_downloads_folder()
proxy_helper.remove_proxy_zip_if_present()

View File

@ -79,6 +79,7 @@ def pytest_addoption(parser):
--use-auto-ext (Use Chrome's automation extension.)
--remote-debug (Enable Chrome's Remote Debugger on http://localhost:9222)
--dashboard (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
--dash-title=STRING (Set the title shown for the generated dashboard.)
--swiftshader (Use Chrome's "--use-gl=swiftshader" feature.)
--incognito (Enable Chrome's Incognito mode.)
--guest (Enable Chrome's Guest mode.)
@ -831,6 +832,13 @@ def pytest_addoption(parser):
open the dashboard.html file located in the same
folder that the pytest command was run from.""",
)
parser.addoption(
"--dash_title",
"--dash-title",
dest="dash_title",
default=None,
help="Set the title shown for the generated dashboard.",
)
parser.addoption(
"--swiftshader",
action="store_true",
@ -1174,6 +1182,7 @@ def pytest_configure(config):
sb_config.disable_gpu = config.getoption("disable_gpu")
sb_config.remote_debug = config.getoption("remote_debug")
sb_config.dashboard = config.getoption("dashboard")
sb_config.dash_title = config.getoption("dash_title")
sb_config.swiftshader = config.getoption("swiftshader")
sb_config.incognito = config.getoption("incognito")
sb_config.guest_mode = config.getoption("guest_mode")
@ -1256,6 +1265,9 @@ def pytest_configure(config):
else:
pass # Use the browser specified using "--browser=BROWSER"
if sb_config.dash_title:
constants.Dashboard.TITLE = sb_config.dash_title.replace("_", " ")
from seleniumbase.core import log_helper
from seleniumbase.core import download_helper
from seleniumbase.core import proxy_helper