Skip to content

Commit

Permalink
Fix get_downloads_list which is causing save_downloaded_file to fail (#…
Browse files Browse the repository at this point in the history
…1098) (#1101)

(cherry picked from commit b72a45d)

Co-authored-by: Jameer Pathan <[email protected]>
  • Loading branch information
Satellite-QE and jameerpathan111 authored Jan 4, 2024
1 parent 04d3a4c commit af7204f
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions airgun/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from datetime import datetime
import logging
import os
import time
import urllib
from urllib.parse import unquote

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit af7204f

Please sign in to comment.