Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Fix scroll test
Magnus Müller1d3adc9e885d
diff --git a/tests/ci/test_browser_event_ScrollEvent.py b/tests/ci/test_browser_event_ScrollEvent.pyindex 10c8a2631..b716969ca 100644--- a/tests/ci/test_browser_event_ScrollEvent.py+++ b/tests/ci/test_browser_event_ScrollEvent.py@@ -154,24 +154,6 @@ class TestScrollActions:result = await asyncio.wait_for(event, timeout=3.0)assert result is not None- async def test_scroll_event_directly(self, browser_session):- """Test ScrollEvent directly through the event bus."""- from browser_use.browser.events import ScrollEvent-- # Test scroll on about:blank (should work)- event = browser_session.event_bus.dispatch(ScrollEvent(direction='down', amount=100))- result = await asyncio.wait_for(event, timeout=2.0)- try:- event_result = await result.event_result()- # ScrollEvent may return different data format, just check it doesn't crash- assert True # If we get here without exception, the event was handled- except ValueError as e:- if 'Expected at least one handler to return a non-None result' in str(e):- # ScrollEvent handler may return None, which is acceptable for scroll operations- assert True # Event was dispatched and handled, even if no explicit result- else:- raise-async def test_scroll_non_scrollable_page(self, browser_session, base_url, http_server):"""Test scrolling a page that's only 100px tall (not scrollable)."""from browser_use.browser.events import ScrollEvent@@ -210,11 +192,9 @@ class TestScrollActions:# Try to scroll down - should succeed but not actually moveevent = browser_session.event_bus.dispatch(ScrollEvent(direction='down', amount=500))- result = await asyncio.wait_for(event, timeout=3.0)- event_result = await result.event_result()- assert event_result is not None- # ScrollEvent may return different data format- assert event_result is not None+ await event+ result = await event.event_result(raise_if_any=True, raise_if_none=False)+ assert result is None# Check scroll position didn't change (page isn't scrollable)final_scroll = await browser_session.cdp_client.send.Runtime.evaluate(@@ -272,11 +252,9 @@ class TestScrollActions:# Scroll down by 8000pxevent = browser_session.event_bus.dispatch(ScrollEvent(direction='down', amount=8000))- result = await asyncio.wait_for(event, timeout=3.0)- event_result = await result.event_result()- assert event_result is not None- # ScrollEvent may return different data format- assert event_result is not None+ await event+ result = await event.event_result(raise_if_any=True, raise_if_none=False)+ assert result is None # ScrollEvent does not return a result# Wait a bit for scroll to take effectawait asyncio.sleep(0.5)diff --git a/tests/ci/test_browser_watchdog_crash.py b/tests/ci/test_browser_watchdog_crash.pyindex 3831717e1..9132b78e6 100644--- a/tests/ci/test_browser_watchdog_crash.py+++ b/tests/ci/test_browser_watchdog_crash.py@@ -19,9 +19,9 @@ from browser_use.utils import logger@pytest.mark.asyncio[email protected]('CrashWatchdog not implemented in current CDP architecture')async def test_crash_watchdog_network_timeout():"""Test that CrashWatchdog detects network timeouts by monitoring actual network requests."""- pytest.skip('CrashWatchdog not implemented in current CDP architecture')# Create browser sessionprofile = BrowserProfile(headless=True)@@ -84,6 +84,7 @@ async def test_crash_watchdog_network_timeout():@pytest.mark.asyncio[email protected]('CrashWatchdog not implemented in current CDP architecture')async def test_crash_watchdog_browser_disconnect():"""Test that CrashWatchdog detects browser disconnection through monitoring."""profile = BrowserProfile(headless=True)@@ -91,7 +92,10 @@ async def test_crash_watchdog_browser_disconnect():try:# Start browser- session.event_bus.dispatch(BrowserStartEvent())+ start_event = session.event_bus.dispatch(BrowserStartEvent())+ await start_event+ # Ensure any exceptions from the event handler are propagated+ await start_event.event_result(raise_if_any=True, raise_if_none=False)# Wait for browser to be fully startedawait session.event_bus.expect(BrowserConnectedEvent, timeout=5.0)@@ -131,6 +135,7 @@ async def test_crash_watchdog_browser_disconnect():@pytest.mark.asyncio[email protected]('CrashWatchdog not implemented in current CDP architecture')async def test_crash_watchdog_lifecycle():"""Test that CrashWatchdog starts and stops with browser session."""profile = BrowserProfile(headless=True)