diff --git a/openhands-tools/openhands/tools/browser_use/impl.py b/openhands-tools/openhands/tools/browser_use/impl.py index 9de844c7b..dffb920a9 100644 --- a/openhands-tools/openhands/tools/browser_use/impl.py +++ b/openhands-tools/openhands/tools/browser_use/impl.py @@ -35,11 +35,36 @@ def _check_chromium_available() -> str | None: if path := shutil.which(binary): return path + # Check common Windows installation paths + windows_chrome_paths = [] + env_vars = [ + ("PROGRAMFILES", "C:\\Program Files"), + ("PROGRAMFILES(X86)", "C:\\Program Files (x86)"), + ("LOCALAPPDATA", ""), + ] + windows_browsers = [ + ("Google", "Chrome", "Application", "chrome.exe"), + ("Microsoft", "Edge", "Application", "msedge.exe"), + ] + + for env_var, default in env_vars: + for vendor, browser, app_dir, executable in windows_browsers: + base_path = Path(os.environ.get(env_var, default)) + if base_path: + windows_chrome_paths.append( + base_path / vendor / browser / app_dir / executable + ) + 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 + Path(os.environ.get("LOCALAPPDATA", "")) / "ms-playwright", # Windows ] + for playwright_cache in playwright_cache_candidates: if playwright_cache.exists(): chromium_dirs = list(playwright_cache.glob("chromium-*"))