seleniumbase 4.24.11__py3-none-any.whl → 4.33.15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sbase/__init__.py +1 -0
- sbase/steps.py +7 -0
- seleniumbase/__init__.py +16 -7
- seleniumbase/__version__.py +1 -1
- seleniumbase/behave/behave_sb.py +97 -32
- seleniumbase/common/decorators.py +16 -7
- seleniumbase/config/proxy_list.py +3 -3
- seleniumbase/config/settings.py +4 -0
- seleniumbase/console_scripts/logo_helper.py +47 -8
- seleniumbase/console_scripts/run.py +345 -335
- seleniumbase/console_scripts/sb_behave_gui.py +5 -12
- seleniumbase/console_scripts/sb_caseplans.py +6 -13
- seleniumbase/console_scripts/sb_commander.py +5 -12
- seleniumbase/console_scripts/sb_install.py +62 -54
- seleniumbase/console_scripts/sb_mkchart.py +13 -20
- seleniumbase/console_scripts/sb_mkdir.py +11 -17
- seleniumbase/console_scripts/sb_mkfile.py +69 -43
- seleniumbase/console_scripts/sb_mkpres.py +13 -20
- seleniumbase/console_scripts/sb_mkrec.py +88 -21
- seleniumbase/console_scripts/sb_objectify.py +30 -30
- seleniumbase/console_scripts/sb_print.py +5 -12
- seleniumbase/console_scripts/sb_recorder.py +16 -11
- seleniumbase/core/browser_launcher.py +1658 -221
- seleniumbase/core/log_helper.py +42 -27
- seleniumbase/core/mysql.py +1 -4
- seleniumbase/core/proxy_helper.py +35 -30
- seleniumbase/core/recorder_helper.py +24 -5
- seleniumbase/core/sb_cdp.py +1951 -0
- seleniumbase/core/sb_driver.py +162 -8
- seleniumbase/core/settings_parser.py +6 -0
- seleniumbase/core/style_sheet.py +10 -0
- seleniumbase/extensions/recorder.zip +0 -0
- seleniumbase/fixtures/base_case.py +1225 -614
- seleniumbase/fixtures/constants.py +10 -1
- seleniumbase/fixtures/js_utils.py +171 -144
- seleniumbase/fixtures/page_actions.py +177 -13
- seleniumbase/fixtures/page_utils.py +25 -53
- seleniumbase/fixtures/shared_utils.py +97 -11
- seleniumbase/js_code/active_css_js.py +1 -1
- seleniumbase/js_code/recorder_js.py +1 -1
- seleniumbase/plugins/base_plugin.py +2 -3
- seleniumbase/plugins/driver_manager.py +340 -65
- seleniumbase/plugins/pytest_plugin.py +276 -47
- seleniumbase/plugins/sb_manager.py +412 -99
- seleniumbase/plugins/selenium_plugin.py +122 -17
- seleniumbase/translate/translator.py +0 -7
- seleniumbase/undetected/__init__.py +59 -52
- seleniumbase/undetected/cdp.py +0 -1
- seleniumbase/undetected/cdp_driver/__init__.py +1 -0
- seleniumbase/undetected/cdp_driver/_contradict.py +110 -0
- seleniumbase/undetected/cdp_driver/browser.py +829 -0
- seleniumbase/undetected/cdp_driver/cdp_util.py +458 -0
- seleniumbase/undetected/cdp_driver/config.py +334 -0
- seleniumbase/undetected/cdp_driver/connection.py +639 -0
- seleniumbase/undetected/cdp_driver/element.py +1168 -0
- seleniumbase/undetected/cdp_driver/tab.py +1323 -0
- seleniumbase/undetected/dprocess.py +4 -7
- seleniumbase/undetected/options.py +6 -8
- seleniumbase/undetected/patcher.py +11 -13
- seleniumbase/undetected/reactor.py +0 -1
- seleniumbase/undetected/webelement.py +16 -3
- {seleniumbase-4.24.11.dist-info → seleniumbase-4.33.15.dist-info}/LICENSE +1 -1
- {seleniumbase-4.24.11.dist-info → seleniumbase-4.33.15.dist-info}/METADATA +299 -252
- {seleniumbase-4.24.11.dist-info → seleniumbase-4.33.15.dist-info}/RECORD +67 -69
- {seleniumbase-4.24.11.dist-info → seleniumbase-4.33.15.dist-info}/WHEEL +1 -1
- sbase/ReadMe.txt +0 -2
- seleniumbase/ReadMe.md +0 -25
- seleniumbase/common/ReadMe.md +0 -71
- seleniumbase/console_scripts/ReadMe.md +0 -731
- seleniumbase/drivers/ReadMe.md +0 -27
- seleniumbase/extensions/ReadMe.md +0 -12
- seleniumbase/masterqa/ReadMe.md +0 -61
- seleniumbase/resources/ReadMe.md +0 -31
- seleniumbase/resources/favicon.ico +0 -0
- seleniumbase/utilities/selenium_grid/ReadMe.md +0 -84
- seleniumbase/utilities/selenium_ide/ReadMe.md +0 -111
- {seleniumbase-4.24.11.dist-info → seleniumbase-4.33.15.dist-info}/entry_points.txt +0 -0
- {seleniumbase-4.24.11.dist-info → seleniumbase-4.33.15.dist-info}/top_level.txt +0 -0
@@ -7,7 +7,7 @@ Usage --> ``with DriverContext() as driver:``
|
|
7
7
|
|
8
8
|
Example -->
|
9
9
|
|
10
|
-
```
|
10
|
+
```python
|
11
11
|
from seleniumbase import DriverContext
|
12
12
|
|
13
13
|
with DriverContext() as driver:
|
@@ -27,7 +27,7 @@ Usage --> ``driver = Driver()``
|
|
27
27
|
|
28
28
|
Example -->
|
29
29
|
|
30
|
-
```
|
30
|
+
```python
|
31
31
|
from seleniumbase import Driver
|
32
32
|
|
33
33
|
driver = Driver()
|
@@ -36,6 +36,7 @@ driver.get("https://google.com/ncr")
|
|
36
36
|
|
37
37
|
###########################################################################
|
38
38
|
"""
|
39
|
+
import os
|
39
40
|
import sys
|
40
41
|
|
41
42
|
|
@@ -64,8 +65,9 @@ class DriverContext():
|
|
64
65
|
|
65
66
|
def Driver(
|
66
67
|
browser=None, # Choose from "chrome", "edge", "firefox", or "safari".
|
67
|
-
headless=None, #
|
68
|
-
|
68
|
+
headless=None, # Use the default headless mode for Chromium and Firefox.
|
69
|
+
headless1=None, # Use Chromium's old headless mode. (Fast, but limited)
|
70
|
+
headless2=None, # Use Chromium's new headless mode. (Has more features)
|
69
71
|
headed=None, # Run tests in headed/GUI mode on Linux, where not default.
|
70
72
|
locale_code=None, # Set the Language Locale Code for the web browser.
|
71
73
|
protocol=None, # The Selenium Grid protocol: "http" or "https".
|
@@ -74,12 +76,13 @@ def Driver(
|
|
74
76
|
proxy=None, # Use proxy. Format: "SERVER:PORT" or "USER:PASS@SERVER:PORT".
|
75
77
|
proxy_bypass_list=None, # Skip proxy when using the listed domains.
|
76
78
|
proxy_pac_url=None, # Use PAC file. (Format: URL or USERNAME:PASSWORD@URL)
|
77
|
-
multi_proxy=
|
79
|
+
multi_proxy=None, # Allow multiple proxies with auth when multi-threaded.
|
78
80
|
agent=None, # Modify the web browser's User-Agent string.
|
79
81
|
cap_file=None, # The desired capabilities to use with a Selenium Grid.
|
80
82
|
cap_string=None, # The desired capabilities to use with a Selenium Grid.
|
81
83
|
recorder_ext=None, # Enables the SeleniumBase Recorder Chromium extension.
|
82
|
-
|
84
|
+
disable_cookies=None, # Disable Cookies on websites. (Pages might break!)
|
85
|
+
disable_js=None, # Disable JavaScript on websites. (Pages might break!)
|
83
86
|
disable_csp=None, # Disable the Content Security Policy of websites.
|
84
87
|
enable_ws=None, # Enable Web Security on Chromium-based browsers.
|
85
88
|
disable_ws=None, # Reverse of "enable_ws". (None and False are different)
|
@@ -114,20 +117,125 @@ def Driver(
|
|
114
117
|
page_load_strategy=None, # Set Chrome PLS to "normal", "eager", or "none".
|
115
118
|
use_wire=None, # Use selenium-wire's webdriver over selenium webdriver.
|
116
119
|
external_pdf=None, # Set Chrome "plugins.always_open_pdf_externally":True.
|
120
|
+
window_position=None, # Set the browser's starting window position: "X,Y"
|
121
|
+
window_size=None, # Set the browser's starting window size: "Width,Height"
|
117
122
|
is_mobile=None, # Use the mobile device emulator while running tests.
|
118
123
|
mobile=None, # Shortcut / Duplicate of "is_mobile".
|
119
124
|
d_width=None, # Set device width
|
120
125
|
d_height=None, # Set device height
|
121
126
|
d_p_r=None, # Set device pixel ratio
|
127
|
+
position=None, # Shortcut / Duplicate of "window_position".
|
128
|
+
size=None, # Shortcut / Duplicate of "window_size".
|
122
129
|
uc=None, # Shortcut / Duplicate of "undetectable".
|
123
130
|
undetected=None, # Shortcut / Duplicate of "undetectable".
|
124
131
|
uc_cdp=None, # Shortcut / Duplicate of "uc_cdp_events".
|
125
132
|
uc_sub=None, # Shortcut / Duplicate of "uc_subprocess".
|
133
|
+
locale=None, # Shortcut / Duplicate of "locale_code".
|
126
134
|
log_cdp=None, # Shortcut / Duplicate of "log_cdp_events".
|
135
|
+
ad_block=None, # Shortcut / Duplicate of "ad_block_on".
|
136
|
+
server=None, # Shortcut / Duplicate of "servername".
|
137
|
+
guest=None, # Shortcut / Duplicate of "guest_mode".
|
127
138
|
wire=None, # Shortcut / Duplicate of "use_wire".
|
128
139
|
pls=None, # Shortcut / Duplicate of "page_load_strategy".
|
129
140
|
):
|
141
|
+
"""
|
142
|
+
* SeleniumBase Driver as a Python Context Manager or a returnable object. *
|
143
|
+
|
144
|
+
Example 1: (context manager format)
|
145
|
+
-----------------------------------
|
146
|
+
.. code-block:: python
|
147
|
+
from seleniumbase import DriverContext
|
148
|
+
|
149
|
+
with DriverContext() as driver:
|
150
|
+
driver.get("https://google.com/ncr")
|
151
|
+
|
152
|
+
Example 2: (as a Python returnable)
|
153
|
+
-----------------------------------
|
154
|
+
.. code-block:: python
|
155
|
+
from seleniumbase import Driver
|
156
|
+
|
157
|
+
driver = Driver()
|
158
|
+
driver.get("https://google.com/ncr")
|
159
|
+
|
160
|
+
Optional Parameters:
|
161
|
+
--------------------
|
162
|
+
browser (str): Choose from "chrome", "edge", "firefox", or "safari".
|
163
|
+
headless (bool): Use the default headless mode for Chromium and Firefox.
|
164
|
+
headless1 (bool): Use Chromium's old headless mode. (Fast, but limited)
|
165
|
+
headless2 (bool): Use Chromium's new headless mode. (Has more features)
|
166
|
+
headed (bool): Run tests in headed/GUI mode on Linux, where not default.
|
167
|
+
locale_code (str): Set the Language Locale Code for the web browser.
|
168
|
+
protocol (str): The Selenium Grid protocol: "http" or "https".
|
169
|
+
servername (str): The Selenium Grid server/IP used for tests.
|
170
|
+
port (int): The Selenium Grid port used by the test server.
|
171
|
+
proxy (str): Use proxy. Format: "SERVER:PORT" or "USER:PASS@SERVER:PORT".
|
172
|
+
proxy_bypass_list (str): Skip proxy when using the listed domains.
|
173
|
+
proxy_pac_url (str): Use PAC file. (Format: URL or USERNAME:PASSWORD@URL)
|
174
|
+
multi_proxy (bool): Allow multiple proxies with auth when multi-threaded.
|
175
|
+
agent (str): Modify the web browser's User-Agent string.
|
176
|
+
cap_file (str): The desired capabilities to use with a Selenium Grid.
|
177
|
+
cap_string (str): The desired capabilities to use with a Selenium Grid.
|
178
|
+
recorder_ext (bool): Enables the SeleniumBase Recorder Chromium extension.
|
179
|
+
disable_cookies (bool): Disable Cookies on websites. (Pages might break!)
|
180
|
+
disable_js (bool): Disable JavaScript on websites. (Pages might break!)
|
181
|
+
disable_csp (bool): Disable the Content Security Policy of websites.
|
182
|
+
enable_ws (bool): Enable Web Security on Chromium-based browsers.
|
183
|
+
disable_ws (bool): Reverse of "enable_ws". (None and False are different)
|
184
|
+
enable_sync (bool): Enable "Chrome Sync" on websites.
|
185
|
+
use_auto_ext (bool): Use Chrome's automation extension.
|
186
|
+
undetectable (bool): Use undetected-chromedriver to evade bot-detection.
|
187
|
+
uc_cdp_events (bool): Capture CDP events in undetected-chromedriver mode.
|
188
|
+
uc_subprocess (bool): Use undetected-chromedriver as a subprocess.
|
189
|
+
log_cdp_events (bool): Capture {"performance": "ALL", "browser": "ALL"}
|
190
|
+
no_sandbox (bool): (DEPRECATED) - "--no-sandbox" is always used now.
|
191
|
+
disable_gpu (bool): (DEPRECATED) - GPU is disabled if not "swiftshader".
|
192
|
+
incognito (bool): Enable Chromium's Incognito mode.
|
193
|
+
guest_mode (bool): Enable Chromium's Guest mode.
|
194
|
+
dark_mode (bool): Enable Chromium's Dark mode.
|
195
|
+
devtools (bool): Open Chromium's DevTools when the browser opens.
|
196
|
+
remote_debug (bool): Enable Chrome's Debugger on "http://localhost:9222".
|
197
|
+
enable_3d_apis (bool): Enable WebGL and 3D APIs.
|
198
|
+
swiftshader (bool): Chrome: --use-gl=angle / --use-angle=swiftshader-webgl
|
199
|
+
ad_block_on (bool): Block some types of display ads from loading.
|
200
|
+
host_resolver_rules (str): Set host-resolver-rules, comma-separated.
|
201
|
+
block_images (bool): Block images from loading during tests.
|
202
|
+
do_not_track (bool): Tell websites that you don't want to be tracked.
|
203
|
+
chromium_arg (str): "ARG=N,ARG2" (Set Chromium args, ","-separated.)
|
204
|
+
firefox_arg (str): "ARG=N,ARG2" (Set Firefox args, comma-separated.)
|
205
|
+
firefox_pref (str): SET (Set Firefox PREFERENCE:VALUE set, ","-separated)
|
206
|
+
user_data_dir (str): Set the Chrome user data directory to use.
|
207
|
+
extension_zip (str): Load a Chrome Extension .zip|.crx, comma-separated.
|
208
|
+
extension_dir (str): Load a Chrome Extension directory, comma-separated.
|
209
|
+
disable_features (str): "F1,F2" (Disable Chrome features, ","-separated.)
|
210
|
+
binary_location (str): Set path of the Chromium browser binary to use.
|
211
|
+
driver_version (str): Set the chromedriver or uc_driver version to use.
|
212
|
+
page_load_strategy (str): Set Chrome PLS to "normal", "eager", or "none".
|
213
|
+
use_wire (bool): Use selenium-wire's webdriver over selenium webdriver.
|
214
|
+
external_pdf (bool): Set Chrome "plugins.always_open_pdf_externally":True
|
215
|
+
window_position (x,y): Set the browser's starting window position: "X,Y"
|
216
|
+
window_size (w,h): Set the browser's starting window size: "Width,Height"
|
217
|
+
is_mobile (bool): Use the mobile device emulator while running tests.
|
218
|
+
mobile (bool): Shortcut / Duplicate of "is_mobile".
|
219
|
+
d_width (int): Set device width
|
220
|
+
d_height (int): Set device height
|
221
|
+
d_p_r (float): Set device pixel ratio
|
222
|
+
position (x,y): Shortcut / Duplicate of "window_position".
|
223
|
+
size (w,h): Shortcut / Duplicate of "window_size".
|
224
|
+
uc (bool): Shortcut / Duplicate of "undetectable".
|
225
|
+
undetected (bool): Shortcut / Duplicate of "undetectable".
|
226
|
+
uc_cdp (bool): Shortcut / Duplicate of "uc_cdp_events".
|
227
|
+
uc_sub (bool): Shortcut / Duplicate of "uc_subprocess".
|
228
|
+
locale (str): Shortcut / Duplicate of "locale_code".
|
229
|
+
log_cdp (bool): Shortcut / Duplicate of "log_cdp_events".
|
230
|
+
ad_block (bool): Shortcut / Duplicate of "ad_block_on".
|
231
|
+
server (str): Shortcut / Duplicate of "servername".
|
232
|
+
guest (bool): Shortcut / Duplicate of "guest_mode".
|
233
|
+
wire (bool): Shortcut / Duplicate of "use_wire".
|
234
|
+
pls (str): Shortcut / Duplicate of "page_load_strategy".
|
235
|
+
"""
|
130
236
|
from seleniumbase import config as sb_config
|
237
|
+
from seleniumbase.config import settings
|
238
|
+
from seleniumbase.core import browser_launcher
|
131
239
|
from seleniumbase.fixtures import constants
|
132
240
|
from seleniumbase.fixtures import shared_utils
|
133
241
|
|
@@ -239,6 +347,13 @@ def Driver(
|
|
239
347
|
headless = True
|
240
348
|
else:
|
241
349
|
headless = False
|
350
|
+
if headless1 is None:
|
351
|
+
if "--headless1" in sys_argv:
|
352
|
+
headless1 = True
|
353
|
+
else:
|
354
|
+
headless1 = False
|
355
|
+
if headless1:
|
356
|
+
headless = True
|
242
357
|
if headless2 is None:
|
243
358
|
if "--headless2" in sys_argv:
|
244
359
|
headless2 = True
|
@@ -246,6 +361,8 @@ def Driver(
|
|
246
361
|
headless2 = False
|
247
362
|
if protocol is None:
|
248
363
|
protocol = "http" # For the Selenium Grid only!
|
364
|
+
if server is not None and servername is None:
|
365
|
+
servername = server
|
249
366
|
if servername is None:
|
250
367
|
servername = "localhost" # For the Selenium Grid only!
|
251
368
|
use_grid = False
|
@@ -259,6 +376,8 @@ def Driver(
|
|
259
376
|
incognito = True
|
260
377
|
else:
|
261
378
|
incognito = False
|
379
|
+
if guest is not None and guest_mode is None:
|
380
|
+
guest_mode = guest
|
262
381
|
if guest_mode is None:
|
263
382
|
if "--guest" in sys_argv:
|
264
383
|
guest_mode = True
|
@@ -295,28 +414,121 @@ def Driver(
|
|
295
414
|
proxy_string = proxy_string[1:-1]
|
296
415
|
c_a = chromium_arg
|
297
416
|
if c_a is None and "--chromium-arg" in arg_join:
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
c_a =
|
305
|
-
|
306
|
-
|
417
|
+
count = 0
|
418
|
+
for arg in sys_argv:
|
419
|
+
if arg.startswith("--chromium-arg="):
|
420
|
+
c_a = arg.split("--chromium-arg=")[1]
|
421
|
+
break
|
422
|
+
elif arg == "--chromium-arg" and len(sys_argv) > count + 1:
|
423
|
+
c_a = sys_argv[count + 1]
|
424
|
+
if c_a.startswith("-"):
|
425
|
+
c_a = None
|
426
|
+
break
|
427
|
+
count += 1
|
307
428
|
chromium_arg = c_a
|
308
429
|
d_f = disable_features
|
309
430
|
if d_f is None and "--disable-features" in arg_join:
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
d_f =
|
317
|
-
|
318
|
-
|
431
|
+
count = 0
|
432
|
+
for arg in sys_argv:
|
433
|
+
if arg.startswith("--disable-features="):
|
434
|
+
d_f = arg.split("--disable-features=")[1]
|
435
|
+
break
|
436
|
+
elif arg == "--disable-features" and len(sys_argv) > count + 1:
|
437
|
+
d_f = sys_argv[count + 1]
|
438
|
+
if d_f.startswith("-"):
|
439
|
+
d_f = None
|
440
|
+
break
|
441
|
+
count += 1
|
319
442
|
disable_features = d_f
|
443
|
+
if window_position is None and position is not None:
|
444
|
+
window_position = position
|
445
|
+
w_p = window_position
|
446
|
+
if w_p is None and "--window-position" in arg_join:
|
447
|
+
count = 0
|
448
|
+
for arg in sys_argv:
|
449
|
+
if arg.startswith("--window-position="):
|
450
|
+
w_p = arg.split("--window-position=")[1]
|
451
|
+
break
|
452
|
+
elif arg == "--window-position" and len(sys_argv) > count + 1:
|
453
|
+
w_p = sys_argv[count + 1]
|
454
|
+
if w_p.startswith("-"):
|
455
|
+
w_p = None
|
456
|
+
break
|
457
|
+
count += 1
|
458
|
+
window_position = w_p
|
459
|
+
if window_position:
|
460
|
+
if window_position.count(",") != 1:
|
461
|
+
message = (
|
462
|
+
'\n\n window_position expects an "x,y" string!'
|
463
|
+
'\n (Your input was: "%s")\n' % window_position
|
464
|
+
)
|
465
|
+
raise Exception(message)
|
466
|
+
window_position = window_position.replace(" ", "")
|
467
|
+
win_x = None
|
468
|
+
win_y = None
|
469
|
+
try:
|
470
|
+
win_x = int(window_position.split(",")[0])
|
471
|
+
win_y = int(window_position.split(",")[1])
|
472
|
+
except Exception:
|
473
|
+
message = (
|
474
|
+
'\n\n Expecting integer values for "x,y"!'
|
475
|
+
'\n (window_position input was: "%s")\n'
|
476
|
+
% window_position
|
477
|
+
)
|
478
|
+
raise Exception(message)
|
479
|
+
settings.WINDOW_START_X = win_x
|
480
|
+
settings.WINDOW_START_Y = win_y
|
481
|
+
if window_size is None and size is not None:
|
482
|
+
window_size = size
|
483
|
+
w_s = window_size
|
484
|
+
if w_s is None and "--window-size" in arg_join:
|
485
|
+
count = 0
|
486
|
+
for arg in sys_argv:
|
487
|
+
if arg.startswith("--window-size="):
|
488
|
+
w_s = arg.split("--window-size=")[1]
|
489
|
+
break
|
490
|
+
elif arg == "--window-size" and len(sys_argv) > count + 1:
|
491
|
+
w_s = sys_argv[count + 1]
|
492
|
+
if w_s.startswith("-"):
|
493
|
+
w_s = None
|
494
|
+
break
|
495
|
+
count += 1
|
496
|
+
window_size = w_s
|
497
|
+
if window_size:
|
498
|
+
if window_size.count(",") != 1:
|
499
|
+
message = (
|
500
|
+
'\n\n window_size expects a "width,height" string!'
|
501
|
+
'\n (Your input was: "%s")\n' % window_size
|
502
|
+
)
|
503
|
+
raise Exception(message)
|
504
|
+
window_size = window_size.replace(" ", "")
|
505
|
+
width = None
|
506
|
+
height = None
|
507
|
+
try:
|
508
|
+
width = int(window_size.split(",")[0])
|
509
|
+
height = int(window_size.split(",")[1])
|
510
|
+
except Exception:
|
511
|
+
message = (
|
512
|
+
'\n\n Expecting integer values for "width,height"!'
|
513
|
+
'\n (window_size input was: "%s")\n' % window_size
|
514
|
+
)
|
515
|
+
raise Exception(message)
|
516
|
+
settings.CHROME_START_WIDTH = width
|
517
|
+
settings.CHROME_START_HEIGHT = height
|
518
|
+
settings.HEADLESS_START_WIDTH = width
|
519
|
+
settings.HEADLESS_START_HEIGHT = height
|
520
|
+
if agent is None and "--agent" in arg_join:
|
521
|
+
count = 0
|
522
|
+
for arg in sys_argv:
|
523
|
+
if arg.startswith("--agent="):
|
524
|
+
agent = arg.split("--agent=")[1]
|
525
|
+
break
|
526
|
+
elif arg == "--agent" and len(sys_argv) > count + 1:
|
527
|
+
agent = sys_argv[count + 1]
|
528
|
+
if agent.startswith("-"):
|
529
|
+
agent = None
|
530
|
+
break
|
531
|
+
count += 1
|
320
532
|
user_agent = agent
|
321
533
|
recorder_mode = False
|
322
534
|
if recorder_ext:
|
@@ -328,31 +540,6 @@ def Driver(
|
|
328
540
|
):
|
329
541
|
recorder_mode = True
|
330
542
|
recorder_ext = True
|
331
|
-
if (
|
332
|
-
shared_utils.is_linux()
|
333
|
-
and not headed
|
334
|
-
and not headless
|
335
|
-
and not headless2
|
336
|
-
):
|
337
|
-
headless = True
|
338
|
-
if recorder_mode and headless:
|
339
|
-
headless = False
|
340
|
-
headless2 = True
|
341
|
-
if headless2 and browser == "firefox":
|
342
|
-
headless2 = False # Only for Chromium browsers
|
343
|
-
headless = True # Firefox has regular headless
|
344
|
-
elif browser not in ["chrome", "edge"]:
|
345
|
-
headless2 = False # Only for Chromium browsers
|
346
|
-
if disable_csp is None:
|
347
|
-
disable_csp = False
|
348
|
-
if (
|
349
|
-
(enable_ws is None and disable_ws is None)
|
350
|
-
or (disable_ws is not None and not disable_ws)
|
351
|
-
or (enable_ws is not None and enable_ws)
|
352
|
-
):
|
353
|
-
enable_ws = True
|
354
|
-
else:
|
355
|
-
enable_ws = False
|
356
543
|
if (
|
357
544
|
undetectable
|
358
545
|
or undetected
|
@@ -363,11 +550,7 @@ def Driver(
|
|
363
550
|
or uc_sub
|
364
551
|
):
|
365
552
|
undetectable = True
|
366
|
-
if
|
367
|
-
(undetectable or undetected or uc)
|
368
|
-
and (uc_subprocess is None)
|
369
|
-
and (uc_sub is None)
|
370
|
-
):
|
553
|
+
if undetectable or undetected or uc:
|
371
554
|
uc_subprocess = True # Use UC as a subprocess by default.
|
372
555
|
elif (
|
373
556
|
"--undetectable" in sys_argv
|
@@ -408,6 +591,67 @@ def Driver(
|
|
408
591
|
uc_cdp_events = True
|
409
592
|
else:
|
410
593
|
uc_cdp_events = False
|
594
|
+
if undetectable and browser != "chrome":
|
595
|
+
message = (
|
596
|
+
'\n Undetected-Chromedriver Mode ONLY supports Chrome!'
|
597
|
+
'\n ("uc=True" / "undetectable=True" / "--uc")'
|
598
|
+
'\n (Your browser choice was: "%s".)'
|
599
|
+
'\n (Will use "%s" without UC Mode.)\n' % (browser, browser)
|
600
|
+
)
|
601
|
+
print(message)
|
602
|
+
if headed is None:
|
603
|
+
# Override the default headless mode on Linux if set.
|
604
|
+
if "--gui" in sys_argv or "--headed" in sys_argv:
|
605
|
+
headed = True
|
606
|
+
else:
|
607
|
+
headed = False
|
608
|
+
if (
|
609
|
+
shared_utils.is_linux()
|
610
|
+
and not headed
|
611
|
+
and not headless
|
612
|
+
and not headless2
|
613
|
+
and (
|
614
|
+
not undetectable
|
615
|
+
or "DISPLAY" not in os.environ.keys()
|
616
|
+
or not os.environ["DISPLAY"]
|
617
|
+
)
|
618
|
+
):
|
619
|
+
headless = True
|
620
|
+
if recorder_mode and headless:
|
621
|
+
headless = False
|
622
|
+
headless1 = False
|
623
|
+
headless2 = True
|
624
|
+
if headless2 and browser == "firefox":
|
625
|
+
headless2 = False # Only for Chromium browsers
|
626
|
+
headless = True # Firefox has regular headless
|
627
|
+
elif browser not in ["chrome", "edge"]:
|
628
|
+
headless2 = False # Only for Chromium browsers
|
629
|
+
if disable_csp is None:
|
630
|
+
if (
|
631
|
+
"--disable-csp" in sys_argv
|
632
|
+
or "--no-csp" in sys_argv
|
633
|
+
or "--dcsp" in sys_argv
|
634
|
+
):
|
635
|
+
disable_csp = True
|
636
|
+
else:
|
637
|
+
disable_csp = False
|
638
|
+
if (
|
639
|
+
(enable_ws is None and disable_ws is None)
|
640
|
+
and (
|
641
|
+
"--disable-web-security" in sys_argv
|
642
|
+
or "--disable-ws" in sys_argv
|
643
|
+
or "--dws" in sys_argv
|
644
|
+
)
|
645
|
+
):
|
646
|
+
enable_ws = False
|
647
|
+
elif (
|
648
|
+
(enable_ws is None and disable_ws is None)
|
649
|
+
or (disable_ws is not None and not disable_ws)
|
650
|
+
or (enable_ws is not None and enable_ws)
|
651
|
+
):
|
652
|
+
enable_ws = True
|
653
|
+
else:
|
654
|
+
enable_ws = False
|
411
655
|
if log_cdp_events is None and log_cdp is None:
|
412
656
|
if (
|
413
657
|
"--log-cdp-events" in sys_argv
|
@@ -427,6 +671,11 @@ def Driver(
|
|
427
671
|
use_auto_ext = True
|
428
672
|
else:
|
429
673
|
use_auto_ext = False
|
674
|
+
if disable_cookies is None:
|
675
|
+
if "--disable-cookies" in sys_argv:
|
676
|
+
disable_cookies = True
|
677
|
+
else:
|
678
|
+
disable_cookies = False
|
430
679
|
if disable_js is None:
|
431
680
|
if "--disable-js" in sys_argv:
|
432
681
|
disable_js = True
|
@@ -434,6 +683,13 @@ def Driver(
|
|
434
683
|
disable_js = False
|
435
684
|
if pls is not None and page_load_strategy is None:
|
436
685
|
page_load_strategy = pls
|
686
|
+
if not page_load_strategy and "--pls=" in arg_join:
|
687
|
+
if "--pls=none" in sys_argv or '--pls="none"' in sys_argv:
|
688
|
+
page_load_strategy = "none"
|
689
|
+
elif "--pls=eager" in sys_argv or '--pls="eager"' in sys_argv:
|
690
|
+
page_load_strategy = "eager"
|
691
|
+
elif "--pls=normal" in sys_argv or '--pls="normal"' in sys_argv:
|
692
|
+
page_load_strategy = "normal"
|
437
693
|
if page_load_strategy is not None:
|
438
694
|
if page_load_strategy.lower() not in ["normal", "eager", "none"]:
|
439
695
|
raise Exception(
|
@@ -485,6 +741,10 @@ def Driver(
|
|
485
741
|
swiftshader = True
|
486
742
|
else:
|
487
743
|
swiftshader = False
|
744
|
+
if locale is not None and locale_code is None:
|
745
|
+
locale_code = locale
|
746
|
+
if ad_block is not None and ad_block_on is None:
|
747
|
+
ad_block_on = ad_block
|
488
748
|
if ad_block_on is None:
|
489
749
|
if "--ad-block" in sys_argv or "--ad_block" in sys_argv:
|
490
750
|
ad_block_on = True
|
@@ -499,20 +759,33 @@ def Driver(
|
|
499
759
|
host_resolver_rules = (
|
500
760
|
arg_join.split("--host_resolver_rules=")[1].split('"')[0]
|
501
761
|
)
|
502
|
-
if driver_version is None:
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
762
|
+
if driver_version is None and "--driver-version" in arg_join:
|
763
|
+
count = 0
|
764
|
+
for arg in sys_argv:
|
765
|
+
if arg.startswith("--driver-version="):
|
766
|
+
driver_version = arg.split("--driver-version=")[1]
|
767
|
+
break
|
768
|
+
elif arg == "--driver-version" and len(sys_argv) > count + 1:
|
769
|
+
driver_version = sys_argv[count + 1]
|
770
|
+
if driver_version.startswith("-"):
|
771
|
+
driver_version = None
|
772
|
+
break
|
773
|
+
count += 1
|
774
|
+
if driver_version is None and "--driver_version" in arg_join:
|
775
|
+
count = 0
|
776
|
+
for arg in sys_argv:
|
777
|
+
if arg.startswith("--driver_version="):
|
778
|
+
driver_version = arg.split("--driver_version=")[1]
|
779
|
+
break
|
780
|
+
elif arg == "--driver_version" and len(sys_argv) > count + 1:
|
781
|
+
driver_version = sys_argv[count + 1]
|
782
|
+
if driver_version.startswith("-"):
|
783
|
+
driver_version = None
|
784
|
+
break
|
785
|
+
count += 1
|
511
786
|
browser_name = browser
|
512
787
|
|
513
788
|
# Launch a web browser
|
514
|
-
from seleniumbase.core import browser_launcher
|
515
|
-
|
516
789
|
driver = browser_launcher.get_driver(
|
517
790
|
browser_name=browser_name,
|
518
791
|
headless=headless,
|
@@ -529,6 +802,7 @@ def Driver(
|
|
529
802
|
cap_file=cap_file,
|
530
803
|
cap_string=cap_string,
|
531
804
|
recorder_ext=recorder_ext,
|
805
|
+
disable_cookies=disable_cookies,
|
532
806
|
disable_js=disable_js,
|
533
807
|
disable_csp=disable_csp,
|
534
808
|
enable_ws=enable_ws,
|
@@ -540,6 +814,7 @@ def Driver(
|
|
540
814
|
log_cdp_events=log_cdp_events,
|
541
815
|
no_sandbox=no_sandbox,
|
542
816
|
disable_gpu=disable_gpu,
|
817
|
+
headless1=headless1,
|
543
818
|
headless2=headless2,
|
544
819
|
incognito=incognito,
|
545
820
|
guest_mode=guest_mode,
|