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
Enhances scroll action testing
Daniel T.eb7c7fa2bcca
diff --git a/browser_use/controller/views.py b/browser_use/controller/views.pyindex d1d9152b7..9929b3061 100644--- a/browser_use/controller/views.py+++ b/browser_use/controller/views.py@@ -46,7 +46,7 @@ class CloseTabAction(BaseModel):class ScrollAction(BaseModel):down: bool # True to scroll down, False to scroll up- amount: int | None = Field(None, description='Number of pixels to scroll. If None, defaults to one page height')+ amount: int | None = None # Number of pixels to scroll. If None, defaults to one page heightclass SendKeysAction(BaseModel):diff --git a/tests/ci/test_controller.py b/tests/ci/test_controller.pyindex e77a35dd0..1a5d92606 100644--- a/tests/ci/test_controller.py+++ b/tests/ci/test_controller.py@@ -130,7 +130,7 @@ class TestControllerIntegration:await controller.act(GoToUrlActionModel(**goto_action), browser_session)- # Create scroll down action+ # Test 1: Default scroll down (no amount specified)scroll_action = {'scroll': ScrollAction(down=True)}class ScrollActionModel(ActionModel):@@ -144,8 +144,8 @@ class TestControllerIntegration:assert result.extracted_content is not Noneassert 'Scrolled down' in result.extracted_content- # Create scroll up action- scroll_up_action = {'scroll': ScrollAction(down=False)}+ # Test 2: Custom scroll amount up+ scroll_up_action = {'scroll': ScrollAction(down=False, amount=250)}class ScrollUpActionModel(ActionModel):scroll: ScrollAction | None = None@@ -157,6 +157,22 @@ class TestControllerIntegration:assert isinstance(result, ActionResult)assert result.extracted_content is not Noneassert 'Scrolled up' in result.extracted_content+ assert '250 pixels' in result.extracted_content++ # Test 3: Custom scroll amount down+ scroll_custom_action = {'scroll': ScrollAction(down=True, amount=500)}++ class ScrollCustomActionModel(ActionModel):+ scroll: ScrollAction | None = None++ # Execute custom scroll down+ result = await controller.act(ScrollCustomActionModel(**scroll_custom_action), browser_session)++ # Verify the result+ assert isinstance(result, ActionResult)+ assert result.extracted_content is not None+ assert 'Scrolled down' in result.extracted_content+ assert '500 pixels' in result.extracted_contentasync def test_registry_actions(self, controller, browser_session):"""Test that the registry contains the expected default actions."""