From 969c50f5905b912552561208a4e9e83aa3db2b54 Mon Sep 17 00:00:00 2001 From: Hugo Slepicka Date: Thu, 9 Jan 2025 17:21:00 -0800 Subject: [PATCH 1/6] BLD: Remove constrain on numpy<2. --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 9b161ce..06838e7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ botcity-framework-base>=0.2.2 beautifulsoup4 -numpy<2 +numpy opencv-python pillow selenium>=4.10,<5 undetected-chromedriver -packaging \ No newline at end of file +packaging From 963012c89ad46ddfe60793562f612f998a251a8a Mon Sep 17 00:00:00 2001 From: Hugo Slepicka Date: Thu, 9 Jan 2025 17:21:27 -0800 Subject: [PATCH 2/6] MNT: Remove tests from inside the package which were old. --- botcity/web/tests/__init__.py | 0 botcity/web/tests/test_import.py | 3 --- 2 files changed, 3 deletions(-) delete mode 100644 botcity/web/tests/__init__.py delete mode 100644 botcity/web/tests/test_import.py diff --git a/botcity/web/tests/__init__.py b/botcity/web/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/botcity/web/tests/test_import.py b/botcity/web/tests/test_import.py deleted file mode 100644 index 1d13474..0000000 --- a/botcity/web/tests/test_import.py +++ /dev/null @@ -1,3 +0,0 @@ -def test_package_import(): - import botcity.web as web - assert web.__file__ != "" From 15f57000b21ccc869547e5bd68d31eddc0ab3507 Mon Sep 17 00:00:00 2001 From: Hugo Slepicka Date: Thu, 9 Jan 2025 17:32:47 -0800 Subject: [PATCH 3/6] FIX: Update Chrome check for download finished. --- botcity/web/browsers/chrome.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/botcity/web/browsers/chrome.py b/botcity/web/browsers/chrome.py index 1782533..8a79bc8 100644 --- a/botcity/web/browsers/chrome.py +++ b/botcity/web/browsers/chrome.py @@ -132,9 +132,11 @@ def wait_for_downloads(driver): """ if not driver.current_url.startswith("chrome://downloads"): driver.get("chrome://downloads/") + # Chrome changed the `e.state` from a ENUM Str to numbers. Here 2 means COMPLETE. + # Reference: https://github.com/chromium/chromium/blob/b34b8f13054dca8440d2dac0b1b5bae1dc5685d4/chrome/browser/ui/webui/downloads/downloads.mojom#L60 return driver.execute_script(""" var items = document.querySelector('downloads-manager') .shadowRoot.getElementById('downloadsList').items; - if (items.every(e => e.state === "COMPLETE")) + if (items.every(e => e.state === 2)) return items.map(e => e.fileUrl || e.file_url); """) From a2f5aafd44282d81083845b428c5ad0393475959 Mon Sep 17 00:00:00 2001 From: Hugo Slepicka Date: Thu, 9 Jan 2025 17:33:25 -0800 Subject: [PATCH 4/6] TST: Add local MacOS resolution to list of possible results. --- tests/test_browser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_browser.py b/tests/test_browser.py index b95512b..e65d218 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -215,7 +215,7 @@ def test_get_view_port_size(web: WebBot): element = [width, height] else: element = web.find_element('window-size', By.ID).text.split('x') - sizes = [tuple(int(e) for e in element), (1600, 900), (1176, 802)] + sizes = [tuple(int(e) for e in element), (1600, 900), (1176, 802), (1600, 987)] assert size in sizes From acefc09830d7cd38191203c7a3126d9c8db92dee Mon Sep 17 00:00:00 2001 From: Hugo Slepicka Date: Thu, 9 Jan 2025 17:39:30 -0800 Subject: [PATCH 5/6] STY: Address flake8 issue. --- botcity/web/browsers/chrome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/botcity/web/browsers/chrome.py b/botcity/web/browsers/chrome.py index 8a79bc8..bf24877 100644 --- a/botcity/web/browsers/chrome.py +++ b/botcity/web/browsers/chrome.py @@ -133,7 +133,7 @@ def wait_for_downloads(driver): if not driver.current_url.startswith("chrome://downloads"): driver.get("chrome://downloads/") # Chrome changed the `e.state` from a ENUM Str to numbers. Here 2 means COMPLETE. - # Reference: https://github.com/chromium/chromium/blob/b34b8f13054dca8440d2dac0b1b5bae1dc5685d4/chrome/browser/ui/webui/downloads/downloads.mojom#L60 + # Reference: https://shorturl.at/G4EES return driver.execute_script(""" var items = document.querySelector('downloads-manager') .shadowRoot.getElementById('downloadsList').items; From 6a7152adc2987d815e0948ac9b56206ba992c43c Mon Sep 17 00:00:00 2001 From: Hugo Slepicka Date: Thu, 9 Jan 2025 17:39:43 -0800 Subject: [PATCH 6/6] FIX: Update Undetected Chrome check for download finished. --- botcity/web/browsers/undetected_chrome.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/botcity/web/browsers/undetected_chrome.py b/botcity/web/browsers/undetected_chrome.py index c06947f..0b2c359 100644 --- a/botcity/web/browsers/undetected_chrome.py +++ b/botcity/web/browsers/undetected_chrome.py @@ -138,9 +138,11 @@ def wait_for_downloads(driver): """ if not driver.current_url.startswith("chrome://downloads"): driver.get("chrome://downloads/") + # Chrome changed the `e.state` from a ENUM Str to numbers. Here 2 means COMPLETE. + # Reference: https://shorturl.at/G4EES return driver.execute_script(""" var items = document.querySelector('downloads-manager') .shadowRoot.getElementById('downloadsList').items; - if (items.every(e => e.state === "COMPLETE")) + if (items.every(e => e.state === 2)) return items.map(e => e.fileUrl || e.file_url); """)