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
removed click_element_by_text and click_element_by_xpath from default controller
Gregor Žuničdd29dfb7c7f8
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.pyindex 3dd05b6a5..11b79af27 100644--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@ -19,8 +19,6 @@ from browser_use.controller.registry.service import Registryfrom browser_use.controller.views import (ClickElementAction,ClickElementBySelectorAction,- ClickElementByTextAction,- ClickElementByXpathAction,CloseTabAction,DoneAction,DragDropAction,@@ -191,53 +189,6 @@ class Controller(Generic[Context]):logger.warning(f'Element not clickable with selector {params.css_selector} - most likely the page changed')return ActionResult(error=str(e))- @self.registry.action('Click on element by xpath', param_model=ClickElementByXpathAction)- async def click_element_by_xpath(params: ClickElementByXpathAction, browser: BrowserContext):- try:- element_node = await browser.get_locate_element_by_xpath(params.xpath)- if element_node:- try:- await element_node.scroll_into_view_if_needed()- await element_node.click(timeout=1500, force=True)- except Exception:- try:- # Handle with js evaluate if fails to click using playwright- await element_node.evaluate('el => el.click()')- except Exception as e:- logger.warning(f"Element not clickable with xpath '{params.xpath}' - {e}")- return ActionResult(error=str(e))- msg = f'🖱️ Clicked on element with text "{params.xpath}"'- return ActionResult(extracted_content=msg, include_in_memory=True)- except Exception as e:- logger.warning(f'Element not clickable with xpath {params.xpath} - most likely the page changed')- return ActionResult(error=str(e))-- @self.registry.action('Click element with text (use only as a backup)', param_model=ClickElementByTextAction)- async def click_element_by_text(params: ClickElementByTextAction, browser: BrowserContext):- try:- element_node = await browser.get_locate_element_by_text(- text=params.text, nth=params.nth, element_type=params.element_type- )-- if element_node:- try:- await element_node.scroll_into_view_if_needed()- await element_node.click(timeout=1500, force=True)- except Exception:- try:- # Handle with js evaluate if fails to click using playwright- await element_node.evaluate('el => el.click()')- except Exception as e:- logger.warning(f"Element not clickable with text '{params.text}' - {e}")- return ActionResult(error=str(e))- msg = f'🖱️ Clicked on element with text "{params.text}"'- return ActionResult(extracted_content=msg, include_in_memory=True)- else:- return ActionResult(error=f"No element found for text '{params.text}'")- except Exception as e:- logger.warning(f"Element not clickable with text '{params.text}' - {e}")- return ActionResult(error=str(e))-@self.registry.action('Input text into a input interactive element',param_model=InputTextAction,