Skip to content

Commit 15f5700

Browse files
committed
FIX: Update Chrome check for download finished.
1 parent 963012c commit 15f5700

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

botcity/web/browsers/chrome.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@ def wait_for_downloads(driver):
132132
"""
133133
if not driver.current_url.startswith("chrome://downloads"):
134134
driver.get("chrome://downloads/")
135+
# Chrome changed the `e.state` from a ENUM Str to numbers. Here 2 means COMPLETE.
136+
# Reference: https://github.com/chromium/chromium/blob/b34b8f13054dca8440d2dac0b1b5bae1dc5685d4/chrome/browser/ui/webui/downloads/downloads.mojom#L60
135137
return driver.execute_script("""
136138
var items = document.querySelector('downloads-manager')
137139
.shadowRoot.getElementById('downloadsList').items;
138-
if (items.every(e => e.state === "COMPLETE"))
140+
if (items.every(e => e.state === 2))
139141
return items.map(e => e.fileUrl || e.file_url);
140142
""")

0 commit comments

Comments
 (0)