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
Refactor screenshot saving in python_highlights.py to use aiofiles for asynchronous file writing and update .gitignore to ensure screenshot.png is properly excluded.
Magnus Müller267ff76e5064
diff --git a/.gitignore b/.gitignoreindex 3072cda88..1b5494b93 100644--- a/.gitignore+++ b/.gitignore@@ -57,4 +57,4 @@ token.jsontemp-profile-*-screenshot.png\ No newline at end of file+screenshot.pngdiff --git a/browser_use/browser/python_highlights.py b/browser_use/browser/python_highlights.pyindex 46362099f..9146bdb2d 100644--- a/browser_use/browser/python_highlights.py+++ b/browser_use/browser/python_highlights.py@@ -4,7 +4,6 @@ This module replaces JavaScript-based highlighting with fast Python image procesto draw bounding boxes around interactive elements directly on screenshots."""-import asyncioimport base64import ioimport logging@@ -480,11 +479,9 @@ async def create_highlighted_screenshot_async(filename = os.getenv('BROWSER_USE_SCREENSHOT_FILE')if filename:+ import aiofiles- async def _write_screenshot():- with open(filename, 'wb') as f:- f.write(base64.b64decode(final_screenshot))- logger.debug('Saved screenshot to ' + str(filename))-- await asyncio.to_thread(_write_screenshot)+ async with aiofiles.open(filename, 'wb') as f:+ await f.write(base64.b64decode(final_screenshot))+ logger.debug('Saved screenshot to ' + str(filename))return final_screenshot