Skip to content

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

Merge branch 'main' into claude-issue-2471-20250718-0729

Nick Sweetingd93d1b1152aa
diff --cc browser_use/controller/service.py
index e7044cc54,ff9a180b1..dfdbaab70
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@@ -811,13 -739,14 +739,14 @@@ Explain the content of the page and tha
)
@self.registry.action(
- description='Get all options from a native dropdown',
+ description='Get all options from a native dropdown or ARIA menu',
)
async def get_dropdown_options(index: int, browser_session: BrowserSession) -> ActionResult:
- """Get all options from a native dropdown"""
+ """Get all options from a native dropdown or ARIA menu"""
page = await browser_session.get_current_page()
- selector_map = await browser_session.get_selector_map()
- dom_element = selector_map[index]
+ dom_element = await browser_session.get_dom_element_by_index(index)
+ if dom_element is None:
+ raise Exception(f'Element index {index} does not exist - retry or use alternative actions')
try:
# Frame-aware approach since we know it works
@@@ -930,11 -824,18 +859,12 @@@
text: str,
browser_session: BrowserSession,
) -> ActionResult:
- """Select dropdown option by the text of the option you want to select"""
+ """Select dropdown option or ARIA menu item by the text of the option you want to select"""
page = await browser_session.get_current_page()
- selector_map = await browser_session.get_selector_map()
- dom_element = selector_map[index]
+ dom_element = await browser_session.get_dom_element_by_index(index)
+ if dom_element is None:
+ raise Exception(f'Element index {index} does not exist - retry or use alternative actions')
- # Validate that we're working with a select element
- if dom_element.tag_name != 'select':
- logger.error(f'Element is not a select! Tag: {dom_element.tag_name}, Attributes: {dom_element.attributes}')
- msg = f'Cannot select option: Element with index {index} is a {dom_element.tag_name}, not a select'
- return ActionResult(extracted_content=msg, include_in_memory=True, long_term_memory=msg)
-
logger.debug(f"Attempting to select '{text}' using xpath: {dom_element.xpath}")
logger.debug(f'Element attributes: {dom_element.attributes}')
logger.debug(f'Element tag: {dom_element.tag_name}')