Selenium 如何使用chromedriver禁用所有chrome扩展

Selenium 如何使用chromedriver禁用所有chrome扩展,selenium,selenium-chromedriver,chrome-automation-extension,Selenium,Selenium Chromedriver,Chrome Automation Extension,升级到chromedriver 74后,Windows上出现了奇怪的扩展行为。 是否可以关闭所有分机 启动色度驱动器 chromedriver--log level=ALL 创建禁用扩展的会话 curl-d'{“desiredCapabilities”:{“browserName”:“chrome”,“goog:chromeOptions”:{“args”:[“--disable extensions”]}}http://localhost:9515/session 加载了一些开发工具扩展

升级到chromedriver 74后,Windows上出现了奇怪的扩展行为。 是否可以关闭所有分机

  • 启动色度驱动器
  • chromedriver--log level=ALL
    
  • 创建禁用扩展的会话
  • curl-d'{“desiredCapabilities”:{“browserName”:“chrome”,“goog:chromeOptions”:{“args”:[“--disable extensions”]}}http://localhost:9515/session
    
    加载了一些开发工具扩展

    [1558606783.990][INFO]:启动chrome:“C:\Program Files(x86)\Google\chrome\Application\chrome.exe”--禁用后台网络--禁用客户端网络钓鱼检测--禁用默认应用--禁用扩展--禁用扩展,除非=“C:\Users\user\AppData\Local\Temp\scoped\u dir19964\u 411\internal”--禁用挂起监视器--禁用弹出窗口阻止--禁用重新发布提示--禁用同步--禁用web资源--启用自动化--启用闪烁功能=ShadowDOMV0--启用日志--强制fieldtrials=SiteIsolationExtensions/控制--忽略证书错误--日志级别=0--无首次运行--密码存储=基本--远程调试端口=0--测试类型=webdriver--使用模拟密钥链--user data dir=“C:\Users\user\AppData\Local\Temp\scoped\u dir19964\u 22650”数据:

    --禁用扩展,除非=“C:\Users\user\AppData\Local\Temp\scoped\u dir19964\u 411\internal”

    有办法摆脱它吗?在chromedriver文档中没有发现任何线索,这些都非常粗略

    TL;博士 将chromeOptions设置为false。使用AutomationExtension将阻止注入Chrome Automation Extension

    {
      "desiredCapabilities": {
        "browserName": "chrome",
        "goog:chromeOptions": {
          "useAutomationExtension": false,
          "args": [
            "--disable-extensions"
          ]
        }
      }
    }
    
    长版本 chromedriver文档中未提及自动化扩展标志,但可在当前版本(75.0)中进行跟踪

    正如Java代码中提到的,使用selenium驱动程序

    ChromeOptions选项=新的ChromeOptions();
    options.setExperimentalOption(“useAutomationExtension”,false);
    
    有一种方法可以愚弄chromedriver—传递一些其他参数以及--disable extensions(用空格分隔),例如,简单地重复--disable extensions--disable extensions。它可以工作,但有点难看。事实证明它不是什么新东西-在chromedriver 2.36中发现了与chromedriver v2.28相同的问题-
        parser_map["useAutomationExtension"] =
            base::Bind(&ParseBoolean, &capabilities->use_automation_extension);
    
        status = internal::ProcessExtensions(
            capabilities.extensions, extension_dir->GetPath(),
            capabilities.use_automation_extension, &switches, extension_bg_pages);
    
      if (include_automation_extension) {
        ...
        if (switches->HasSwitch("disable-extensions")) {
          UpdateExtensionSwitch(switches, "disable-extensions-except",
                                automation_extension.value());