我注意到,当通过 selenium chromedriver 使用新的用户数据目录启动 chrome 时,它使用的资源(cpu、内存和磁盘)比正常启动时要少得多。
我能够找到的原因之一是 selenium chromedriver 启动时带有以下参数:
--disable-background-networking
--disable-client-side-phishing-detection
--disable-default-apps
--disable-hang-monitor
--disable-popup-blocking
--disable-prompt-on-repost
--disable-sync
--disable-web-resources
--enable-automation
--enable-logging
--force-fieldtrials=SiteIsolationExtensions/Control
--ignore-certificate-errors
--log-level=0
--metrics-recording-only
--no-first-run
--password-store=basic
--test-type=webdriver
--use-mock-keychain
应用这些参数后,CPU、内存和磁盘使用率大幅下降。然而,磁盘使用率仍然高出约 10 倍。使用 Windows 资源监视器,我分析了 I/O 使用情况,发现有大量写入 chrome_url_fetcher 目录和另一个目录,其中包含两个由下划线分隔的随机 5 位数字; RANDOMNUMBER_RANDOMNUMBER。这两个目录都位于 %temp% 文件夹中,并且包含名称中包含“pepperflashplayer”的文件。
我假设这是chrome为pepperflash安装了必要的组件,但为什么selenium chromedriver不是这种情况?我有什么办法可以阻止这一切吗?
The Selenium https://stackoverflow.com/questions/54459701/what-is-selenium-and-what-is-webdriver/54482491#54482491 driven Chrome驱动程序 https://stackoverflow.com/questions/48079120/what-is-the-difference-between-chromedriver-and-webdriver-in-selenium/48080871#48080871发起谷歌浏览器 /questions/tagged/google-chrome v87.0.4280.88浏览上下文是用这些附加的启动的命令行开关 https://peter.sh/experiments/chromium-command-line-switches/:
-
--disable-background-networking
:禁用在后台运行网络请求的多个子系统。
-
--disable-client-side-phishing-detection
:禁用客户端钓鱼检测功能。
-
--disable-default-apps
:首次运行时禁用默认应用程序的安装。这在自动化测试期间使用。
-
--disable-hang-monitor
:禁止渲染器进程中挂起监视器对话框。
-
--disable-popup-blocking
:禁用弹出窗口阻止。
-
--disable-prompt-on-repost
:此开关可用于禁用检查用户是否尝试导航到帖子结果的页面。
-
--disable-sync
:禁用将浏览器数据同步到 Google 帐户。
-
--enable-automation
:启用浏览器由自动化控制的指示。
-
--enable-blink-features=ShadowDOMV0
:启用一项或多项支持 Blink 运行时的功能。
-
--enable-logging
:控制是否启用控制台日志记录并可选择配置其路由位置。
-
--log-level=0
:设置最低日志级别。
-
--no-first-run
:跳过首次运行任务,无论它是否实际上是首次运行。
-
--no-service-autorun
:禁止服务进程将自身添加为自动运行进程。
-
--password-store=basic
:指定使用哪个加密存储后端。
-
--remote-debugging-port=0
:在指定端口上启用通过 HTTP 的远程调试。
-
--test-type=webdriver
:当前测试工具的类型(“浏览器”或“ui”或“webdriver”)。
--use-mock-keychain
-
--user-data-dir="C:\Users\username\AppData\Local\Temp\scoped_dir9640_113432031
:浏览器存储用户配置文件的目录。
data:,
这些附加命令行开关的使用使得初始化谷歌浏览器工艺要求较少回调以及禁用更多回调 https://www.w3schools.com/js/js_callback.asp
除此之外,Flash常规 chrome 会话使用的是:
32.0.0.465 C:\Users\username\AppData\Local\Google\Chrome\User Data\PepperFlash\32.0.0.465\pepflashplayer.dll
然而,Flash所使用的Chrome驱动程序启动的 Chrome 会话是:
30.0.0.154 C:\WINDOWS\system32\Macromed\Flash\pepflashplayer64_30_0_0_154.dll
由于上述原因Chrome驱动程序 https://stackoverflow.com/questions/59909654/how-does-chrome-driver-interact-with-chrome-browser/59927747#59927747发起谷歌浏览器比常规的更轻,消耗的内存更少谷歌浏览器.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)