Skip to content

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

fix user-data-dir matching

Nick Sweeting7403c33be32d
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 6fe5af1ba..385c2c290 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -86,14 +86,8 @@ jobs:
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}-chromium
- #- run: playwright install chrome # tests that need it can install it manually
- run: playwright install chromium --with-deps
-
- - name: Verify Playwright installation
- run: |
- playwright --version
- ls -la ~/.cache/ms-playwright/ || echo "No playwright cache found"
- find ~/.cache/ms-playwright/ -name "chrome*" -type f 2>/dev/null | head -5 || echo "No chrome binaries found"
+ - run: playwright install chrome --with-deps
- run: pytest tests/ci/${{ matrix.test_filename }}.py
@@ -126,12 +120,7 @@ jobs:
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}-chromium
- run: playwright install chromium --with-deps
-
- - name: Verify Playwright installation
- run: |
- playwright --version
- ls -la ~/.cache/ms-playwright/ || echo "No playwright cache found"
- find ~/.cache/ms-playwright/ -name "chrome*" -type f 2>/dev/null | head -5 || echo "No chrome binaries found"
+ - run: playwright install chrome --with-deps
- name: Run agent tasks evaluation and capture score
id: eval
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 4670e9ac6..c13ad8d5e 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -1681,10 +1681,21 @@ class BrowserSession(BaseModel):
if not self.browser_profile.user_data_dir:
return False
+ # Normalize the path for comparison
+ target_dir = str(Path(self.browser_profile.user_data_dir).expanduser().resolve())
+
# Check for running processes using this user data dir
for proc in psutil.process_iter(['pid', 'cmdline']):
- if f'--user-data-dir={self.browser_profile.user_data_dir}' in (proc.info['cmdline'] or []):
- return True
+ cmdline = proc.info['cmdline'] or []
+
+ # Check both formats: --user-data-dir=/path and --user-data-dir /path
+ for i, arg in enumerate(cmdline):
+ # Combined format: --user-data-dir=/path
+ if arg.startswith('--user-data-dir=') and arg.split('=', 1)[1] == target_dir:
+ return True
+ # Separate format: --user-data-dir /path
+ elif arg == '--user-data-dir' and i + 1 < len(cmdline) and cmdline[i + 1] == target_dir:
+ return True
# Note: We don't consider a SingletonLock file alone as a conflict
# because it might be stale. Only actual running processes count as conflicts.