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
examples fixes
Nick Sweeting878586edcdc0
diff --git a/examples/use-cases/find_and_apply_to_jobs.py b/examples/use-cases/find_and_apply_to_jobs.pyindex 31f698099..8325429a9 100644--- a/examples/use-cases/find_and_apply_to_jobs.py+++ b/examples/use-cases/find_and_apply_to_jobs.py@@ -94,12 +94,17 @@ async def upload_cv(index: int, browser_session: BrowserSession):return ActionResult(error=f'Element at index {index} is not a file upload element')try:- await file_upload_el.set_input_files(path)+ # Dispatch upload file event with the file input element+ from browser_use.browser.events import UploadFileEvent++ event = browser_session.event_bus.dispatch(UploadFileEvent(node=dom_element, file_path=path))+ await event+ await event.event_result(raise_if_any=True, raise_if_none=False)msg = f'Successfully uploaded file "{path}" to index {index}'logger.info(msg)return ActionResult(extracted_content=msg)except Exception as e:- logger.debug(f'Error in set_input_files: {str(e)}')+ logger.debug(f'Error in upload: {str(e)}')return ActionResult(error=f'Failed to upload file to index {index}')diff --git a/examples/use-cases/play_chess.py b/examples/use-cases/play_chess.pyindex 19b54ad72..378e3dbdf 100755--- a/examples/use-cases/play_chess.py+++ b/examples/use-cases/play_chess.py@@ -112,6 +112,8 @@ async def calculate_square_size(browser: BrowserSession) -> float | None:session_id=browser.agent_focus.session_id,)board_html = result.get('result', {}).get('value')+ if not board_html:+ raise ValueError('Failed to get board HTML')soup = BeautifulSoup(board_html, 'html.parser')pieces = soup.find_all('piece')if not pieces:diff --git a/tests/ci/evaluate_tasks.py b/tests/ci/evaluate_tasks.pyindex 31ea19f8b..687eeb5d2 100644--- a/tests/ci/evaluate_tasks.py+++ b/tests/ci/evaluate_tasks.py@@ -80,6 +80,7 @@ async def run_single_task(task_file):try:await session.start()from browser_use.browser.events import NavigateToUrlEvent+event = session.event_bus.dispatch(NavigateToUrlEvent(url='https://httpbin.org/get', new_tab=True))await eventprint('[DEBUG] Browser test: navigation successful', file=sys.stderr)