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
fix
mertunsallfd3d04537a6f
diff --git a/browser_use/agent/prompts.py b/browser_use/agent/prompts.pyindex 95b86bfe8..aaf1ebf0b 100644--- a/browser_use/agent/prompts.py+++ b/browser_use/agent/prompts.py@@ -289,7 +289,7 @@ Interactive elements from top layer of the current page inside the viewport{trunreturn UserMessage(content=browser_state_content, cache=False)def get_read_state_message(self) -> UserMessage | None:- """Get read state as a separate cached message"""+ """Get read state as a separate message"""if not self.read_state_description:return Noneif not self.read_state_description.strip('\n').strip():diff --git a/browser_use/controller/service.py b/browser_use/controller/service.pyindex 975234cfb..c5f1e210b 100644--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@ -4,10 +4,7 @@ import jsonimport loggingimport osimport re-from typing import TYPE_CHECKING, Generic, TypeVar, cast--if TYPE_CHECKING:- from browser_use.browser.types import Page+from typing import Generic, TypeVar, casttry:from lmnr import Laminar # type: ignore@@ -18,6 +15,7 @@ from pydantic import BaseModelfrom browser_use.agent.views import ActionModel, ActionResultfrom browser_use.browser import BrowserSession+from browser_use.browser.types import Pagefrom browser_use.browser.views import BrowserErrorfrom browser_use.controller.registry.service import Registryfrom browser_use.controller.views import (@@ -298,7 +296,7 @@ Only use this for specific queries for information retrieval from the page. Don'async def extract_structured_data(query: str,extract_links: bool,- page: 'Page',+ page: Page,page_extraction_llm: BaseChatModel,file_system: FileSystem,):@@ -611,7 +609,7 @@ Explain the content of the page and that the requested information is not availa'Send strings of special keys to use Playwright page.keyboard.press - examples include Escape, Backspace, Insert, PageDown, Delete, Enter, or Shortcuts such as `Control+o`, `Control+Shift+T`',param_model=SendKeysAction,)- async def send_keys(params: SendKeysAction, page: 'Page'):+ async def send_keys(params: SendKeysAction, page: Page):try:await page.keyboard.press(params.keys)except Exception as e:@@ -632,7 +630,7 @@ Explain the content of the page and that the requested information is not availa@self.registry.action(description='Scroll to a text in the current page',)- async def scroll_to_text(text: str, page: 'Page'): # type: ignore+ async def scroll_to_text(text: str, page: Page): # type: ignoretry:# Try different locator strategieslocators = [@@ -915,7 +913,7 @@ Explain the content of the page and that the requested information is not availaraise BrowserError(msg)@self.registry.action('Google Sheets: Get the contents of the entire sheet', domains=['https://docs.google.com'])- async def read_sheet_contents(page: 'Page'):+ async def read_sheet_contents(page: Page):# select all cellsawait page.keyboard.press('Enter')await page.keyboard.press('Escape')@@ -981,7 +979,7 @@ Explain the content of the page and that the requested information is not availa)@self.registry.action('Google Sheets: Select a specific cell or range of cells', domains=['https://docs.google.com'])- async def select_cell_or_range(cell_or_range: str, page: 'Page'):+ async def select_cell_or_range(cell_or_range: str, page: Page):await page.keyboard.press('Enter') # make sure we dont delete current cell contents if we were last editingawait page.keyboard.press('Escape') # to clear current focus (otherwise select range popup is additive)await asyncio.sleep(0.1)@@ -1005,7 +1003,7 @@ Explain the content of the page and that the requested information is not availa'Google Sheets: Fallback method to type text into (only one) currently selected cell',domains=['https://docs.google.com'],)- async def fallback_input_into_single_selected_cell(text: str, page: 'Page'):+ async def fallback_input_into_single_selected_cell(text: str, page: Page):await page.keyboard.type(text, delay=0.1)await page.keyboard.press('Enter') # make sure to commit the input so it doesn't get overwritten by the next actionawait page.keyboard.press('ArrowUp')