Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Numpy-lock and fix small bug with Chrome waiting for downloads #115

Merged
merged 6 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion botcity/web/browsers/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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://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);
""")
4 changes: 3 additions & 1 deletion botcity/web/browsers/undetected_chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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);
""")
Empty file removed botcity/web/tests/__init__.py
Empty file.
3 changes: 0 additions & 3 deletions botcity/web/tests/test_import.py

This file was deleted.

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
botcity-framework-base>=0.2.2
beautifulsoup4
numpy<2
numpy
opencv-python
pillow
selenium>=4.10,<5
undetected-chromedriver
packaging
packaging
2 changes: 1 addition & 1 deletion tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Loading