Skip to content

Commit 0fc8705

Browse files
committed
Handle edge cases with extension-loading in regular mode
1 parent aed740b commit 0fc8705

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ def extend_driver(
295295
driver.set_wire_proxy = DM.set_wire_proxy
296296
completed_loads = []
297297
for ext_dir in sb_config._ext_dirs:
298-
with suppress(Exception):
299-
if ext_dir not in completed_loads:
300-
completed_loads.append(ext_dir)
301-
if not use_uc and os.path.exists(os.path.abspath(ext_dir)):
302-
driver.webextension.install(os.path.abspath(ext_dir))
298+
if ext_dir not in completed_loads:
299+
completed_loads.append(ext_dir)
300+
if not use_uc and os.path.exists(os.path.realpath(ext_dir)):
301+
with suppress(Exception):
302+
driver.webextension.install(os.path.realpath(ext_dir))
303303
if proxy_auth:
304-
with suppress(Exception):
305-
if not use_uc and os.path.exists(proxy_helper.PROXY_DIR_PATH):
304+
if not use_uc and os.path.exists(proxy_helper.PROXY_DIR_PATH):
305+
with suppress(Exception):
306306
driver.webextension.install(proxy_helper.PROXY_DIR_PATH)
307307
# Proxy needs a moment to load in Manifest V3
308308
if use_uc:
@@ -2479,7 +2479,7 @@ def _set_chrome_options(
24792479
# Can be a comma-separated list of .ZIP or .CRX files
24802480
extension_zip_list = extension_zip.split(",")
24812481
for extension_zip_item in extension_zip_list:
2482-
abs_path = os.path.abspath(extension_zip_item)
2482+
abs_path = os.path.realpath(extension_zip_item)
24832483
if os.path.exists(abs_path):
24842484
try:
24852485
abs_path_dir = os.path.join(
@@ -2496,11 +2496,11 @@ def _set_chrome_options(
24962496
if extension_dir:
24972497
# load-extension input can be a comma-separated list
24982498
abs_path = (
2499-
",".join(os.path.abspath(p) for p in extension_dir.split(","))
2499+
",".join(os.path.realpath(p) for p in extension_dir.split(","))
25002500
)
25012501
chrome_options = add_chrome_ext_dir(chrome_options, abs_path)
25022502
for p in extension_dir.split(","):
2503-
sb_config._ext_dirs.append(os.path.abspath(p))
2503+
sb_config._ext_dirs.append(os.path.realpath(p))
25042504
if (
25052505
page_load_strategy
25062506
and page_load_strategy.lower() in ["eager", "none"]
@@ -2744,10 +2744,12 @@ def _set_chrome_options(
27442744
included_disabled_features.append(item)
27452745
d_f_string = ",".join(included_disabled_features)
27462746
chrome_options.add_argument("--disable-features=%s" % d_f_string)
2747+
chrome_options.add_argument("--enable-unsafe-extension-debugging")
27472748
if proxy_auth:
27482749
chrome_options.add_argument("--test-type")
27492750
if proxy_auth or sb_config._ext_dirs:
27502751
if not is_using_uc(undetectable, browser_name):
2752+
chrome_options.add_argument("--remote-debugging-pipe")
27512753
chrome_options.enable_webextensions = True
27522754
chrome_options.enable_bidi = True
27532755
if (
@@ -4579,12 +4581,12 @@ def get_local_driver(
45794581
# Can be a comma-separated list of .ZIP or .CRX files
45804582
extension_zip_list = extension_zip.split(",")
45814583
for extension_zip_item in extension_zip_list:
4582-
abs_path = os.path.abspath(extension_zip_item)
4584+
abs_path = os.path.realpath(extension_zip_item)
45834585
edge_options.add_extension(abs_path)
45844586
if extension_dir:
45854587
# load-extension input can be a comma-separated list
45864588
abs_path = (
4587-
",".join(os.path.abspath(p) for p in extension_dir.split(","))
4589+
",".join(os.path.realpath(p) for p in extension_dir.split(","))
45884590
)
45894591
edge_options = add_chrome_ext_dir(edge_options, abs_path)
45904592
edge_options.add_argument("--disable-infobars")

0 commit comments

Comments
 (0)