Skip to content

Commit

Permalink
Merge pull request #2740 from seleniumbase/add-command-line-shortcuts
Browse files Browse the repository at this point in the history
Add command-line shortcuts for `SB()` / `Driver()` formats
  • Loading branch information
mdmintz authored May 2, 2024
2 parents 989bd86 + 92b957d commit 06a495e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.26.1"
__version__ = "4.26.2"
13 changes: 13 additions & 0 deletions seleniumbase/plugins/driver_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ def Driver(
):
recorder_mode = True
recorder_ext = True
if headed is None:
# Override the default headless mode on Linux if set.
if "--gui" in sys_argv or "--headed" in sys_argv:
headed = True
else:
headed = False
if (
shared_utils.is_linux()
and not headed
Expand Down Expand Up @@ -434,6 +440,13 @@ def Driver(
disable_js = False
if pls is not None and page_load_strategy is None:
page_load_strategy = pls
if not page_load_strategy and "--pls=" in arg_join:
if "--pls=none" in sys_argv or '--pls="none"' in sys_argv:
page_load_strategy = "none"
elif "--pls=eager" in sys_argv or '--pls="eager"' in sys_argv:
page_load_strategy = "eager"
elif "--pls=normal" in sys_argv or '--pls="normal"' in sys_argv:
page_load_strategy = "normal"
if page_load_strategy is not None:
if page_load_strategy.lower() not in ["normal", "eager", "none"]:
raise Exception(
Expand Down
18 changes: 18 additions & 0 deletions seleniumbase/plugins/sb_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,20 @@ def SB(
record_sleep = True
else:
record_sleep = False
if xvfb is None:
if "--xvfb" in sys_argv:
xvfb = True
else:
xvfb = False
if not shared_utils.is_linux():
# The Xvfb virtual display server is for Linux OS Only!
xvfb = False
if headed is None:
# Override the default headless mode on Linux if set.
if "--gui" in sys_argv or "--headed" in sys_argv:
headed = True
else:
headed = False
if (
shared_utils.is_linux()
and not headed
Expand Down Expand Up @@ -532,6 +543,13 @@ def SB(
_disable_beforeunload = True
if pls is not None and page_load_strategy is None:
page_load_strategy = pls
if not page_load_strategy and "--pls=" in arg_join:
if "--pls=none" in sys_argv or '--pls="none"' in sys_argv:
page_load_strategy = "none"
elif "--pls=eager" in sys_argv or '--pls="eager"' in sys_argv:
page_load_strategy = "eager"
elif "--pls=normal" in sys_argv or '--pls="normal"' in sys_argv:
page_load_strategy = "normal"
if page_load_strategy is not None:
if page_load_strategy.lower() not in ["normal", "eager", "none"]:
raise Exception(
Expand Down

0 comments on commit 06a495e

Please sign in to comment.