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

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

  • chrome-launcher’s flags
  • Chromedriver’s flags
  • Puppeteer’s flags
  • WebpageTest’s flags
  • Catapult’s flags and here
  • Karma’s flags

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/Preferenceschrome --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.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/110419.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

从实时监控到智能洞察:Grafana 和 CnosDB 的无限潜力

在今天的数字化世界中&#xff0c;监控系统对于维护应用程序和基础设施的稳定性至关重要。本文将介绍如何使用 Grafana 和 CnosDB 构建强大的监控体系&#xff0c;以便实时监视性能、发现问题并采取及时的措施。 CnosDB已正式上架Grafana插件市场 Grafana&#xff1a;开源监控和…

(手撕)数据结构--->堆

文章内容 目录 一&#xff1a;堆的相关概念与结构 二&#xff1a;堆的代码实现与重要接口代码讲解 让我们一起来学习:一种特殊的数据结构吧&#xff01;&#xff01;&#xff01;&#xff01; 一&#xff1a;堆的相关概念与结构 在前面我们已经简单的学习过了二叉树的链式存储结…

虚拟化和容器

文章目录 1 介绍1.1 简介1.2 虚拟化工作原理1.3 两大核心组件&#xff1a;QEMU、KVMQEMUKVM 1.4 发展历史1.5 虚拟化类型1.6 云计算与虚拟化1.7 HypervisorHypervisor分为两大类 1.8 虚拟化 VS 容器 2 虚拟化应用dockerdocker 与虚拟机的区别 K8Swine 参考 1 介绍 1.1 简介 虚…

stm32---定时器输入捕获

一、输入捕获介绍 在定时器中断实验章节中我们介绍了通用定时器具有多种功能&#xff0c;输入捕获就是其中一种。 STM32F1除了基本定时器TIM6和TIM7&#xff0c;其他定时器都具有输入捕获功能 。输入捕获可以对输入的信号的上升沿&#xff0c;下降沿或者双边沿进行捕获&#xf…

Linux中swap几乎耗尽,但物理内存还有空余的现象

故障现象&#xff1a; 产生此现象的原因&#xff1a; swappiness 配额设置了偏高的值。 还有一个潜在的因素是某个程序因其自身对内存管理的缺陷&#xff0c;形成了zombie进程、且为及时关闭的处理任务还在持续消耗Mem及swap。 解决办法&#xff1a; 调低swappiness 配额值&…

C++ - 异常介绍和使用

前言 我们在日常编写代码的时候&#xff0c;难免会出现编写错误带来程序的奔溃&#xff0c;或者是用户在使用我们编写的程序时候&#xff0c;使用错误所带来程序的奔溃。 在C 当中 可以对你觉得可能发生 错误 的地方在运行之前进行判断&#xff0c;发生错误可以给出提示。 C…

PDF 工具箱

PDF 工具箱 V9.0.0.1 程序&#xff1a;VB.net 运行库&#xff1a;NET Framework 4.5 功能简介&#xff1a; 1、PDF文件多文件合并&#xff0c;可调整顺序。 2、PDF文件拆分&#xff0c;将每页拆分成独立的PDF文件。 3、PDF文件添加水印&#xff0c;文字或图片水印&…

解决中国科大 USTC 邮箱系统的超大附件上传的邮箱控件安装问题

USTC邮箱系统上传超过 48M 的附件的步骤&#xff1a; 从文件中转站上传文件&#xff0c;会提示下载邮箱控件 cmplugin_setup.exe &#xff0c;默认安装C盘即可 2. 安装好之后依然无法上传超大文件&#xff0c;因为只有 IE 浏览器支持该功能&#xff0c;所以可以使用 Edge 浏览…

opencv dnn模块 示例(16) 目标检测 object_detection 之 yolov4

博客【opencv dnn模块 示例(3) 目标检测 object_detection (2) YOLO object detection】 测试了yolov3 及之前系列的模型&#xff0c;有在博客【opencv dnn模块 示例(15) opencv4.2版本dnn支持cuda加速&#xff08;vs2015异常解决&#xff09;】 说明了如何使用dnn模块进行cuda…

C语言实现通讯录 (附完整代码)

C语言实现通讯录 &#x1f340;实现一个通讯录&#xff1a;&#x1f340;通讯录的功能&#xff1a;&#x1f340;多文件实现&#x1f4ae;设计结构体——保存人的信息&#x1f4ae;初始通讯录&#x1f4ae;封装通讯录&#x1f4ae;define宏定义修改通讯录的最大容量初始化通讯录…

掌握这5种方法,让你的新AirPods充电盒更耐用!

每次AirPods充电盒落地时&#xff0c;你都会呼吸急促吗&#xff1f;无论我使用的是旧一代的AirPods还是最新的AirPod Pro 2&#xff0c;我都关心它们的保存状况&#xff0c;并尽力保护这些脆弱设备的安全。我想我对AirPods Pro 2的新充电盒也会有同样的感受&#xff0c;它在9月…

页面静态化、Freemarker入门

页面静态化介绍 页面的访问量比较大时&#xff0c;就会对数据库造成了很大的访问压力&#xff0c;并且数据库中的数据变化频率并不高。 那需要通过什么方法为数据库减压并提高系统运行性能呢&#xff1f;答案就是页面静态化。页面静态化其实就是将原来的动态网页(例如通过ajax…