Skip to content

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

fix pytest assert

Nick Sweeting54a62b5cff88
diff --git a/tests/test_browser.py b/tests/test_browser.py
index 9d3874a17..3525387ba 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -11,7 +11,9 @@ async def test_connection_via_cdp(monkeypatch):
)
with pytest.raises(Exception) as e:
await browser_session.start()
- assert 'Failed to connect to browser' in str(e)
+
+ # Assert on the exception value outside the context manager
+ assert 'Failed to connect to browser' in str(e.value)
playwright = await async_playwright().start()
browser = await playwright.chromium.launch(args=['--remote-debugging-port=9222'])