Skip to content

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

fix browser_session tests

Nick Sweetingdcfc6a4c8e36
diff --git a/tests/test_browser_session.py b/tests/test_browser_session.py
index d1229561f..9df55b82d 100644
--- a/tests/test_browser_session.py
+++ b/tests/test_browser_session.py
@@ -85,7 +85,8 @@ class TestBrowserContext:
assert context1._is_url_allowed('https://anotherdomain.org/path') is True
# Scenario 2: allowed_domains is provided.
- allowed = ['example.com', '*.mysite.org']
+ # Note: match_url_with_domain_pattern defaults to https:// scheme when none is specified
+ allowed = ['https://example.com', 'http://example.com', 'http://*.mysite.org', 'https://*.mysite.org']
config2 = BrowserProfile(allowed_domains=allowed)
context2 = BrowserSession(browser_profile=config2)
@@ -93,7 +94,7 @@ class TestBrowserContext:
assert context2._is_url_allowed('http://example.com') is True
# URL with subdomain (should not be allowed)
assert context2._is_url_allowed('http://sub.example.com/path') is False
- # URL with different domain (should not be allowed)
+ # URL with subdomain for wildcard pattern (should be allowed)
assert context2._is_url_allowed('http://sub.mysite.org') is True
# URL that matches second allowed domain
assert context2._is_url_allowed('https://mysite.org/page') is True