23
23
@contextmanager # Usage: -> ``with SB() as sb:``
24
24
def SB (
25
25
test = None , # Test Mode: Output, Logging, Continue on failure unless "rtf".
26
- raise_test_failure = None , # In "test" mode, raise Exception at 1st failure .
27
- rtf = None , # Short form of "raise_test_failure". (Less typing, same thing!)
26
+ rtf = None , # Shortcut / Duplicate of "raise_test_failure" .
27
+ raise_test_failure = None , # If "test" mode, raise Exception on 1st failure.
28
28
browser = None , # Choose from "chrome", "edge", "firefox", or "safari".
29
29
headless = None , # The original headless mode for Chromium and Firefox.
30
30
headless2 = None , # Chromium's new headless mode. (Has more features)
@@ -59,11 +59,14 @@ def SB(
59
59
firefox_arg = None , # "ARG=N,ARG2" (Set Firefox args, comma-separated.)
60
60
firefox_pref = None , # SET (Set Firefox PREFERENCE:VALUE set, ","-separated)
61
61
user_data_dir = None , # Set the Chrome user data directory to use.
62
- extension_zip = None , # Load a Chrome Extension .zip|.crx, comma-separated.)
63
- extension_dir = None , # Load a Chrome Extension directory, comma-separated.)
62
+ extension_zip = None , # Load a Chrome Extension .zip|.crx, comma-separated.
63
+ extension_dir = None , # Load a Chrome Extension directory, comma-separated.
64
64
page_load_strategy = None , # Set Chrome PLS to "normal", "eager", or "none".
65
+ skip_js_waits = None , # Skip JS Waits (readyState=="complete" and Angular).
66
+ use_wire = None , # Use selenium-wire's webdriver over selenium webdriver.
65
67
external_pdf = None , # Set Chrome "plugins.always_open_pdf_externally":True.
66
68
is_mobile = None , # Use the mobile device emulator while running tests.
69
+ mobile = None , # Shortcut / Duplicate of "is_mobile".
67
70
device_metrics = None , # Set mobile metrics: "CSSWidth,CSSHeight,PixelRatio"
68
71
xvfb = None , # Run tests using the Xvfb virtual display server on Linux OS.
69
72
start_page = None , # The starting URL for the web browser when tests begin.
@@ -82,9 +85,12 @@ def SB(
82
85
disable_ws = None , # Reverse of "enable_ws". (None and False are different)
83
86
disable_beforeunload = None , # Disable the "beforeunload" event on Chromium.
84
87
settings_file = None , # A file for overriding default SeleniumBase settings.
85
- uc = None , # Shortcut / Duplicate of "undetectable" to avoid confusion.
86
- undetected = None , # Duplicate of "undetectable" to avoid confusion.
87
- uc_sub = None , # Duplicate of "uc_subprocess" to avoid confusion.
88
+ uc = None , # Shortcut / Duplicate of "undetectable".
89
+ undetected = None , # Shortcut / Duplicate of "undetectable".
90
+ uc_sub = None , # Shortcut / Duplicate of "uc_subprocess".
91
+ wire = None , # Shortcut / Duplicate of "use_wire".
92
+ pls = None , # Shortcut / Duplicate of "page_load_strategy".
93
+ sjw = None , # Shortcut / Duplicate of "skip_js_waits".
88
94
save_screenshot = None , # Save a screenshot at the end of each test.
89
95
timeout_multiplier = None , # Multiplies the default timeout values.
90
96
js_checking_on = None , # Check for JavaScript errors after page loads.
@@ -154,6 +160,7 @@ def SB(
154
160
raise_test_failure
155
161
or rtf
156
162
or "--raise-test-failure" in sys_argv
163
+ or "--raise_test_failure" in sys_argv
157
164
or "--rtf" in sys_argv
158
165
or "-x" in sys_argv # Carry-over from "pytest"
159
166
or "--exitfirst" in sys_argv # Carry-over from "pytest"
@@ -286,6 +293,8 @@ def SB(
286
293
devtools = True
287
294
else :
288
295
devtools = False
296
+ if mobile is not None and is_mobile is None :
297
+ is_mobile = mobile
289
298
if is_mobile is None :
290
299
if "--mobile" in sys_argv :
291
300
is_mobile = True
@@ -416,6 +425,9 @@ def SB(
416
425
uc_subprocess = True
417
426
else :
418
427
uc_subprocess = False
428
+ if undetectable and is_mobile :
429
+ is_mobile = False
430
+ user_agent = None
419
431
if use_auto_ext is None :
420
432
if "--use-auto-ext" in sys_argv :
421
433
use_auto_ext = True
@@ -432,6 +444,8 @@ def SB(
432
444
_disable_beforeunload = False
433
445
if disable_beforeunload :
434
446
_disable_beforeunload = True
447
+ if pls is not None and page_load_strategy is None :
448
+ page_load_strategy = pls
435
449
if page_load_strategy is not None :
436
450
if page_load_strategy .lower () not in ["normal" , "eager" , "none" ]:
437
451
raise Exception (
@@ -444,12 +458,17 @@ def SB(
444
458
page_load_strategy = "eager"
445
459
elif "--pls=none" in sys_argv or '--pls="none"' in sys_argv :
446
460
page_load_strategy = "none"
447
- if (
448
- "--sjw" in sys_argv
449
- or "--skip_js_waits" in sys_argv
450
- or "--skip-js-waits" in sys_argv
451
- ):
452
- settings .SKIP_JS_WAITS = True
461
+ if sjw is not None and skip_js_waits is None :
462
+ skip_js_waits = sjw
463
+ if skip_js_waits is None :
464
+ if (
465
+ "--sjw" in sys_argv
466
+ or "--skip_js_waits" in sys_argv
467
+ or "--skip-js-waits" in sys_argv
468
+ ):
469
+ settings .SKIP_JS_WAITS = True
470
+ elif skip_js_waits :
471
+ settings .SKIP_JS_WAITS = skip_js_waits
453
472
if save_screenshot is None :
454
473
if "--screenshot" in sys_argv or "--save-screenshot" in sys_argv :
455
474
save_screenshot = True
@@ -480,6 +499,15 @@ def SB(
480
499
do_not_track = True
481
500
else :
482
501
do_not_track = False
502
+ if use_wire is None and wire is None :
503
+ if "--wire" in sys_argv :
504
+ use_wire = True
505
+ else :
506
+ use_wire = False
507
+ elif use_wire or wire :
508
+ use_wire = True
509
+ else :
510
+ use_wire = False
483
511
if external_pdf is None :
484
512
if "--external-pdf" in sys_argv or "--external_pdf" in sys_argv :
485
513
external_pdf = True
@@ -598,6 +626,7 @@ def SB(
598
626
sb_config .message_duration = message_duration
599
627
sb_config .block_images = block_images
600
628
sb_config .do_not_track = do_not_track
629
+ sb_config .use_wire = use_wire
601
630
sb_config .external_pdf = external_pdf
602
631
sb_config .remote_debug = remote_debug
603
632
sb_config .settings_file = settings_file
@@ -691,6 +720,7 @@ def SB(
691
720
sb .message_duration = sb_config .message_duration
692
721
sb .block_images = sb_config .block_images
693
722
sb .do_not_track = sb_config .do_not_track
723
+ sb .use_wire = sb_config .use_wire
694
724
sb .external_pdf = sb_config .external_pdf
695
725
sb .remote_debug = sb_config .remote_debug
696
726
sb .settings_file = sb_config .settings_file
0 commit comments