Skip to content

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

fix: scroll handles left/right directions correctly

ShawnPanab4c874721a33
diff --git a/browser_use/skill_cli/actions.py b/browser_use/skill_cli/actions.py
index 4292d05b3..3bd6ccde5 100644
--- a/browser_use/skill_cli/actions.py
+++ b/browser_use/skill_cli/actions.py
@@ -70,11 +70,14 @@ class ActionHandler:
async def scroll(self, direction: str, amount: int) -> None:
"""Scroll the page using JS (CDP gesture doesn't work in --connect mode)."""
- pixels = amount if direction == 'down' else -amount
+ if direction in ('down', 'up'):
+ x, y = 0, (amount if direction == 'down' else -amount)
+ else:
+ x, y = (amount if direction == 'right' else -amount), 0
cdp_session = await self.bs.get_or_create_cdp_session()
assert cdp_session is not None, 'No CDP session for scroll'
await cdp_session.cdp_client.send.Runtime.evaluate(
- params={'expression': f'window.scrollBy(0, {pixels})', 'awaitPromise': False},
+ params={'expression': f'window.scrollBy({x}, {y})', 'awaitPromise': False},
session_id=cdp_session.session_id,
)