seleniumbase 4.24.10__py3-none-any.whl → 4.33.15__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. sbase/__init__.py +1 -0
  2. sbase/steps.py +7 -0
  3. seleniumbase/__init__.py +16 -7
  4. seleniumbase/__version__.py +1 -1
  5. seleniumbase/behave/behave_sb.py +97 -32
  6. seleniumbase/common/decorators.py +16 -7
  7. seleniumbase/config/proxy_list.py +3 -3
  8. seleniumbase/config/settings.py +4 -0
  9. seleniumbase/console_scripts/logo_helper.py +47 -8
  10. seleniumbase/console_scripts/run.py +345 -335
  11. seleniumbase/console_scripts/sb_behave_gui.py +5 -12
  12. seleniumbase/console_scripts/sb_caseplans.py +6 -13
  13. seleniumbase/console_scripts/sb_commander.py +5 -12
  14. seleniumbase/console_scripts/sb_install.py +62 -54
  15. seleniumbase/console_scripts/sb_mkchart.py +13 -20
  16. seleniumbase/console_scripts/sb_mkdir.py +11 -17
  17. seleniumbase/console_scripts/sb_mkfile.py +69 -43
  18. seleniumbase/console_scripts/sb_mkpres.py +13 -20
  19. seleniumbase/console_scripts/sb_mkrec.py +88 -21
  20. seleniumbase/console_scripts/sb_objectify.py +30 -30
  21. seleniumbase/console_scripts/sb_print.py +5 -12
  22. seleniumbase/console_scripts/sb_recorder.py +16 -11
  23. seleniumbase/core/browser_launcher.py +1658 -221
  24. seleniumbase/core/detect_b_ver.py +7 -8
  25. seleniumbase/core/log_helper.py +42 -27
  26. seleniumbase/core/mysql.py +1 -4
  27. seleniumbase/core/proxy_helper.py +35 -30
  28. seleniumbase/core/recorder_helper.py +24 -5
  29. seleniumbase/core/sb_cdp.py +1951 -0
  30. seleniumbase/core/sb_driver.py +162 -8
  31. seleniumbase/core/settings_parser.py +6 -0
  32. seleniumbase/core/style_sheet.py +10 -0
  33. seleniumbase/extensions/recorder.zip +0 -0
  34. seleniumbase/fixtures/base_case.py +1234 -632
  35. seleniumbase/fixtures/constants.py +10 -1
  36. seleniumbase/fixtures/js_utils.py +171 -144
  37. seleniumbase/fixtures/page_actions.py +177 -13
  38. seleniumbase/fixtures/page_utils.py +25 -53
  39. seleniumbase/fixtures/shared_utils.py +97 -11
  40. seleniumbase/js_code/active_css_js.py +1 -1
  41. seleniumbase/js_code/recorder_js.py +1 -1
  42. seleniumbase/plugins/base_plugin.py +2 -3
  43. seleniumbase/plugins/driver_manager.py +340 -65
  44. seleniumbase/plugins/pytest_plugin.py +276 -47
  45. seleniumbase/plugins/sb_manager.py +412 -99
  46. seleniumbase/plugins/selenium_plugin.py +122 -17
  47. seleniumbase/translate/translator.py +0 -7
  48. seleniumbase/undetected/__init__.py +59 -52
  49. seleniumbase/undetected/cdp.py +0 -1
  50. seleniumbase/undetected/cdp_driver/__init__.py +1 -0
  51. seleniumbase/undetected/cdp_driver/_contradict.py +110 -0
  52. seleniumbase/undetected/cdp_driver/browser.py +829 -0
  53. seleniumbase/undetected/cdp_driver/cdp_util.py +458 -0
  54. seleniumbase/undetected/cdp_driver/config.py +334 -0
  55. seleniumbase/undetected/cdp_driver/connection.py +639 -0
  56. seleniumbase/undetected/cdp_driver/element.py +1168 -0
  57. seleniumbase/undetected/cdp_driver/tab.py +1323 -0
  58. seleniumbase/undetected/dprocess.py +4 -7
  59. seleniumbase/undetected/options.py +6 -8
  60. seleniumbase/undetected/patcher.py +11 -13
  61. seleniumbase/undetected/reactor.py +0 -1
  62. seleniumbase/undetected/webelement.py +16 -3
  63. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/LICENSE +1 -1
  64. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/METADATA +299 -252
  65. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/RECORD +68 -70
  66. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/WHEEL +1 -1
  67. sbase/ReadMe.txt +0 -2
  68. seleniumbase/ReadMe.md +0 -25
  69. seleniumbase/common/ReadMe.md +0 -71
  70. seleniumbase/console_scripts/ReadMe.md +0 -731
  71. seleniumbase/drivers/ReadMe.md +0 -27
  72. seleniumbase/extensions/ReadMe.md +0 -12
  73. seleniumbase/masterqa/ReadMe.md +0 -61
  74. seleniumbase/resources/ReadMe.md +0 -31
  75. seleniumbase/resources/favicon.ico +0 -0
  76. seleniumbase/utilities/selenium_grid/ReadMe.md +0 -84
  77. seleniumbase/utilities/selenium_ide/ReadMe.md +0 -111
  78. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/entry_points.txt +0 -0
  79. {seleniumbase-4.24.10.dist-info → seleniumbase-4.33.15.dist-info}/top_level.txt +0 -0
@@ -7,7 +7,7 @@ Usage --> ``with SB() as sb:``
7
7
 
8
8
  Example -->
9
9
 
10
- ```
10
+ ```python
11
11
  from seleniumbase import SB
12
12
 
13
13
  with SB() as sb: # Many args! Eg. SB(browser="edge")
@@ -32,8 +32,9 @@ def SB(
32
32
  rtf=None, # Shortcut / Duplicate of "raise_test_failure".
33
33
  raise_test_failure=None, # If "test" mode, raise Exception on 1st failure.
34
34
  browser=None, # Choose from "chrome", "edge", "firefox", or "safari".
35
- headless=None, # The original headless mode for Chromium and Firefox.
36
- headless2=None, # Chromium's new headless mode. (Has more features)
35
+ headless=None, # Use the default headless mode for Chromium and Firefox.
36
+ headless1=None, # Use Chromium's old headless mode. (Fast, but limited)
37
+ headless2=None, # Use Chromium's new headless mode. (Has more features)
37
38
  locale_code=None, # Set the Language Locale Code for the web browser.
38
39
  protocol=None, # The Selenium Grid protocol: "http" or "https".
39
40
  servername=None, # The Selenium Grid server/IP used for tests.
@@ -41,12 +42,13 @@ def SB(
41
42
  proxy=None, # Use proxy. Format: "SERVER:PORT" or "USER:PASS@SERVER:PORT".
42
43
  proxy_bypass_list=None, # Skip proxy when using the listed domains.
43
44
  proxy_pac_url=None, # Use PAC file. (Format: URL or USERNAME:PASSWORD@URL)
44
- multi_proxy=False, # Allow multiple proxies with auth when multi-threaded.
45
+ multi_proxy=None, # Allow multiple proxies with auth when multi-threaded.
45
46
  agent=None, # Modify the web browser's User-Agent string.
46
47
  cap_file=None, # The desired capabilities to use with a Selenium Grid.
47
48
  cap_string=None, # The desired capabilities to use with a Selenium Grid.
48
49
  recorder_ext=None, # Enables the SeleniumBase Recorder Chromium extension.
49
- disable_js=None, # Disable JavaScript on websites. Pages might break!
50
+ disable_cookies=None, # Disable Cookies on websites. (Pages might break!)
51
+ disable_js=None, # Disable JavaScript on websites. (Pages might break!)
50
52
  disable_csp=None, # Disable the Content Security Policy of websites.
51
53
  enable_ws=None, # Enable Web Security on Chromium-based browsers.
52
54
  enable_sync=None, # Enable "Chrome Sync" on websites.
@@ -76,12 +78,16 @@ def SB(
76
78
  binary_location=None, # Set path of the Chromium browser binary to use.
77
79
  driver_version=None, # Set the chromedriver or uc_driver version to use.
78
80
  skip_js_waits=None, # Skip JS Waits (readyState=="complete" and Angular).
81
+ wait_for_angularjs=None, # Wait for AngularJS to load after some actions.
79
82
  use_wire=None, # Use selenium-wire's webdriver over selenium webdriver.
80
83
  external_pdf=None, # Set Chrome "plugins.always_open_pdf_externally":True.
84
+ window_position=None, # Set the browser's starting window position: "X,Y"
85
+ window_size=None, # Set the browser's starting window size: "Width,Height"
81
86
  is_mobile=None, # Use the mobile device emulator while running tests.
82
87
  mobile=None, # Shortcut / Duplicate of "is_mobile".
83
88
  device_metrics=None, # Set mobile metrics: "CSSWidth,CSSHeight,PixelRatio"
84
89
  xvfb=None, # Run tests using the Xvfb virtual display server on Linux OS.
90
+ xvfb_metrics=None, # Set Xvfb display size on Linux: "Width,Height".
85
91
  start_page=None, # The starting URL for the web browser when tests begin.
86
92
  rec_print=None, # If Recorder is enabled, prints output after tests end.
87
93
  rec_behave=None, # Like Recorder Mode, but also generates behave-gherkin.
@@ -98,14 +104,21 @@ def SB(
98
104
  disable_ws=None, # Reverse of "enable_ws". (None and False are different)
99
105
  disable_beforeunload=None, # Disable the "beforeunload" event on Chromium.
100
106
  settings_file=None, # A file for overriding default SeleniumBase settings.
107
+ position=None, # Shortcut / Duplicate of "window_position".
108
+ size=None, # Shortcut / Duplicate of "window_size".
101
109
  uc=None, # Shortcut / Duplicate of "undetectable".
102
110
  undetected=None, # Shortcut / Duplicate of "undetectable".
103
111
  uc_cdp=None, # Shortcut / Duplicate of "uc_cdp_events".
104
112
  uc_sub=None, # Shortcut / Duplicate of "uc_subprocess".
113
+ locale=None, # Shortcut / Duplicate of "locale_code".
105
114
  log_cdp=None, # Shortcut / Duplicate of "log_cdp_events".
115
+ ad_block=None, # Shortcut / Duplicate of "ad_block_on".
116
+ server=None, # Shortcut / Duplicate of "servername".
117
+ guest=None, # Shortcut / Duplicate of "guest_mode".
106
118
  wire=None, # Shortcut / Duplicate of "use_wire".
107
119
  pls=None, # Shortcut / Duplicate of "page_load_strategy".
108
120
  sjw=None, # Shortcut / Duplicate of "skip_js_waits".
121
+ wfa=None, # Shortcut / Duplicate of "wait_for_angularjs".
109
122
  save_screenshot=None, # Save a screenshot at the end of each test.
110
123
  no_screenshot=None, # No screenshots saved unless tests directly ask it.
111
124
  page_load_strategy=None, # Set Chrome PLS to "normal", "eager", or "none".
@@ -119,6 +132,130 @@ def SB(
119
132
  interval=None, # SECONDS (Autoplay interval for SB Slides & Tour steps.)
120
133
  time_limit=None, # SECONDS (Safely fail tests that exceed the time limit.)
121
134
  ):
135
+ """
136
+ * SeleniumBase as a Python Context Manager *
137
+
138
+ Example:
139
+ --------
140
+ .. code-block:: python
141
+ from seleniumbase import SB
142
+
143
+ with SB() as sb: # Many args! Eg. SB(browser="edge")
144
+ sb.open("https://google.com/ncr")
145
+ sb.type('[name="q"]', "SeleniumBase on GitHub")
146
+ sb.submit('[name="q"]')
147
+ sb.click('a[href*="github.com/seleniumbase"]')
148
+ sb.highlight("div.Layout-main")
149
+ sb.highlight("div.Layout-sidebar")
150
+ sb.sleep(0.5)
151
+
152
+ Optional Parameters:
153
+ --------------------
154
+ test (bool): Test Mode: Output, Logging, Continue on failure unless "rtf".
155
+ rtf (bool): Shortcut / Duplicate of "raise_test_failure".
156
+ raise_test_failure (bool): If "test" mode, raise Exception on 1st failure.
157
+ browser (str): Choose from "chrome", "edge", "firefox", or "safari".
158
+ headless (bool): Use the default headless mode for Chromium and Firefox.
159
+ headless1 (bool): Use Chromium's old headless mode. (Fast, but limited)
160
+ headless2 (bool): Use Chromium's new headless mode. (Has more features)
161
+ locale_code (str): Set the Language Locale Code for the web browser.
162
+ protocol (str): The Selenium Grid protocol: "http" or "https".
163
+ servername (str): The Selenium Grid server/IP used for tests.
164
+ port (int): The Selenium Grid port used by the test server.
165
+ proxy (str): Use proxy. Format: "SERVER:PORT" or "USER:PASS@SERVER:PORT".
166
+ proxy_bypass_list (str): Skip proxy when using the listed domains.
167
+ proxy_pac_url (str): Use PAC file. (Format: URL or USERNAME:PASSWORD@URL)
168
+ multi_proxy (bool): # Allow multiple proxies with auth when multithreaded.
169
+ agent (str): Modify the web browser's User-Agent string.
170
+ cap_file (str): The desired capabilities to use with a Selenium Grid.
171
+ cap_string (str): The desired capabilities to use with a Selenium Grid.
172
+ recorder_ext (bool): Enables the SeleniumBase Recorder Chromium extension.
173
+ disable_cookies (bool): Disable Cookies on websites. (Pages might break!)
174
+ disable_js (bool): Disable JavaScript on websites. (Pages might break!)
175
+ disable_csp (bool): Disable the Content Security Policy of websites.
176
+ enable_ws (bool): Enable Web Security on Chromium-based browsers.
177
+ enable_sync (bool): Enable "Chrome Sync" on websites.
178
+ use_auto_ext (bool): Use Chrome's automation extension.
179
+ undetectable (bool): Use undetected-chromedriver to evade bot-detection.
180
+ uc_cdp_events (bool): Capture CDP events in undetected-chromedriver mode.
181
+ uc_subprocess (bool): Use undetected-chromedriver as a subprocess.
182
+ log_cdp_events (bool): Capture {"performance": "ALL", "browser": "ALL"}
183
+ incognito (bool): Enable Chromium's Incognito mode.
184
+ guest_mode (bool): Enable Chromium's Guest mode.
185
+ dark_mode (bool): Enable Chromium's Dark mode.
186
+ devtools (bool): Open Chromium's DevTools when the browser opens.
187
+ remote_debug (bool): Enable Chrome's Debugger on "http://localhost:9222".
188
+ enable_3d_apis (bool): Enable WebGL and 3D APIs.
189
+ swiftshader (bool): Chrome: --use-gl=angle / --use-angle=swiftshader-webgl
190
+ ad_block_on (bool): Block some types of display ads from loading.
191
+ host_resolver_rules (str): Set host-resolver-rules, comma-separated.
192
+ block_images (bool): Block images from loading during tests.
193
+ do_not_track (bool): Tell websites that you don't want to be tracked.
194
+ chromium_arg (str): "ARG=N,ARG2" (Set Chromium args, ","-separated.)
195
+ firefox_arg (str): "ARG=N,ARG2" (Set Firefox args, comma-separated.)
196
+ firefox_pref (str): SET (Set Firefox PREFERENCE:VALUE set, ","-separated)
197
+ user_data_dir (str): Set the Chrome user data directory to use.
198
+ extension_zip (str): Load a Chrome Extension .zip|.crx, comma-separated.
199
+ extension_dir (str): Load a Chrome Extension directory, comma-separated.
200
+ disable_features (str): "F1,F2" (Disable Chrome features, ","-separated.)
201
+ binary_location (str): Set path of the Chromium browser binary to use.
202
+ driver_version (str): Set the chromedriver or uc_driver version to use.
203
+ skip_js_waits (bool): Skip JS Waits (readyState=="complete" and Angular).
204
+ wait_for_angularjs (bool): Wait for AngularJS to load after some actions.
205
+ use_wire (bool): Use selenium-wire's webdriver over selenium webdriver.
206
+ external_pdf (bool): Set Chrome "plugins.always_open_pdf_externally":True.
207
+ window_position (x,y): Set the browser's starting window position: "X,Y"
208
+ window_size (w,h): Set the browser's starting window size: "Width,Height"
209
+ is_mobile (bool): Use the mobile device emulator while running tests.
210
+ mobile (bool): Shortcut / Duplicate of "is_mobile".
211
+ device_metrics (w,h,pr): Mobile metrics: "CSSWidth,CSSHeight,PixelRatio"
212
+ xvfb (bool): Run tests using the Xvfb virtual display server on Linux OS.
213
+ xvfb_metrics (w,h): Set Xvfb display size on Linux: "Width,Height".
214
+ start_page (str): The starting URL for the web browser when tests begin.
215
+ rec_print (bool): If Recorder is enabled, prints output after tests end.
216
+ rec_behave (bool): Like Recorder Mode, but also generates behave-gherkin.
217
+ record_sleep (bool): If Recorder enabled, also records self.sleep calls.
218
+ data (str): Extra test data. Access with "self.data" in tests.
219
+ var1 (str): Extra test data. Access with "self.var1" in tests.
220
+ var2 (str): Extra test data. Access with "self.var2" in tests.
221
+ var3 (str): Extra test data. Access with "self.var3" in tests.
222
+ variables (dict): Extra test data. Access with "self.variables".
223
+ account (str): Set account. Access with "self.account" in tests.
224
+ environment (str): Set the test env. Access with "self.env" in tests.
225
+ headed (bool): Run tests in headed/GUI mode on Linux, where not default.
226
+ maximize (bool): Start tests with the browser window maximized.
227
+ disable_ws (bool): Reverse of "enable_ws". (None and False are different)
228
+ disable_beforeunload (bool): Disable the "beforeunload" event on Chromium.
229
+ settings_file (str): A file for overriding default SeleniumBase settings.
230
+ position (x,y): Shortcut / Duplicate of "window_position".
231
+ size (w,h): Shortcut / Duplicate of "window_size".
232
+ uc (bool): Shortcut / Duplicate of "undetectable".
233
+ undetected (bool): Shortcut / Duplicate of "undetectable".
234
+ uc_cdp (bool): Shortcut / Duplicate of "uc_cdp_events".
235
+ uc_sub (bool): Shortcut / Duplicate of "uc_subprocess".
236
+ locale (str): Shortcut / Duplicate of "locale_code".
237
+ log_cdp (bool): Shortcut / Duplicate of "log_cdp_events".
238
+ ad_block (bool): Shortcut / Duplicate of "ad_block_on".
239
+ server (str): Shortcut / Duplicate of "servername".
240
+ guest (bool): Shortcut / Duplicate of "guest_mode".
241
+ wire (bool): Shortcut / Duplicate of "use_wire".
242
+ pls (str): Shortcut / Duplicate of "page_load_strategy".
243
+ sjw (bool): Shortcut / Duplicate of "skip_js_waits".
244
+ wfa (bool): Shortcut / Duplicate of "wait_for_angularjs".
245
+ save_screenshot (bool): Save a screenshot at the end of each test.
246
+ no_screenshot (bool): No screenshots saved unless tests directly ask it.
247
+ page_load_strategy (str): Set Chrome PLS to "normal", "eager", or "none".
248
+ timeout_multiplier (float): Multiplies the default timeout values.
249
+ js_checking_on (bool): Check for JavaScript errors after page loads.
250
+ slow (bool): Slow down the automation. Faster than using Demo Mode.
251
+ demo (bool): Slow down and visually see test actions as they occur.
252
+ demo_sleep (float): SECONDS (Set wait time after Slow & Demo Mode actions)
253
+ message_duration (float): SECONDS (The time length for Messenger alerts.)
254
+ highlights (int): Number of highlight animations for Demo Mode actions.
255
+ interval (float): SECONDS (Autoplay interval for SB Slides & Tour steps.)
256
+ time_limit (float): SECONDS (Safely fail tests that exceed the time limit)
257
+ """
258
+ import colorama
122
259
  import os
123
260
  import sys
124
261
  import time
@@ -131,7 +268,6 @@ def SB(
131
268
 
132
269
  sb_config_backup = sb_config
133
270
  sb_config._do_sb_post_mortem = False
134
- is_windows = shared_utils.is_windows()
135
271
  sys_argv = sys.argv
136
272
  arg_join = " ".join(sys_argv)
137
273
  archive_logs = False
@@ -139,12 +275,15 @@ def SB(
139
275
  collect_only = ("--co" in sys_argv or "--collect-only" in sys_argv)
140
276
  all_scripts = (hasattr(sb_config, "all_scripts") and sb_config.all_scripts)
141
277
  do_log_folder_setup = False # The first "test=True" run does it
278
+ inner_test = False
142
279
  if (
143
280
  (hasattr(sb_config, "is_behave") and sb_config.is_behave)
144
281
  or (hasattr(sb_config, "is_pytest") and sb_config.is_pytest)
145
282
  or (hasattr(sb_config, "is_nosetest") and sb_config.is_nosetest)
146
283
  ):
147
284
  existing_runner = True
285
+ if test:
286
+ inner_test = True
148
287
  test = False # Already using a test runner. Skip extra test steps.
149
288
  elif test is None and "--test" in sys_argv:
150
289
  test = True
@@ -275,6 +414,13 @@ def SB(
275
414
  headless = True
276
415
  else:
277
416
  headless = False
417
+ if headless1 is None:
418
+ if "--headless1" in sys_argv:
419
+ headless1 = True
420
+ else:
421
+ headless1 = False
422
+ if headless1:
423
+ headless = True
278
424
  if headless2 is None:
279
425
  if "--headless2" in sys_argv:
280
426
  headless2 = True
@@ -282,6 +428,8 @@ def SB(
282
428
  headless2 = False
283
429
  if protocol is None:
284
430
  protocol = "http" # For the Selenium Grid only!
431
+ if server is not None and servername is None:
432
+ servername = server
285
433
  if servername is None:
286
434
  servername = "localhost" # For the Selenium Grid only!
287
435
  if port is None:
@@ -293,6 +441,8 @@ def SB(
293
441
  incognito = True
294
442
  else:
295
443
  incognito = False
444
+ if guest is not None and guest_mode is None:
445
+ guest_mode = guest
296
446
  if guest_mode is None:
297
447
  if "--guest" in sys_argv:
298
448
  guest_mode = True
@@ -330,28 +480,93 @@ def SB(
330
480
  proxy_string = proxy_string[1:-1]
331
481
  c_a = chromium_arg
332
482
  if c_a is None and "--chromium-arg" in arg_join:
333
- if "--chromium-arg=" in arg_join:
334
- c_a = arg_join.split("--chromium-arg=")[1].split(" ")[0]
335
- elif "--chromium-arg " in arg_join:
336
- c_a = arg_join.split("--chromium-arg ")[1].split(" ")[0]
337
- if c_a:
338
- if c_a.startswith('"') and c_a.endswith('"'):
339
- c_a = c_a[1:-1]
340
- elif c_a.startswith("'") and c_a.endswith("'"):
341
- c_a = c_a[1:-1]
483
+ count = 0
484
+ for arg in sys_argv:
485
+ if arg.startswith("--chromium-arg="):
486
+ c_a = arg.split("--chromium-arg=")[1]
487
+ break
488
+ elif arg == "--chromium-arg" and len(sys_argv) > count + 1:
489
+ c_a = sys_argv[count + 1]
490
+ if c_a.startswith("-"):
491
+ c_a = None
492
+ break
493
+ count += 1
342
494
  chromium_arg = c_a
343
495
  d_f = disable_features
344
496
  if d_f is None and "--disable-features" in arg_join:
345
- if "--disable-features=" in arg_join:
346
- d_f = arg_join.split("--disable-features=")[1].split(" ")[0]
347
- elif "--disable-features " in arg_join:
348
- d_f = arg_join.split("--disable-features ")[1].split(" ")[0]
349
- if d_f:
350
- if d_f.startswith('"') and d_f.endswith('"'):
351
- d_f = d_f[1:-1]
352
- elif c_a.startswith("'") and d_f.endswith("'"):
353
- d_f = d_f[1:-1]
497
+ count = 0
498
+ for arg in sys_argv:
499
+ if arg.startswith("--disable-features="):
500
+ d_f = arg.split("--disable-features=")[1]
501
+ break
502
+ elif arg == "--disable-features" and len(sys_argv) > count + 1:
503
+ d_f = sys_argv[count + 1]
504
+ if d_f.startswith("-"):
505
+ d_f = None
506
+ break
507
+ count += 1
354
508
  disable_features = d_f
509
+ if window_position is None and position is not None:
510
+ window_position = position
511
+ w_p = window_position
512
+ if (
513
+ w_p is None
514
+ and ("--window-position" in arg_join or "--position" in arg_join)
515
+ ):
516
+ count = 0
517
+ for arg in sys_argv:
518
+ if arg.startswith("--window-position="):
519
+ w_p = arg.split("--window-position=")[1]
520
+ break
521
+ elif arg == "--window-position" and len(sys_argv) > count + 1:
522
+ w_p = sys_argv[count + 1]
523
+ if w_p.startswith("-"):
524
+ w_p = None
525
+ break
526
+ count += 1
527
+ window_position = w_p
528
+ if window_size is None and size is not None:
529
+ window_size = size
530
+ w_s = window_size
531
+ if w_s is None and "--window-size" in arg_join:
532
+ count = 0
533
+ for arg in sys_argv:
534
+ if arg.startswith("--window-size="):
535
+ w_s = arg.split("--window-size=")[1]
536
+ break
537
+ elif arg == "--window-size" and len(sys_argv) > count + 1:
538
+ w_s = sys_argv[count + 1]
539
+ if w_s.startswith("-"):
540
+ w_s = None
541
+ break
542
+ count += 1
543
+ window_size = w_s
544
+ x_m = xvfb_metrics
545
+ if x_m is None and "--xvfb-metrics" in arg_join:
546
+ count = 0
547
+ for arg in sys_argv:
548
+ if arg.startswith("--xvfb-metrics="):
549
+ x_m = arg.split("--xvfb-metrics=")[1]
550
+ break
551
+ elif arg == "--xvfb-metrics" and len(sys_argv) > count + 1:
552
+ x_m = sys_argv[count + 1]
553
+ if x_m.startswith("-"):
554
+ x_m = None
555
+ break
556
+ count += 1
557
+ xvfb_metrics = x_m
558
+ if agent is None and "--agent" in arg_join:
559
+ count = 0
560
+ for arg in sys_argv:
561
+ if arg.startswith("--agent="):
562
+ agent = arg.split("--agent=")[1]
563
+ break
564
+ elif arg == "--agent" and len(sys_argv) > count + 1:
565
+ agent = sys_argv[count + 1]
566
+ if agent.startswith("-"):
567
+ agent = None
568
+ break
569
+ count += 1
355
570
  user_agent = agent
356
571
  recorder_mode = False
357
572
  if recorder_ext:
@@ -378,9 +593,79 @@ def SB(
378
593
  record_sleep = True
379
594
  else:
380
595
  record_sleep = False
596
+ if xvfb is None:
597
+ if "--xvfb" in sys_argv:
598
+ xvfb = True
599
+ else:
600
+ xvfb = False
381
601
  if not shared_utils.is_linux():
382
602
  # The Xvfb virtual display server is for Linux OS Only!
383
603
  xvfb = False
604
+ if (
605
+ undetectable
606
+ or undetected
607
+ or uc
608
+ or uc_cdp_events
609
+ or uc_cdp
610
+ or uc_subprocess
611
+ or uc_sub
612
+ ):
613
+ undetectable = True
614
+ if undetectable or undetected or uc:
615
+ uc_subprocess = True # Use UC as a subprocess by default.
616
+ elif (
617
+ "--undetectable" in sys_argv
618
+ or "--undetected" in sys_argv
619
+ or "--uc" in sys_argv
620
+ or "--uc-cdp-events" in sys_argv
621
+ or "--uc_cdp_events" in sys_argv
622
+ or "--uc-cdp" in sys_argv
623
+ or "--uc-subprocess" in sys_argv
624
+ or "--uc_subprocess" in sys_argv
625
+ or "--uc-sub" in sys_argv
626
+ ):
627
+ undetectable = True
628
+ if uc_subprocess is None and uc_sub is None:
629
+ uc_subprocess = True # Use UC as a subprocess by default.
630
+ else:
631
+ undetectable = False
632
+ if uc_subprocess or uc_sub:
633
+ uc_subprocess = True
634
+ elif (
635
+ "--uc-subprocess" in sys_argv
636
+ or "--uc_subprocess" in sys_argv
637
+ or "--uc-sub" in sys_argv
638
+ ):
639
+ uc_subprocess = True
640
+ else:
641
+ uc_subprocess = False
642
+ if uc_cdp_events or uc_cdp:
643
+ undetectable = True
644
+ uc_cdp_events = True
645
+ elif (
646
+ "--uc-cdp-events" in sys_argv
647
+ or "--uc_cdp_events" in sys_argv
648
+ or "--uc-cdp" in sys_argv
649
+ or "--uc_cdp" in sys_argv
650
+ ):
651
+ undetectable = True
652
+ uc_cdp_events = True
653
+ else:
654
+ uc_cdp_events = False
655
+ if undetectable and browser != "chrome":
656
+ message = (
657
+ '\n Undetected-Chromedriver Mode ONLY supports Chrome!'
658
+ '\n ("uc=True" / "undetectable=True" / "--uc")'
659
+ '\n (Your browser choice was: "%s".)'
660
+ '\n (Will use "%s" without UC Mode.)\n' % (browser, browser)
661
+ )
662
+ print(message)
663
+ if headed is None:
664
+ # Override the default headless mode on Linux if set.
665
+ if "--gui" in sys_argv or "--headed" in sys_argv:
666
+ headed = True
667
+ else:
668
+ headed = False
384
669
  if (
385
670
  shared_utils.is_linux()
386
671
  and not headed
@@ -388,7 +673,10 @@ def SB(
388
673
  and not headless2
389
674
  and not xvfb
390
675
  ):
391
- headless = True
676
+ if not undetectable:
677
+ headless = True
678
+ else:
679
+ xvfb = True
392
680
  if headless2 and browser == "firefox":
393
681
  headless2 = False # Only for Chromium browsers
394
682
  headless = True # Firefox has regular headless
@@ -407,6 +695,7 @@ def SB(
407
695
  recorder_ext = True
408
696
  if recorder_mode and headless:
409
697
  headless = False
698
+ headless1 = False
410
699
  headless2 = True
411
700
  sb_config.proxy_driver = False
412
701
  if "--proxy-driver" in sys_argv or "--proxy_driver" in sys_argv:
@@ -434,8 +723,25 @@ def SB(
434
723
  else:
435
724
  variables = {}
436
725
  if disable_csp is None:
437
- disable_csp = False
726
+ if (
727
+ "--disable-csp" in sys_argv
728
+ or "--no-csp" in sys_argv
729
+ or "--dcsp" in sys_argv
730
+ ):
731
+ disable_csp = True
732
+ else:
733
+ disable_csp = False
438
734
  if (
735
+ (enable_ws is None and disable_ws is None)
736
+ and (
737
+ "--disable-web-security" in sys_argv
738
+ or "--disable-ws" in sys_argv
739
+ or "--dws" in sys_argv
740
+ )
741
+ ):
742
+ enable_ws = False
743
+ disable_ws = True
744
+ elif (
439
745
  (enable_ws is None and disable_ws is None)
440
746
  or (disable_ws is not None and not disable_ws)
441
747
  or (enable_ws is not None and enable_ws)
@@ -445,61 +751,6 @@ def SB(
445
751
  else:
446
752
  enable_ws = False
447
753
  disable_ws = True
448
- if (
449
- undetectable
450
- or undetected
451
- or uc
452
- or uc_cdp_events
453
- or uc_cdp
454
- or uc_subprocess
455
- or uc_sub
456
- ):
457
- undetectable = True
458
- if (
459
- (undetectable or undetected or uc)
460
- and (uc_subprocess is None)
461
- and (uc_sub is None)
462
- ):
463
- uc_subprocess = True # Use UC as a subprocess by default.
464
- elif (
465
- "--undetectable" in sys_argv
466
- or "--undetected" in sys_argv
467
- or "--uc" in sys_argv
468
- or "--uc-cdp-events" in sys_argv
469
- or "--uc_cdp_events" in sys_argv
470
- or "--uc-cdp" in sys_argv
471
- or "--uc-subprocess" in sys_argv
472
- or "--uc_subprocess" in sys_argv
473
- or "--uc-sub" in sys_argv
474
- ):
475
- undetectable = True
476
- if uc_subprocess is None and uc_sub is None:
477
- uc_subprocess = True # Use UC as a subprocess by default.
478
- else:
479
- undetectable = False
480
- if uc_subprocess or uc_sub:
481
- uc_subprocess = True
482
- elif (
483
- "--uc-subprocess" in sys_argv
484
- or "--uc_subprocess" in sys_argv
485
- or "--uc-sub" in sys_argv
486
- ):
487
- uc_subprocess = True
488
- else:
489
- uc_subprocess = False
490
- if uc_cdp_events or uc_cdp:
491
- undetectable = True
492
- uc_cdp_events = True
493
- elif (
494
- "--uc-cdp-events" in sys_argv
495
- or "--uc_cdp_events" in sys_argv
496
- or "--uc-cdp" in sys_argv
497
- or "--uc_cdp" in sys_argv
498
- ):
499
- undetectable = True
500
- uc_cdp_events = True
501
- else:
502
- uc_cdp_events = False
503
754
  if log_cdp_events is None and log_cdp is None:
504
755
  if (
505
756
  "--log-cdp-events" in sys_argv
@@ -519,6 +770,11 @@ def SB(
519
770
  use_auto_ext = True
520
771
  else:
521
772
  use_auto_ext = False
773
+ if disable_cookies is None:
774
+ if "--disable-cookies" in sys_argv:
775
+ disable_cookies = True
776
+ else:
777
+ disable_cookies = False
522
778
  if disable_js is None:
523
779
  if "--disable-js" in sys_argv:
524
780
  disable_js = True
@@ -532,6 +788,13 @@ def SB(
532
788
  _disable_beforeunload = True
533
789
  if pls is not None and page_load_strategy is None:
534
790
  page_load_strategy = pls
791
+ if not page_load_strategy and "--pls=" in arg_join:
792
+ if "--pls=none" in sys_argv or '--pls="none"' in sys_argv:
793
+ page_load_strategy = "none"
794
+ elif "--pls=eager" in sys_argv or '--pls="eager"' in sys_argv:
795
+ page_load_strategy = "eager"
796
+ elif "--pls=normal" in sys_argv or '--pls="normal"' in sys_argv:
797
+ page_load_strategy = "normal"
535
798
  if page_load_strategy is not None:
536
799
  if page_load_strategy.lower() not in ["normal", "eager", "none"]:
537
800
  raise Exception(
@@ -555,6 +818,17 @@ def SB(
555
818
  settings.SKIP_JS_WAITS = True
556
819
  elif skip_js_waits:
557
820
  settings.SKIP_JS_WAITS = skip_js_waits
821
+ if wfa is not None and wait_for_angularjs is None:
822
+ wait_for_angularjs = wfa
823
+ if wait_for_angularjs is None:
824
+ if (
825
+ "--wfa" in sys_argv
826
+ or "--wait_for_angularjs" in sys_argv
827
+ or "--wait-for-angularjs" in sys_argv
828
+ ):
829
+ settings.WAIT_FOR_ANGULARJS = True
830
+ elif wait_for_angularjs:
831
+ settings.WAIT_FOR_ANGULARJS = wait_for_angularjs
558
832
  if save_screenshot is None:
559
833
  if (
560
834
  "--screenshot" in sys_argv
@@ -573,6 +847,7 @@ def SB(
573
847
  save_screenshot = False # "no_screenshot" has priority
574
848
  if browser == "safari" and headless:
575
849
  headless = False # Safari doesn't support headless mode
850
+ headless1 = False
576
851
  if js_checking_on is None:
577
852
  if "--check-js" in sys_argv:
578
853
  js_checking_on = True
@@ -627,6 +902,10 @@ def SB(
627
902
  swiftshader = True
628
903
  else:
629
904
  swiftshader = False
905
+ if locale is not None and locale_code is None:
906
+ locale_code = locale
907
+ if ad_block is not None and ad_block_on is None:
908
+ ad_block_on = ad_block
630
909
  if ad_block_on is None:
631
910
  if "--ad-block" in sys_argv or "--ad_block" in sys_argv:
632
911
  ad_block_on = True
@@ -641,15 +920,30 @@ def SB(
641
920
  host_resolver_rules = (
642
921
  arg_join.split("--host_resolver_rules=")[1].split('"')[0]
643
922
  )
644
- if driver_version is None:
645
- if "--driver-version=" in arg_join:
646
- driver_version = (
647
- arg_join.split("--driver-version=")[1].split(" ")[0]
648
- )
649
- elif "--driver_version=" in arg_join:
650
- driver_version = (
651
- arg_join.split("--driver_version=")[1].split(" ")[0]
652
- )
923
+ if driver_version is None and "--driver-version" in arg_join:
924
+ count = 0
925
+ for arg in sys_argv:
926
+ if arg.startswith("--driver-version="):
927
+ driver_version = arg.split("--driver-version=")[1]
928
+ break
929
+ elif arg == "--driver-version" and len(sys_argv) > count + 1:
930
+ driver_version = sys_argv[count + 1]
931
+ if driver_version.startswith("-"):
932
+ driver_version = None
933
+ break
934
+ count += 1
935
+ if driver_version is None and "--driver_version" in arg_join:
936
+ count = 0
937
+ for arg in sys_argv:
938
+ if arg.startswith("--driver_version="):
939
+ driver_version = arg.split("--driver_version=")[1]
940
+ break
941
+ elif arg == "--driver_version" and len(sys_argv) > count + 1:
942
+ driver_version = sys_argv[count + 1]
943
+ if driver_version.startswith("-"):
944
+ driver_version = None
945
+ break
946
+ count += 1
653
947
  if highlights is not None:
654
948
  try:
655
949
  highlights = int(highlights)
@@ -676,9 +970,11 @@ def SB(
676
970
  sb_config.is_nosetest = False
677
971
  sb_config.is_context_manager = True
678
972
  sb_config.headless = headless
973
+ sb_config.headless1 = headless1
679
974
  sb_config.headless2 = headless2
680
975
  sb_config.headed = headed
681
976
  sb_config.xvfb = xvfb
977
+ sb_config.xvfb_metrics = xvfb_metrics
682
978
  sb_config.start_page = start_page
683
979
  sb_config.locale_code = locale_code
684
980
  sb_config.protocol = protocol
@@ -715,13 +1011,15 @@ def SB(
715
1011
  sb_config.log_cdp_events = log_cdp_events
716
1012
  sb_config.no_sandbox = None
717
1013
  sb_config.disable_gpu = None
1014
+ sb_config.disable_cookies = disable_cookies
718
1015
  sb_config.disable_js = disable_js
719
1016
  sb_config._multithreaded = False
720
1017
  sb_config.reuse_session = False
721
1018
  sb_config.crumbs = False
722
1019
  sb_config.final_debug = False
723
1020
  sb_config.visual_baseline = False
724
- sb_config.window_size = None
1021
+ sb_config.window_position = window_position
1022
+ sb_config.window_size = window_size
725
1023
  sb_config.maximize_option = maximize_option
726
1024
  sb_config._disable_beforeunload = _disable_beforeunload
727
1025
  sb_config.save_screenshot = save_screenshot
@@ -779,9 +1077,11 @@ def SB(
779
1077
  sb.is_nosetest = False
780
1078
  sb.is_context_manager = sb_config.is_context_manager
781
1079
  sb.headless = sb_config.headless
1080
+ sb.headless1 = sb_config.headless1
782
1081
  sb.headless2 = sb_config.headless2
783
1082
  sb.headed = sb_config.headed
784
1083
  sb.xvfb = sb_config.xvfb
1084
+ sb.xvfb_metrics = sb_config.xvfb_metrics
785
1085
  sb.start_page = sb_config.start_page
786
1086
  sb.locale_code = sb_config.locale_code
787
1087
  sb.protocol = sb_config.protocol
@@ -820,12 +1120,14 @@ def SB(
820
1120
  sb.log_cdp_events = sb_config.log_cdp_events
821
1121
  sb.no_sandbox = sb_config.no_sandbox
822
1122
  sb.disable_gpu = sb_config.disable_gpu
1123
+ sb.disable_cookies = sb_config.disable_cookies
823
1124
  sb.disable_js = sb_config.disable_js
824
1125
  sb._multithreaded = sb_config._multithreaded
825
1126
  sb._reuse_session = sb_config.reuse_session
826
1127
  sb._crumbs = sb_config.crumbs
827
1128
  sb._final_debug = sb_config.final_debug
828
1129
  sb.visual_baseline = sb_config.visual_baseline
1130
+ sb.window_position = sb_config.window_position
829
1131
  sb.window_size = sb_config.window_size
830
1132
  sb.maximize_option = sb_config.maximize_option
831
1133
  sb._disable_beforeunload = sb_config._disable_beforeunload
@@ -881,11 +1183,6 @@ def SB(
881
1183
  test_name = None
882
1184
  terminal_width = shared_utils.get_terminal_width()
883
1185
  if test:
884
- import colorama
885
- if is_windows and hasattr(colorama, "just_fix_windows_console"):
886
- colorama.just_fix_windows_console()
887
- else:
888
- colorama.init(autoreset=True)
889
1186
  c1 = colorama.Fore.GREEN
890
1187
  b1 = colorama.Style.BRIGHT
891
1188
  cr = colorama.Style.RESET_ALL
@@ -908,7 +1205,7 @@ def SB(
908
1205
  from seleniumbase.core import download_helper
909
1206
  from seleniumbase.core import proxy_helper
910
1207
 
911
- log_helper.log_folder_setup(constants.Logs.LATEST + "/")
1208
+ log_helper.log_folder_setup(constants.Logs.LATEST + os.sep)
912
1209
  log_helper.clear_empty_logs()
913
1210
  download_helper.reset_downloads_folder()
914
1211
  if not sb_config.multi_proxy:
@@ -928,13 +1225,16 @@ def SB(
928
1225
  sb._has_failure = True
929
1226
  exception = e
930
1227
  test_passed = False
931
- if not test_name:
1228
+ if (test or inner_test) and not test_name:
1229
+ print(e)
1230
+ return
1231
+ elif not test_name:
932
1232
  raise
933
1233
  else:
934
1234
  the_traceback = traceback.format_exc().strip()
935
1235
  try:
936
1236
  p2 = the_traceback.split(', in ')[1].split('", line ')[0]
937
- filename = p2.split("/")[-1]
1237
+ filename = p2.split(os.sep)[-1]
938
1238
  sb.cm_filename = filename
939
1239
  except Exception:
940
1240
  sb.cm_filename = None
@@ -956,6 +1256,19 @@ def SB(
956
1256
  print(traceback.format_exc().strip())
957
1257
  if test and not test_passed:
958
1258
  print("********** ERROR: The test AND the tearDown() FAILED!")
1259
+ if (
1260
+ hasattr(sb_config, "_virtual_display")
1261
+ and sb_config._virtual_display
1262
+ and hasattr(sb_config._virtual_display, "stop")
1263
+ ):
1264
+ try:
1265
+ sb_config._virtual_display.stop()
1266
+ sb_config._virtual_display = None
1267
+ sb_config.headless_active = False
1268
+ except AttributeError:
1269
+ pass
1270
+ except Exception:
1271
+ pass
959
1272
  end_time = time.time()
960
1273
  run_time = end_time - start_time
961
1274
  sb_config = sb_config_backup