Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix(browser): return Path from validate_user_data_dir when creating temp dir

itxaiohangloverf2c871effb4d
diff --git a/browser_use/browser/profile.py b/browser_use/browser/profile.py
index eda73dfcf..4b5e4a9bb 100644
--- a/browser_use/browser/profile.py
+++ b/browser_use/browser/profile.py
@@ -550,7 +550,7 @@ class BrowserLaunchPersistentContextArgs(BrowserLaunchArgs, BrowserContextArgs):
def validate_user_data_dir(cls, v: str | Path | None) -> str | Path:
"""Validate user data dir is set to a non-default path."""
if v is None:
- return tempfile.mkdtemp(prefix='browser-use-user-data-dir-')
+ return Path(tempfile.mkdtemp(prefix='browser-use-user-data-dir-'))
return Path(v).expanduser().resolve()