【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.mzph.cn/news/80313.shtml

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

相关文章

Windows10设置开启自启动任务

Windows10设置开机自启动任务 在日常的工作中经常会遇到需要给系统设置一个开机自启动的任务&#xff0c;例如开机自启动浏览器&#xff0c;开机自启动代理程序等等&#xff0c;这个时候就需要给系统设置一个开机自启动任务&#xff0c;本文主要介绍一下设置开机自启动任务的几…

使用 Messenger 跨进程通信

什么是Messenger Messenger 也是IPC的方案之一&#xff0c;是基于消息的跨进程通信。基于消息是什么意思&#xff1f;Handler是我们最常用的消息机制&#xff0c;所以 Messenger 对于使用者来说就像是使用 Handler。实际上 Messenger 就是 AIDL 的上层封装而已&#xff0c;它们…

微服务全栈:深入核心组件与开发技巧

文章目录 1.服务注册与发现1.1. 客户端注册 (ZooKeeper)1.2. 第三方注册 (独立的服务Registrar)1.3. 客户端发现1.4. 服务端发现1.5. Consul1.6. Eureka1.7. SmartStack1.8. Etcd 2. API 网关2.1. 请求转发2.2. 响应合并2.3. 协议转换2.4. 数据转换2.5. 安全认证 3. 配置中心3.…

什么是交换分区以及如何创建交换分区

介绍 交换分区是Linux中的一项功能,可提供虚拟内存空间和多种好处。它允许操作系统有效地处理内存需求。因此,交换分区提高了系统稳定性、响应能力和繁重工作负载处理。 本指南将探讨交换分区及其优缺点,并概述在 Linux 系统上创建和管理交换分区的步骤。 先决条件 运行 …

PHP自己的框架2.0结合容器技术(重构篇二)

目录 1、使用容器实现框架加载类运行 2、 创建框架容器类core/fm/Di.php 3、框架使用容器类来执行public/index.php 4、运行效果还是一样 1、使用容器实现框架加载类运行 2、 创建框架容器类core/fm/Di.php 什么是容器&#xff1f;容器就相当于盒子&#xff0c;把很多类放里…

NTIRE2023-RTSR-Track2 冠军方案详解

编辑 | Happy 首发 | AIWalker 链接 | https://mp.weixin.qq.com/s/JQ5g9yn_OdjR8hi_tWc4jA arXiv:2305.02126 , cvpr2023 , code , video 本文了一个实时&轻量图像超分方案Bicubic&#xff0c;它通过下采样模块降低图像分辨率以减少计算量&#xff0c;在网络尾部采用…

三分钟使用ngrok实现内网穿透

1.官网注册 官网地址&#xff1a;https://ngrok.com/ tips:若使用邮箱注册自行认证 2.下载对应部署电脑 压缩包&#xff08;此处笔者使用自己电脑因此以Windows11作为案例&#xff09; 解压下载的ngrok压缩包&#xff0c;在对应目录进入命令提示符装口&#xff08;也可直接…

免费api接口:物流api,企业工商查询api,游戏api。。。

免费api接口&#xff0c;物流api,企业工商查询api,游戏api。。。都有。 Facebook Games Services - Facebook Games Services 为游戏开发者提供了各种服务, 包括(但不限于) 成就 API, 分数 API, 应用通知, 请求, 游戏养成和 Facebook SDK for Unity.Google Play Games Service…

Git diff 使用 vimdiff 对比差异

在Ubuntu中使用Git时&#xff0c;可使用命令行的git diff命令来对比两次提交的差异&#xff0c;但是这种对比查看方式无法直观地查看修改的差异&#xff0c;在对比和查看时不太方便。 可以使用vimdiff作为Git diff的对比工具&#xff0c;这样就方便了许多&#xff0c;Git的配置…

TensorFlow 03(Keras)

一、tf.keras tf.keras是TensorFlow 2.0的高阶API接口&#xff0c;为TensorFlow的代码提供了新的风格和设计模式&#xff0c;大大提升了TF代码的简洁性和复用性&#xff0c;官方也推荐使用tf.keras来进行模型设计和开发。 1.1 tf.keras中常用模块 如下表所示: 1.2 常用方法 …

TCP/IP网络江湖——数据链路层的协议与传承(数据链路层中篇:数据链路层的协议与帧)

0、引言 网络江湖,宛如千年武林,承载着代代传承的文化和传统。在这个广袤的江湖之中,数据链路层犹如武林门派,代代传承着网络通信的精华。这一部分将带领我们深入探讨数据链路层的协议与传承,揭示其在网络江湖中的精彩故事。 就如同江湖中的武者需要基本功夫作为修行的基础…

mysql如何实现根据经纬度判断某一个坐标是否在一个多边形区域范围内

要根据经纬度判断一个坐标是否在一个多边形区域内&#xff0c;MySQL提供了几种函数来处理地理空间数据&#xff0c;其中包括用于处理多边形区域的函数。 1.创建一个包含多边形区域的表&#xff1a; 首先&#xff0c;创建一个表来存储多边形区域。可以使用ST_GeomFromText函数将…

kuiper 规则sql写法

创建规则对接收到的报文数据进行业务过滤&#xff0c;报文有各种结构的&#xff0c;下面对各种结构报文sql过滤使用进行说明 下面sql规则统一对temperature大于20的数据进行过滤 1&#xff1a;单层结构报文 {"temperature": 35,"humidity": 66 } sql写…

【Leetcode Sheet】Weekly Practice 6

Leetcode Test 2605 从两个数字数组里生成最小数字(9.5) 给你两个只包含 1 到 9 之间数字的数组 nums1 和 nums2 &#xff0c;每个数组中的元素 互不相同 &#xff0c;请你返回 最小 的数字&#xff0c;两个数组都 至少 包含这个数字的某个数位。 提示&#xff1a; 1 < …

MySQL8--my.cnf配置文件的设置

原文网址&#xff1a;MySQL8--my.cfg配置文件的设置_IT利刃出鞘的博客-CSDN博客 简介 本文介绍MySQL8的my.cnf的配置。 典型配置 [client] default-character-setutf8mb4[mysql] default-character-setutf8mb4[mysqld] #服务端口号 默认3306 port3306datadir /work/docker…

一个FlutterCocoapods项目打包问题集锦

一个Flutter&Cocoapods项目打包问题集锦 问题1 github加速问题 cocoapods项目需要访问https://github.com/CocoaPods/Specs.git&#xff0c;众所周知&#xff0c;github经常被墙&#xff0c;导致经常需要借助加速来下载和访问&#xff0c;这里可以使用油猴脚本或者Fastgi…

kibana报错内存溢出问题解决

一、背景&#xff1a; kibana内存溢出&#xff0c;进程被kill掉&#xff0c;导致前端页面访问不到。 报错内容 二、报错原因&#xff1a; 发现是前端 js 报的内存 oom 异常&#xff0c;通过网上资料发现node.js 的默认内存大小为1.4G Node 中通过 JavaScript 使用内存时只能…

Promethues(五)查询-PromQL 语言-保证易懂好学

文章目录 一、介绍二、PromQL 数据类型三、常量1 字符串2 浮点 四、时间序列选择器 Time series Selectors1 即时矢量&#xff08;Instant vector&#xff09;选择器2 范围矢量选择器2.1 时间长度2.2 偏移修饰符2.3 修饰符 3 避免慢速查询和过载 五、子查询六、操作符 Operato…

【C++】深拷贝和浅拷贝 ② ( 默认拷贝构造函数是浅拷贝 | 代码示例 - 浅拷贝造成的问题 )

文章目录 一、默认拷贝构造函数是浅拷贝1、默认拷贝构造函数2、默认拷贝构造函数是浅拷贝机制 二、代码示例 - 浅拷贝造成的问题 一、默认拷贝构造函数是浅拷贝 1、默认拷贝构造函数 如果 C 类中 没有定义拷贝构造函数 , C 编译器会自动为该类提供一个 " 默认的拷贝构造函…

连接MySQL时报错:Public Key Retrieval is not allowed的解决方法

问题描述&#xff1a; DBeaver 连接 mysql 时报错&#xff1a;Public Key Retrieval is not allowed&#xff08;不允许公钥检索&#xff09; 解决方法&#xff1a; 连接设置 -> 驱动属性 -> allowPublicKeyRetrievalfalse&#xff08;这里的运输公钥检索是默认关闭的&a…