@@ -143,6 +143,8 @@ def _create_cla_action(self, action_type: str, **kwargs) -> Dict[str, Any]:
143143 enter_after = kwargs .get ("enter_after" , False )
144144 )
145145 elif action_type == "scroll" :
146+ x = kwargs .get ("x" , 0 )
147+ y = kwargs .get ("y" , 0 )
146148 # Map direction to scroll amounts
147149 direction = kwargs .get ("direction" , "down" )
148150 dx , dy = 0 , 0
@@ -157,7 +159,7 @@ def _create_cla_action(self, action_type: str, **kwargs) -> Dict[str, Any]:
157159 dx = - magnitude
158160
159161 action = ScrollAction (
160- scroll = Point (x = dx , y = dy )
162+ scroll = Point (x = x + dx , y = y + dy )
161163 )
162164 if "x" in kwargs and "y" in kwargs :
163165 action .point = Point (x = kwargs ["x" ], y = kwargs ["y" ])
@@ -255,7 +257,14 @@ def type_text_at(
255257 def scroll_document (
256258 self , direction : Literal ["up" , "down" , "left" , "right" ]
257259 ) -> EnvState :
258- return self ._execute_action ("scroll" , direction = direction )
260+ if direction == "down" :
261+ return self .key_combination (["PageDown" ])
262+ elif direction == "up" :
263+ return self .key_combination (["PageUp" ])
264+ elif direction in ("left" , "right" ):
265+ return self ._horizontal_document_scroll (direction )
266+ else :
267+ raise ValueError ("Unsupported direction: " , direction )
259268
260269 def scroll_at (
261270 self ,
0 commit comments