From c2b68cdce7e3e613768eaa457cb2f2ab9645f9b0 Mon Sep 17 00:00:00 2001 From: openhands Date: Tue, 4 Nov 2025 14:55:34 +0530 Subject: [PATCH 1/3] Add Windows browser path checks to Chromium detection Enhanced _check_chromium_available to check common Windows installation paths for Chrome and Edge executables. Also added support for Playwright cache detection on Windows using LOCALAPPDATA. --- .../openhands/tools/browser_use/impl.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/openhands-tools/openhands/tools/browser_use/impl.py b/openhands-tools/openhands/tools/browser_use/impl.py index cbe6aebf1b..71377a7309 100644 --- a/openhands-tools/openhands/tools/browser_use/impl.py +++ b/openhands-tools/openhands/tools/browser_use/impl.py @@ -35,11 +35,27 @@ def _check_chromium_available() -> str | None: if path := shutil.which(binary): return path + # Check common Windows installation paths + if os.name == "nt": + windows_chrome_paths = [ + Path(os.environ.get("PROGRAMFILES", "C:\\Program Files")) / "Google" / "Chrome" / "Application" / "chrome.exe", + Path(os.environ.get("PROGRAMFILES(X86)", "C:\\Program Files (x86)")) / "Google" / "Chrome" / "Application" / "chrome.exe", + Path(os.environ.get("LOCALAPPDATA", "")) / "Google" / "Chrome" / "Application" / "chrome.exe", + Path(os.environ.get("PROGRAMFILES", "C:\\Program Files")) / "Microsoft" / "Edge" / "Application" / "msedge.exe", + Path(os.environ.get("PROGRAMFILES(X86)", "C:\\Program Files (x86)")) / "Microsoft" / "Edge" / "Application" / "msedge.exe", + ] + for chrome_path in windows_chrome_paths: + if chrome_path.exists(): + return str(chrome_path) + # Check Playwright-installed Chromium playwright_cache_candidates = [ - Path.home() / ".cache" / "ms-playwright", - Path.home() / "Library" / "Caches" / "ms-playwright", + Path.home() / ".cache" / "ms-playwright", # Linux + Path.home() / "Library" / "Caches" / "ms-playwright", # macOS ] + if os.name == "nt" and os.environ.get("LOCALAPPDATA"): + playwright_cache_candidates.append(Path(os.environ["LOCALAPPDATA"]) / "ms-playwright") + for playwright_cache in playwright_cache_candidates: if playwright_cache.exists(): chromium_dirs = list(playwright_cache.glob("chromium-*")) From 87938d3b97b920e569b56ef506df93ae0d341902 Mon Sep 17 00:00:00 2001 From: openhands Date: Thu, 6 Nov 2025 10:22:31 +0530 Subject: [PATCH 2/3] format --- .../openhands/tools/browser_use/impl.py | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/openhands-tools/openhands/tools/browser_use/impl.py b/openhands-tools/openhands/tools/browser_use/impl.py index d2d37035aa..3ca35d0fcf 100644 --- a/openhands-tools/openhands/tools/browser_use/impl.py +++ b/openhands-tools/openhands/tools/browser_use/impl.py @@ -38,11 +38,31 @@ def _check_chromium_available() -> str | None: # Check common Windows installation paths if os.name == "nt": windows_chrome_paths = [ - Path(os.environ.get("PROGRAMFILES", "C:\\Program Files")) / "Google" / "Chrome" / "Application" / "chrome.exe", - Path(os.environ.get("PROGRAMFILES(X86)", "C:\\Program Files (x86)")) / "Google" / "Chrome" / "Application" / "chrome.exe", - Path(os.environ.get("LOCALAPPDATA", "")) / "Google" / "Chrome" / "Application" / "chrome.exe", - Path(os.environ.get("PROGRAMFILES", "C:\\Program Files")) / "Microsoft" / "Edge" / "Application" / "msedge.exe", - Path(os.environ.get("PROGRAMFILES(X86)", "C:\\Program Files (x86)")) / "Microsoft" / "Edge" / "Application" / "msedge.exe", + Path(os.environ.get("PROGRAMFILES", "C:\\Program Files")) + / "Google" + / "Chrome" + / "Application" + / "chrome.exe", + Path(os.environ.get("PROGRAMFILES(X86)", "C:\\Program Files (x86)")) + / "Google" + / "Chrome" + / "Application" + / "chrome.exe", + Path(os.environ.get("LOCALAPPDATA", "")) + / "Google" + / "Chrome" + / "Application" + / "chrome.exe", + Path(os.environ.get("PROGRAMFILES", "C:\\Program Files")) + / "Microsoft" + / "Edge" + / "Application" + / "msedge.exe", + Path(os.environ.get("PROGRAMFILES(X86)", "C:\\Program Files (x86)")) + / "Microsoft" + / "Edge" + / "Application" + / "msedge.exe", ] for chrome_path in windows_chrome_paths: if chrome_path.exists(): @@ -54,8 +74,10 @@ def _check_chromium_available() -> str | None: Path.home() / "Library" / "Caches" / "ms-playwright", # macOS ] if os.name == "nt" and os.environ.get("LOCALAPPDATA"): - playwright_cache_candidates.append(Path(os.environ["LOCALAPPDATA"]) / "ms-playwright") - + playwright_cache_candidates.append( + Path(os.environ["LOCALAPPDATA"]) / "ms-playwright" + ) + for playwright_cache in playwright_cache_candidates: if playwright_cache.exists(): chromium_dirs = list(playwright_cache.glob("chromium-*")) From 87718f51cf713de39494f7e2183ceb13e928a003 Mon Sep 17 00:00:00 2001 From: openhands Date: Fri, 7 Nov 2025 03:27:11 +0530 Subject: [PATCH 3/3] Refactor Windows Chromium path checks in impl.py Removed redundant os.name check and always define Windows Chromium and Edge paths. Simplified Playwright cache candidate logic by unconditionally including the Windows path. --- .../openhands/tools/browser_use/impl.py | 66 +++++++++---------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/openhands-tools/openhands/tools/browser_use/impl.py b/openhands-tools/openhands/tools/browser_use/impl.py index 3ca35d0fcf..5969d8a8c1 100644 --- a/openhands-tools/openhands/tools/browser_use/impl.py +++ b/openhands-tools/openhands/tools/browser_use/impl.py @@ -36,47 +36,43 @@ def _check_chromium_available() -> str | None: return path # Check common Windows installation paths - if os.name == "nt": - windows_chrome_paths = [ - Path(os.environ.get("PROGRAMFILES", "C:\\Program Files")) - / "Google" - / "Chrome" - / "Application" - / "chrome.exe", - Path(os.environ.get("PROGRAMFILES(X86)", "C:\\Program Files (x86)")) - / "Google" - / "Chrome" - / "Application" - / "chrome.exe", - Path(os.environ.get("LOCALAPPDATA", "")) - / "Google" - / "Chrome" - / "Application" - / "chrome.exe", - Path(os.environ.get("PROGRAMFILES", "C:\\Program Files")) - / "Microsoft" - / "Edge" - / "Application" - / "msedge.exe", - Path(os.environ.get("PROGRAMFILES(X86)", "C:\\Program Files (x86)")) - / "Microsoft" - / "Edge" - / "Application" - / "msedge.exe", - ] - for chrome_path in windows_chrome_paths: - if chrome_path.exists(): - return str(chrome_path) + windows_chrome_paths = [ + Path(os.environ.get("PROGRAMFILES", "C:\\Program Files")) + / "Google" + / "Chrome" + / "Application" + / "chrome.exe", + Path(os.environ.get("PROGRAMFILES(X86)", "C:\\Program Files (x86)")) + / "Google" + / "Chrome" + / "Application" + / "chrome.exe", + Path(os.environ.get("LOCALAPPDATA", "")) + / "Google" + / "Chrome" + / "Application" + / "chrome.exe", + Path(os.environ.get("PROGRAMFILES", "C:\\Program Files")) + / "Microsoft" + / "Edge" + / "Application" + / "msedge.exe", + Path(os.environ.get("PROGRAMFILES(X86)", "C:\\Program Files (x86)")) + / "Microsoft" + / "Edge" + / "Application" + / "msedge.exe", + ] + for chrome_path in windows_chrome_paths: + if chrome_path.exists(): + return str(chrome_path) # Check Playwright-installed Chromium playwright_cache_candidates = [ Path.home() / ".cache" / "ms-playwright", # Linux Path.home() / "Library" / "Caches" / "ms-playwright", # macOS + Path(os.environ.get("LOCALAPPDATA", "")) / "ms-playwright", # Windows ] - if os.name == "nt" and os.environ.get("LOCALAPPDATA"): - playwright_cache_candidates.append( - Path(os.environ["LOCALAPPDATA"]) / "ms-playwright" - ) for playwright_cache in playwright_cache_candidates: if playwright_cache.exists():