Skip to content

Commit bc94de8

Browse files
committed
Update default Chrome and Edge (Chromium) options
1 parent 420b6cc commit bc94de8

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ def _set_chrome_options(
223223
chrome_options.add_argument("--homepage=about:blank")
224224
chrome_options.add_argument("--dns-prefetch-disable")
225225
chrome_options.add_argument("--dom-automation")
226+
chrome_options.add_argument("--disable-hang-monitor")
227+
chrome_options.add_argument("--disable-prompt-on-repost")
226228
if not use_auto_ext: # (It's ON by default. Disable it when not wanted.)
227229
chrome_options.add_experimental_option("useAutomationExtension", False)
228230
if (settings.DISABLE_CSP_ON_CHROME or disable_csp) and not headless:
@@ -695,9 +697,11 @@ def get_local_driver(
695697
print("\nWarning: msedgedriver not found. Installing now:")
696698
sb_install.main(override="edgedriver")
697699
sys.argv = sys_args # Put back the original sys args
700+
# For Microsoft Edge (Chromium) version 79 or lower
698701
return webdriver.Chrome(executable_path=LOCAL_EDGEDRIVER,
699702
options=chrome_options)
700703
except Exception:
704+
# For Microsoft Edge (Chromium) version 80 or higher
701705
from msedge.selenium_tools import Edge, EdgeOptions
702706
if LOCAL_EDGEDRIVER and os.path.exists(LOCAL_EDGEDRIVER):
703707
try:
@@ -707,6 +711,18 @@ def get_local_driver(
707711
" executable: %s" % e)
708712
edge_options = EdgeOptions()
709713
edge_options.use_chromium = True
714+
prefs = {
715+
"download.default_directory": downloads_path,
716+
"local_discovery.notifications_enabled": False,
717+
"credentials_enable_service": False,
718+
"profile": {
719+
"password_manager_enabled": False
720+
}
721+
}
722+
if block_images:
723+
prefs["profile.managed_default_content_settings.images"] = 2
724+
edge_options.add_experimental_option("prefs", prefs)
725+
edge_options.add_experimental_option("w3c", True)
710726
edge_options.add_experimental_option(
711727
"useAutomationExtension", False)
712728
edge_options.add_experimental_option(
@@ -734,13 +750,36 @@ def get_local_driver(
734750
edge_options.add_experimental_option(
735751
"mobileEmulation", emulator_settings)
736752
edge_options.add_argument("--enable-sync")
753+
edge_options.add_argument("--disable-infobars")
754+
edge_options.add_argument("--disable-save-password-bubble")
755+
edge_options.add_argument("--disable-single-click-autofill")
756+
edge_options.add_argument("--disable-translate")
757+
edge_options.add_argument("--disable-web-security")
758+
edge_options.add_argument("--homepage=about:blank")
759+
edge_options.add_argument("--dns-prefetch-disable")
760+
edge_options.add_argument("--dom-automation")
761+
edge_options.add_argument("--disable-hang-monitor")
762+
edge_options.add_argument("--disable-prompt-on-repost")
737763
if proxy_string:
738-
if proxy_auth:
739-
edge_options = _add_chrome_proxy_extension(
740-
edge_options, proxy_string, proxy_user, proxy_pass)
741764
edge_options.add_argument('--proxy-server=%s' % proxy_string)
765+
edge_options.add_argument("--test-type")
766+
edge_options.add_argument("--log-level=3")
767+
edge_options.add_argument("--no-first-run")
768+
edge_options.add_argument("--ignore-certificate-errors")
769+
if devtools and not headless:
770+
edge_options.add_argument("--auto-open-devtools-for-tabs")
771+
edge_options.add_argument("--allow-file-access-from-files")
772+
edge_options.add_argument("--allow-insecure-localhost")
773+
edge_options.add_argument("--allow-running-insecure-content")
742774
if user_agent:
743775
edge_options.add_argument("--user-agent=%s" % user_agent)
776+
edge_options.add_argument("--no-sandbox")
777+
if swiftshader:
778+
edge_options.add_argument("--use-gl=swiftshader")
779+
else:
780+
edge_options.add_argument("--disable-gpu")
781+
if "linux" in PLATFORM:
782+
edge_options.add_argument("--disable-dev-shm-usage")
744783
capabilities = edge_options.to_capabilities()
745784
capabilities["platform"] = ''
746785
return Edge(

0 commit comments

Comments
 (0)