Skip to content

Commit 06a495e

Browse files
authored
Merge pull request #2740 from seleniumbase/add-command-line-shortcuts
Add command-line shortcuts for `SB()` / `Driver()` formats
2 parents 989bd86 + 92b957d commit 06a495e

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.26.1"
2+
__version__ = "4.26.2"

seleniumbase/plugins/driver_manager.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ def Driver(
328328
):
329329
recorder_mode = True
330330
recorder_ext = True
331+
if headed is None:
332+
# Override the default headless mode on Linux if set.
333+
if "--gui" in sys_argv or "--headed" in sys_argv:
334+
headed = True
335+
else:
336+
headed = False
331337
if (
332338
shared_utils.is_linux()
333339
and not headed
@@ -434,6 +440,13 @@ def Driver(
434440
disable_js = False
435441
if pls is not None and page_load_strategy is None:
436442
page_load_strategy = pls
443+
if not page_load_strategy and "--pls=" in arg_join:
444+
if "--pls=none" in sys_argv or '--pls="none"' in sys_argv:
445+
page_load_strategy = "none"
446+
elif "--pls=eager" in sys_argv or '--pls="eager"' in sys_argv:
447+
page_load_strategy = "eager"
448+
elif "--pls=normal" in sys_argv or '--pls="normal"' in sys_argv:
449+
page_load_strategy = "normal"
437450
if page_load_strategy is not None:
438451
if page_load_strategy.lower() not in ["normal", "eager", "none"]:
439452
raise Exception(

seleniumbase/plugins/sb_manager.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,20 @@ def SB(
378378
record_sleep = True
379379
else:
380380
record_sleep = False
381+
if xvfb is None:
382+
if "--xvfb" in sys_argv:
383+
xvfb = True
384+
else:
385+
xvfb = False
381386
if not shared_utils.is_linux():
382387
# The Xvfb virtual display server is for Linux OS Only!
383388
xvfb = False
389+
if headed is None:
390+
# Override the default headless mode on Linux if set.
391+
if "--gui" in sys_argv or "--headed" in sys_argv:
392+
headed = True
393+
else:
394+
headed = False
384395
if (
385396
shared_utils.is_linux()
386397
and not headed
@@ -532,6 +543,13 @@ def SB(
532543
_disable_beforeunload = True
533544
if pls is not None and page_load_strategy is None:
534545
page_load_strategy = pls
546+
if not page_load_strategy and "--pls=" in arg_join:
547+
if "--pls=none" in sys_argv or '--pls="none"' in sys_argv:
548+
page_load_strategy = "none"
549+
elif "--pls=eager" in sys_argv or '--pls="eager"' in sys_argv:
550+
page_load_strategy = "eager"
551+
elif "--pls=normal" in sys_argv or '--pls="normal"' in sys_argv:
552+
page_load_strategy = "normal"
535553
if page_load_strategy is not None:
536554
if page_load_strategy.lower() not in ["normal", "eager", "none"]:
537555
raise Exception(

0 commit comments

Comments
 (0)