Chrome Flags for Automation: A Comprehensive Guide
Automating tasks in Chrome requires a deep understanding of various command-line flags that can configure the browser's behavior. This article provides a detailed overview of these flags, categorized for easier navigation, to help you optimize your automation, testing, and benchmarking workflows. This article will cover everything from disabling unwanted browser features to suppressing interactivity and background networking.
Understanding Chrome Flags for Tooling
Chrome flags are command-line arguments that modify the browser's behavior. They are essential for tools that automate Chrome, as they allow you to control various aspects of the browser environment, disable unwanted features, and optimize performance.
Commonly Unwanted Browser Features
These flags help to streamline the browser by disabling unnecessary features that can interfere with automation:
--disable-client-side-phishing-detection
: Turns off phishing detection.--disable-component-extensions-with-background-pages
: Disables built-in extensions.--disable-default-apps
: Prevents the installation of default apps.--disable-extensions
: Disables all Chrome extensions.--disable-features=InterestFeedContentSuggestions
: Removes the Discover feed on the New Tab Page.--disable-features=Translate
: Disables the Chrome translate feature.--hide-scrollbars
: Hides scrollbars from screenshots.--mute-audio
: Mutes audio output.--no-default-browser-check
: Skips the default browser check.--no-first-run
: Skips the first-run wizard.--ash-no-nudges
: Avoids blue bubble "user education" nudges.--disable-search-engine-choice-screen
: Disables the search engine choice screen.--propagate-iph-for-testing
: Specifies which in-product help (IPH) features are allowed.
Optimizing Task Throttling
These flags help control the behavior of background tasks and processes to prevent resource contention:
--disable-background-timer-throttling
: Prevents timers from being throttled in background tabs.--disable-backgrounding-occluded-windows
: Prevents Chrome from treating a foreground tab as backgrounded if its window is covered.--disable-features=CalculateNativeWinOcclusion
: Disables window occlusion calculation on Windows which can throttle foreground tabs in occluded windows.--disable-hang-monitor
: Suppresses hang monitor dialogs in renderer processes.--disable-ipc-flooding-protection
: Disables protection against IPC flooding.--disable-renderer-backgrounding
: Prevents non-foreground tabs from getting lower process priority.
Adjusting Web Platform Behavior
These flags modify how Chrome handles web platform features and functionalities:
--aggressive-cache-discard
: Aggressively discards cached data.--allow-running-insecure-content
: Allows running insecure content on secure pages.--disable-back-forward-cache
: Disables the BackForwardCache feature.--disable-features=AcceptCHFrame
: Disable accepting h2/h3 ACCEPT_CH Client Hints frames.--disable-features=AvoidUnnecessaryBeforeUnloadCheckSync
: Avoids checkingbeforeunload
handlers unless necessary.--disable-features=BackForwardCache
: Disable the bfcache.--disable-features=HeavyAdPrivacyMitigations
: Disables privacy mitigation for heavy ads.--disable-features=IsolateOrigins
--disable-features=LazyFrameLoading
--disable-features=ScriptStreaming
: Disable V8 script streaming--no-process-per-site
: Disables renderer process reuse across tabs of the same site.--enable-precise-memory-info
: Provides more granular memory information.--js-flags=--random-seed=1157259157
: Initializes V8's RNG with a fixed seed.--use-fake-device-for-media-stream
: Uses a fake device for media streams, replacing camera and microphone.--use-fake-ui-for-media-stream
: Bypasses the media stream infobar.--use-file-for-fake-video-capture=
: Uses a file for fake video capture. Requires--use-fake-device-for-media-stream
.
Suppressing Interactivity
These flags are key for maintaining control during automated sessions by preventing unwanted prompts and interactions:
--autoplay-policy=...
: Controls autoplay behavior (user-gesture-required
orno-user-gesture-required
).--deny-permission-prompts
: Automatically denies all permission prompts.--disable-external-intent-requests
: Disallows opening links in external applications.--disable-features=GlobalMediaControls
: Hides the global media controls button.--disable-features=ImprovedCookieControls
: Disables an improved UI for third-party cookie blocking in incognito mode.--disable-features=PrivacySandboxSettings4
: Disables "Enhanced ad privacy in Chrome" dialog--disable-notifications
: Disables Web Notifications and Push APIs.--disable-popup-blocking
: Disables popup blocking. Consider--block-new-web-contents
for stricter blocking.--disable-prompt-on-repost
: Prevents prompting the user when reloading a page from a POST request.--noerrdialogs
: Suppresses all error dialogs.
Essential Flags for Catch-All Automation
These flags disable unwanted behaviors in automation scenarios:
--enable-automation
: Disables features considered inappropriate for automation. Setswindow.navigator.webdriver
totrue
. Disables bubble notification about running development/unpacked extensions, the password saving UI, infobar animations and auto-reloading on network errors.--test-type
: An older version of--enable-automation
.--remote-debugging-pipe
: Enables remote debugging using a pipe. More secure than websockets.--remote-debugging-port=...
: Enables remote debugging on a specified port.--silent-debugger-extension-api
: Suppresses infobars when extensions attach usingchrome.debugger
.
General Utility Flags
These flags provide general configuration options:
--enable-logging=stderr
: Configures logging to be more suitable for server-type processes.--log-level=0
: Sets the logging level (0 for INFO and higher, 2 for most verbose).--user-data-dir=...
: Specifies the directory for storing the user profile.
Mitigating Chromium Annoyances
These flags help avoid common issues and dialogs:
--disable-features=MediaRouter
: Disables the Chrome Media Router and avoids startup dialogs about network connections.--password-store=basic
: Avoids potential instability with Gnome Keyring or KDE wallet.--use-mock-keychain
: Uses a mock keychain on Mac to prevent permissions dialogs.
Controlling Background Networking
These flags are important for minimizing background activity:
--disable-background-networking
: Disables various background network services.--disable-breakpad
: Disables crashdump collection.--disable-component-update
: Prevents updating browser components.--disable-domain-reliability
: Disables Domain Reliability Monitoring.--disable-features=AutofillServerCommunication
: Disables autofill server communication.--disable-features=CertificateTransparencyComponentUpdater
--disable-sync
: Disables syncing to a Google account.--enable-crash-reporter-for-testing
: Enables crash reporting in debug environments.--metrics-recording-only
: Disables reporting to UMA but allows collection.--disable-features=OptimizationHints
: Disable the Chrome Optimization Guide and networking with its service API--disable-features=DialMediaRouteProvider
: A weaker form of disabling theMediaRouter
feature.--no-pings
: Prevents sending hyperlink auditing pings.
Rendering and GPU Optimization
These flags are primarily for configuring rendering and GPU usage:
--allow-pre-commit-input
: Allows processing input before a frame is committed (used by headless).--deterministic-mode
: Enables deterministic rendering.--disable-features=PaintHolding
: Don't defer paint commits (normally used to avoid flash of unstyled content)--disable-partial-raster
: Prevents partial rasterization.--disable-skia-runtime-opts
: Disables runtime-detected CPU optimizations in Skia.--in-process-gpu
: Moves the GPU process into a browser process thread.--use-gl="swiftshader"
: Selects the GL implementation for the GPU process.
Conclusion
Mastering Chrome flags is crucial for anyone involved in browser automation, testing, or performance analysis. By carefully selecting and applying these flags, you can create a controlled, efficient, and reliable environment for your automated tasks.