【Selenium】webdriver.ChromeOptions()官方文档参数

2023-11-15

Google官方Chrome文档,在此记录一下

Chrome Flags for Tooling

Many tools maintain a list of runtime flags for Chrome to configure the environment. This file
is an attempt to document all chrome flags that are relevant to tools, automation, benchmarking, etc.

All use cases are different, so you’ll have to choose which flags are most appropriate.

Here’s a Nov 2022 comparison of what flags all these tools use.

Commonly unwanted browser features

  • --disable-client-side-phishing-detection: Disables client-side phishing detection
  • --disable-component-extensions-with-background-pages: Disable some built-in extensions that aren’t affected by --disable-extensions
  • --disable-default-apps: Disable installation of default apps
  • --disable-extensions: Disable all chrome extensions
  • --disable-features=InterestFeedContentSuggestions: Disables the Discover feed on NTP
  • --disable-features=Translate: Disables Chrome translation, both the manual option and the popup prompt when a page with differing language is detected.
  • --hide-scrollbars: Hide scrollbars from screenshots.
  • --mute-audio: Mute any audio
  • --no-default-browser-check: Disable the default browser check, do not prompt to set it as such
  • --no-first-run: Skip first run wizards

Task throttling

  • --disable-background-timer-throttling: Disable timers being throttled in background pages/tabs
  • --disable-backgrounding-occluded-windows: Normally, Chrome will treat a ‘foreground’ tab instead as backgrounded if the surrounding window is occluded (aka visually covered) by another window. This flag disables that.
  • --disable-features=CalculateNativeWinOcclusion: Disable the feature of: Calculate window occlusion on Windows will be used in the future to throttle and potentially unload foreground tabs in occluded windows.
  • --disable-hang-monitor: Suppresses hang monitor dialogs in renderer processes. This flag may allow slow unload handlers on a page to prevent the tab from closing.
  • --disable-ipc-flooding-protection: Some javascript functions can be used to flood the browser process with IPC. By default, protection is on to limit the number of IPC sent to 10 per second per frame. This flag disables it. https://crrev.com/604305
  • --disable-renderer-backgrounding: This disables non-foreground tabs from getting a lower process priority This doesn’t (on its own) affect timers or painting behavior. karma-chrome-launcher#123

Web platform behavior

  • --aggressive-cache-discard
  • --allow-running-insecure-content
  • --disable-back-forward-cache: Disables the BackForwardCache feature.
  • --disable-features=AcceptCHFrame: Disable accepting h2/h3 ACCEPT_CH Client Hints frames.
  • --disable-features=AutoExpandDetailsElement: Removed in Sept 2022.
  • --disable-features=AvoidUnnecessaryBeforeUnloadCheckSync: If enabled, this feature results in the browser process only asking the renderer process to run beforeunload handlers if it knows such handlers are registered. With kAvoidUnnecessaryBeforeUnloadCheckSync, content does not report a beforeunload handler is present. A ramification of this is navigations that would normally check beforeunload handlers before continuing will not, and navigation will synchronously continue.
  • --disable-features=BackForwardCache: Disable the bfcache.
  • --disable-features=HeavyAdPrivacyMitigations: Disables the privacy mitigations for the heavy ad intervention. This throttles the amount of interventions that can occur on a given host in a time period. It also adds noise to the thresholds used. This is separate from the intervention feature so it does not interfere with field trial activation, as this blocklist is created for every user, and noise is decided prior to seeing a heavy ad.
  • --disable-features=IsolateOrigins
  • --disable-features=LazyFrameLoading
  • --disable-features=ScriptStreaming: V8 script streaming
  • --enable-precise-memory-info: Make the values returned to window.performance.memory more granular and more up to date in shared worker. Without this flag, the memory information is still available, but it is bucketized and updated less frequently. This flag also applys to workers.
  • --js-flags=--random-seed=1157259157: Initialize V8’s RNG with a fixed seed.
  • --use-fake-device-for-media-stream: Use fake device for Media Stream to replace camera and microphone
  • --use-fake-ui-for-media-stream: Bypass the media stream infobar by selecting the default device for media streams (e.g. WebRTC). Works with --use-fake-device-for-media-stream.
  • --use-file-for-fake-video-capture=<path-to-file>: Use file for fake video capture (.y4m or .mjpeg) Needs --use-fake-device-for-media-stream

Interactivity suppression

  • --autoplay-policy=...: Value of user-gesture-required to not autoplay video. Value of no-user-gesture-required to always autoplay video.
  • --deny-permission-prompts: Suppress all permission prompts by automatically denying them.
  • --disable-external-intent-requests: Disallow opening links in external applications
  • --disable-features=GlobalMediaControls: Hide toolbar button that opens dialog for controlling media sessions.
  • --disable-features=ImprovedCookieControls: Disables an improved UI for third-party cookie blocking in incognito mode.
  • --disable-notifications: Disables the Web Notification and the Push APIs.
  • --disable-popup-blocking: Disable popup blocking. --block-new-web-contents is the strict version of this.
  • --disable-prompt-on-repost: Reloading a page that came from a POST normally prompts the user.
  • --noerrdialogs: Suppresses all error dialogs when present.

Catch-all automation

  • --enable-automation: Disable a few things considered not appropriate for automation. (Original design doc, though renamed here) codesearch. Note that some projects have chosen to avoid using this flag: web-platform-tests/wpt/#6348, crbug.com/1277272
    • sets window.navigator.webdriver to true within all JS contexts. This is also set when using --headless, --remote-debugging-pipe and --remote-debugging-port=0 (yes, specifically 0).
    • disables bubble notification about running development/unpacked extensions (source)
    • disables the password saving UI (which covers the usecase of the defunct --disable-save-password-bubble flag)
    • disables infobar animations (source)
    • disables auto-reloading on network errors (source)
    • enables the CDP method Browser.getBrowserCommandLine.
    • avoids showing these 4 infobars: ShowBadFlagsPrompt, GoogleApiKeysInfoBarDelegate, ObsoleteSystemInfoBarDelegate, LacrosButterBar
    • adds this infobar: image … which is known to adversely affect screenshots.
  • --test-type: Basically the 2014 version of --enable-automation. codesearch
    • It avoids creating application stubs in ~/Applications on mac.
    • It makes exit codes slightly more correct
    • windows navigation jumplists arent updated https://crbug.com/389375
    • doesn’t start some chrome StartPageService
    • disables initializing chromecast service
    • “Component extensions with background pages are not enabled during tests because they generate a lot of background behavior that can interfere.”
    • when quitting the browser, it disables additional checks that may stop that quitting process. (like unsaved form modifications or unhandled profile notifications…)
  • --remote-debugging-pipe: more secure than using protocol over a websocket
  • --remote-debugging-port=...: With a value of 0, Chrome will automatically select a useable port and will set navigator.webdriver to true.
  • --silent-debugger-extension-api: Does not show an infobar when a Chrome extension attaches to a page using chrome.debugger page. Required to attach to extension background pages.

General

  • --enable-logging=stderr: Logging behavior slightly more appropriate for a server-type process.
  • --log-level=0: 0 means INFO and higher. 2 is the most verbose. Protip: Use --enable-logging=stderr --v=2 and you may spot additional components active that you may want to disable.
  • --user-data-dir=...: Directory where the browser stores the user profile.

Chromium Annoyances

  • --disable-features=DialMediaRouteProvider: Avoid the startup dialog for Do you want the application “Chromium.app” to accept incoming network connections?. This is a sub-component of the MediaRouter.
  • --password-store=basic: Avoid potential instability of using Gnome Keyring or KDE wallet. chromium/linux/password_storage.md https://crbug.com/571003
  • --use-mock-keychain: Use mock keychain on Mac to prevent the blocking permissions dialog abou: Chrome wants to use your confidential information stored in your keychain

Background networking

  • --disable-background-networking: Disable various background network services, including extension updating,safe browsing service, upgrade detector, translate, UMA
  • --disable-breakpad: Disable crashdump collection (reporting is already disabled in Chromium)
  • --disable-component-update: Don’t update the browser ‘components’ listed at chrome://components/
  • --disable-domain-reliability: Disables Domain Reliability Monitoring, which tracks whether the browser has difficulty contacting Google-owned sites and uploads reports to Google.
  • --disable-features=AutofillServerCommunication: Disables (mostly for hermetic testing) autofill server communication. The URL of the autofill server can further be controlled via the autofill-server-url param. The given URL should specify the complete autofill server API url up to the parent “directory” of the “query” and “upload” resources. i.e., https://other.autofill.server:port/tbproxy/af/
  • --disable-features=CertificateTransparencyComponentUpdater
  • --disable-sync: Disable syncing to a Google account
  • --enable-crash-reporter-for-testing: Used for turning on Breakpad crash reporting in a debug environment where crash reporting is typically compiled but disabled.
  • --metrics-recording-only: Disable reporting to UMA, but allows for collection
  • --disable-features=OptimizationHints: Disable the Chrome Optimization Guide and networking with its service API
  • --disable-features=MediaRouter: Disable the Chrome Media Router which creates some background network activity to discover castable targets.
  • --no-pings: Don’t send hyperlink auditing pings

Rendering & GPU

  • --allow-pre-commit-input: Allows processing of input before a frame has been committed. Used by headless. https://crbug.com/987626
  • --deterministic-mode: An experimental meta flag. This sets the below indented flags which put the browser into a mode where rendering (border radius, etc) is deterministic and begin frames should be issued over DevTools Protocol. codesearch
    • --run-all-compositor-stages-before-draw
    • --disable-new-content-rendering-timeout
    • --enable-begin-frame-control
    • --disable-threaded-animation
    • --disable-threaded-scrolling
    • --disable-checker-imaging
    • --disable-image-animation-resync
  • --disable-features=PaintHolding: Don’t defer paint commits (normally used to avoid flash of unstyled content)
  • --disable-partial-raster: https://crbug.com/919955
  • --disable-skia-runtime-opts: Do not use runtime-detected high-end CPU optimizations in Skia.
  • --in-process-gpu: Saves some memory by moving GPU process into a browser process thread
  • --use-gl="swiftshader": Select which implementation of GL the GPU process should use. Options are: desktop: whatever desktop OpenGL the user has installed (Linux and Mac default). egl: whatever EGL / GLES2 the user has installed (Windows default - actually ANGLE). swiftshader: The SwiftShader software renderer.

Window & screen management

  • --block-new-web-contents: All pop-ups and calls to window.open will fail.
  • --force-color-profile=srgb: Force all monitors to be treated as though they have the specified color profile.
  • --new-window: Launches URL in new browser window.
  • --window-position=0,0: Specify the initial window position: --window-position=x,y
  • --window-size=1600,1024: Sets the initial window size. Provided as string in the format “800,600”.

Process management

  • --disable-features=DestroyProfileOnBrowserClose: Disable the feature of: Destroy profiles when their last browser window is closed, instead of when the browser exits.
  • --disable-features=site-per-process: Disables OOPIF. https://www.chromium.org/Home/chromium-security/site-isolation
  • --no-service-autorun: Disables the service process from adding itself as an autorun process. This does not delete existing autorun registrations, it just prevents the service from registering a new one.
  • --process-per-tab: Doesn’t do anything. Use --single-process instead.
  • --single-process: Runs the renderer and plugins in the same process as the browser.

Headless

  • --headless: Run in headless mode, i.e., without a UI or display server dependencies.
  • --headless=new: New, native Headless mode. (previously, --headless=chrome)
  • --no-sandbox: Sometimes used with headless, though not recommended.
  • --disable-dev-shm-usage: Often used in Lambda, Cloud Functions scenarios. (pptr issue, crbug)
  • --disable-gpu: Was often used along with --headless, but as of 2021, isn’t needed.

Removed flags

  • --disable-add-to-shelf: Removed June 2017
  • --disable-background-downloads: Removed Oct 2014.
  • --disable-browser-side-navigation: Removed. It disabled PlzNavigate.
  • --disable-datasaver-prompt: Removed
  • --disable-desktop-notifications: Removed
  • --disable-device-discovery-notifications: Removed. Avoided messages like “New printer on your network”. Replaced with --disable-features=MediaRouter.
  • --disable-features=TranslateUI: Removed as TranslateUI changed to Translate in Sept 2020.
  • --disable-infobars: Removed April 2014
  • --disable-save-password-bubble: Removed May 2016
  • --disable-search-geolocation-disclosure: Removed.
  • --disable-translate: Removed April 2017 Used to disable built-in Google Translate service.
  • --ignore-autoplay-restrictions: Removed December 2017 Can use --autoplay-policy=no-user-gesture-required instead.
  • --safebrowsing-disable-auto-update: Removed Nov 2017

Sources

The canonical list of Chrome command-line switches on peter.sh (maintained by the Chromium team)

FYI: (Probably) all flags are defined in files matching the pattern of *_switches.cc.

Set Preferences

Many Chrome settings are defined in a JSON file located at USER_DATA_DIR/Default/Preferences. Browse your own Preferences file to see what’s in there; some, but not all, preferences are defined in pref_names.h

If you wanted to launch a fresh Chrome profile with some Preferences set, for example: disable DevTools source-map fetching:

mkdir -p your_empty_user_data_dir/Default/
echo '{"devtools":{"preferences":{"jsSourceMapsEnabled":"false","cssSourceMapsEnabled":"false"}}}' > your_empty_user_data_dir/Default/Preferences

chrome --user-data-dir=your_empty_user_data_dir ...

Feature Flags FYI

Chromium and Blink use feature flags to disable/enable many features at runtime. Chromium has ~400 features that can be toggled with --enable-features / --disable-features. https://niek.github.io/chrome-features/ presents all of them very clearly.

Independently, Blink has many features that can be toggled with commandline switches: --enable-blink-features / --disable-blink-features.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【Selenium】webdriver.ChromeOptions()官方文档参数 的相关文章

随机推荐

  • 2022最新秋招+社招Android面试题汇总+解析(内含字节、网易等大厂面经)

    前言 目前的就业形式可以分为校招和社招两大战场 无形的竞争相当于是一场没有硝烟的厮杀 人才饱和的结果当然就是一阵阵卷麻了的哀嚎 不过 大家既然选择了Android 自然就得做好迎战的准备 最近一两个月 陆陆续续的秋招面经都出来了 但是在网上
  • 2020年全国平均工资出炉:IT行业超17万居首!网友:又是拖后腿的那个~

    2020年全国平均工资出炉了 2020年全国城镇非私营单位就业人员年平均工资为97379元 2020年全国城镇私营单位就业人员年平均工资为57727元 前三甲依次是信息传输 软件和信息技术服务业177544元 其次是科学研究和技术服务业13
  • codeblocks创建和使用静态库(C语言)

    静态库 扩展名为 a 或 lib 是包含函数的文件 用于在link阶段整合执行程序 动态链接库 扩展名 dll 是不在link阶段整合进执行程序中的 DLL文件在执行阶段动态调用 下面我们将用免费的开发工具CodeBocks开发静态库 创建
  • 【C++】在线IDE

    1 洛谷在线IDE https www luogu com cn ide 2 菜鸟工具 https c runoob com compile 12 3 Cloud Studio https cloudstudio net
  • 使用STM32CubeMX生成源码工程后,使用ST-LINK下载出现问题的解决方法

    第一次使用STM32CubeMX生成源码工程文件 各种时钟引脚资源配置好后 点击生成了Keil的工程 编译通过 连接ST LINK下载程序 第一次下载 一切正常 然后修改了一下程序 再次下载 出现找不到设备的提示 以为板子出了问题 又拿过来
  • Python 数组(Arrays)

    数组 Array 是有序的元素序列 若将有限个类型相同的变量的集合命名 那么这个名称为数组名 组成数组的各个变量称为数组的分量 也称为数组的元素 有时也称为下标变量 用于区分数组的各个元素的数字编号称为下标 数组是在程序设计中 为了处理方便
  • 为什么db是先写日志,而redis是后写日志

    预写式日志 Write Ahead Logging WAL 基本上所有的数据库都实现了这个WAL技术 来保证原子性和持久性 WAL的核心思想是 在数据写入到数据库之前 先写入到日志 这一定程度上也可以提高效率 因为不需要每次都和磁盘交互 可
  • 各种开源应用的实践经验

    在实际的项目中 很多地方需要用到开源项目 而现在的开源项目太多 从开源项目的首页去看的话 也未必能得到足够充分的信息 多数时候是选用淘汰法 选剩下两到三个项目然后自己再去一个一个地去试用 选择合适的开源组件确实是一件麻烦事 本文将记录下选择
  • Arthas 定位CPU跑满问题,源头竟是Apache Beanutils

    一 背景 大早上 线上k8s 机子 某个机子 cpu 飙高 导致k8s 健康检查失败 线上环境会自动执行jstack 上传到oss 通知到 钉钉告警群 直接分析锁 cpu 高的线程 二 过程分析 2 1 排查cpu 占用最高的线程 使用js
  • JAVA-0基础学习笔记-day01

    0基础学Java笔记day01 01 01 计算机基础知识 计算机概述 了解 A 什么是计算机 计算机在生活中的应用举例 计算机 Computer 全称 电子计算机 俗称电脑 是一种能够按照程序运行 自动 高速处理海量数据的现代化智能电子设
  • Java经典面试题 带答案(五)

    Java经典面试题 带答案 五 Java 面试笔试题汇总 一 编程语言 Java 2 二 软件工程方面 9 三 智力测试 9 四 数据库 12 五 Java框架方面 14 六 XML方面 17 七 网络基础方面 17 八 算法方面 19 1
  • eclispe黑色配色方案,插件配置

    http blog csdn net zhwangkaixuan article details 9303359 使用android官方的ADT感觉界面白色的太怪了 看就了眼睛不舒服 上网找了一个eclispe的插件可以定制编辑器的配色方案
  • Docker学习笔记05-----镜像仓库之官方Docker Hub

    官方Docker Hub https hub docker com 1 创建Repository 2 构建容器镜像 2 1 创建Dockerfile FROM java 8 MAINTAINER itmrl LABEL name hello
  • Qt颜色选择器(HSV)

    目录 引言 HSV颜色空间 实现思路 代码实现 引言 基于Qt实现的HSV颜色选择器 效果如下 HSV颜色空间 HSV Hue Saturation Value 是根据颜色的直观特征创建的颜色模型 如下图所示 Hue为色调 通过角度表示不同
  • 3_Nginx重载、热部署、日志切割

    文章目录 常用命令 重载配置文件 热部署 流程 日志切割 常用命令 获取帮助 nginx h 使用指定的配置文件 nginx c conf file 在命令行中覆盖配置文件中的指令 nginx g 指定运行目录 nginx p 发送信号 n
  • 【Vue学习笔记3】使用Vite开启一个Vue3工程项目

    1 什么是Vite Vite是一个web开发构建工具 Vite 的竞品是 Webpack 而且按照现在的趋势看 使用率超过 Webpack 也是早晚的事 Vite 主要提升的是开发的体验 Webpack启动调试环境需要 3 分钟都很常见 V
  • linux环境下的Qt编程问题解决

    1 gcc编译器无法使用 原因可能是没有安装g 终端输入命令 sudo apt get install g 2 编译程序报错Could not start process make qmake all 解决办法 终端输入命令 sudo ap
  • 机器学习(第二章)—— 模型评估

    目录 一 评估指标的局限性 二 ROC曲线 三 余弦距离的应用 四 A B测试的陷阱 五 模型的评估方法 六 超参数优化 七 过拟合与欠拟合 准确率的局限性 精确率与召回率的权衡 平方根误差的 意外 什么是ROC曲线 为什么要进行在线A B
  • include过滤器

    include过滤器分为core gui io scene video几个文件夹以及 IEventReceiver h Irrlicht h Irrlicht h IrrlichtDevice h Irrlicht h IrrlichtDe
  • 【Selenium】webdriver.ChromeOptions()官方文档参数

    Google官方Chrome文档 在此记录一下 Chrome Flags for Tooling Many tools maintain a list of runtime flags for Chrome to configure the