From b72a45d59096212cadb4bea298f3a001af1f0731 Mon Sep 17 00:00:00 2001 From: Jameer Pathan <21165044+jameerpathan111@users.noreply.github.com> Date: Wed, 3 Jan 2024 07:17:14 +0100 Subject: [PATCH] Fix get_downloads_list which is causing save_downloaded_file to fail (#1098) --- airgun/browser.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/airgun/browser.py b/airgun/browser.py index 1fd9a6088..195f7d480 100644 --- a/airgun/browser.py +++ b/airgun/browser.py @@ -6,7 +6,6 @@ from datetime import datetime import logging import os -import time import urllib from urllib.parse import unquote @@ -344,19 +343,12 @@ def get_downloads_list(self): downloads_uri = 'chrome://downloads' if not self.url.startswith(downloads_uri): self.url = downloads_uri - time.sleep(3) script = ( - 'return downloads.Manager.get().items_' - '.filter(e => e.state === "COMPLETE")' - '.map(e => e.file_url || e.fileUrl);' + 'return document.querySelector("downloads-manager")' + '.shadowRoot.querySelector("#downloadsList")' + '.items.filter(e => e.state == "2")' + '.map(e => e.filePath || e.file_path || e.fileUrl || e.file_url);' ) - if self.browser_type == 'chrome': - script = ( - '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);' - ) return self.execute_script(script) def get_file_content(self, uri):