Skip to content

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

make sure cookies_path is always resolved

Nick Sweetingedeab395ed4c
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 8ee7078e5..d872152a0 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -1514,9 +1514,9 @@ class BrowserSession(BaseModel):
'See: https://playwright.dev/python/docs/api/class-browsercontext#browser-context-storage-state'
)
- cookies_path = Path(self.browser_profile.cookies_file)
+ cookies_path = Path(self.browser_profile.cookies_file).expanduser().resolve()
if not cookies_path.is_absolute():
- cookies_path = Path(self.browser_profile.downloads_path or '.') / cookies_path
+ cookies_path = Path(self.browser_profile.downloads_path or '.').expanduser().resolve() / cookies_path.name
try:
cookies_data = json.loads(cookies_path.read_text())