Skip to content

Commit e59713d

Browse files
committed
fixed the bug in the amount of scroll schema while scrolling inside the container
1 parent fccf850 commit e59713d

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/agent/web/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ async def action(self,state:AgentState):
130130
'informative_elements':browser_state.dom_state.informative_elements_to_string(),
131131
'scrollable_elements':browser_state.dom_state.scrollable_elements_to_string()
132132
})
133-
print(browser_state.dom_state.scrollable_nodes)
134133
messages=[AIMessage(action_prompt),ImageMessage(text=observation_prompt,image_obj=image_obj) if self.use_vision and image_obj is not None else HumanMessage(observation_prompt)]
135134
return {**state,'messages':messages,'prev_observation':observation}
136135

src/agent/web/tools/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ async def scroll_tool(direction:Literal['up','down']='up',index:int=None,amount:
5656
page=await context.get_current_page()
5757
if index is not None:
5858
element=await context.get_element_by_index(index=index)
59-
handle=await context.get_handle_by_xpath(element.xpath)
60-
frame=await context.get_frame_by_xpath(element.xpath)
59+
handle=await context.get_handle_by_xpath(xpath=element.xpath)
60+
frame=await context.get_frame_by_xpath(xpath=element.xpath)
6161
if direction=='up':
62-
await frame.evaluate(f'element=> element.scrollBy(0,-{amount})', handle)
62+
await frame.evaluate(f'(element)=> element.scrollBy(0,{-amount})', handle)
6363
elif direction=='down':
64-
await frame.evaluate(f'element=> element.scrollBy(0,{amount})', handle)
64+
await frame.evaluate(f'(element)=> element.scrollBy(0,{amount})', handle)
6565
else:
6666
raise ValueError('Invalid direction')
6767
return f'Scrolled {direction} inside the element at label {index} by {amount}'

src/agent/web/tools/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Wait(SharedBaseModel):
2121

2222
class Scroll(SharedBaseModel):
2323
direction: Literal['up','down'] = Field(description="The direction to scroll content", examples=['up','down'], default='up')
24-
amount: int = Field(description="Number of pixels to scroll, if None then scrolls by page/container height", examples=[100, 250, 500], default=None)
24+
amount: int = Field(description="Number of pixels to scroll, if None then scrolls by page/container height. Must required for scrollable container elements and the amount should be small", examples=[100, 25, 50], default=None)
2525
index: int = Field(description="Index of specific scrollable container element, if None then scrolls the entire page", examples=[0, 5, 12], default=None)
2626

2727
class GoTo(SharedBaseModel):

0 commit comments

Comments
 (0)