无法在 Chrome 80 中获取下载的项目

Lon*_*yen 1 google-chrome selenium-webdriver

在 Chrome 80 (79.0.3945.130) 之前,您可以通过访问chrome://downloads/来获取 Chrome 中所有下载的项目,并从全局变量 中获取下载的项目downloads

var items = downloads.Manager.get().items_;
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

但似乎自版本 80 以来,Google 已经隐藏了变量Manager的属性downloads,因此我无法再获取下载的项目。

在此输入图像描述

如果您能告诉我有关获取下载项目的新方法的任何想法,我将不胜感激。(弓)

Ita*_*evy 5

return document.querySelector('downloads-manager')
  .shadowRoot.querySelector('#downloadsList')
  .items.filter(e => e.state === 'COMPLETE')
  .map(e => e.filePath || e.file_path || e.fileUrl || e.file_url);
Run Code Online (Sandbox Code Playgroud)

  • self.driver.execute_script("返回 document.querySelector('downloads-manager').shadowRoot.querySelector('#downloadsList').items.filter(e => e.state === 'COMPLETE').map(e => e.filePath || e.file_path || e.fileUrl || e.file_url);") (2认同)