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
Adjust font size and padding calculations for enhanced bounding box rendering in Python highlights; update task description in example script for clarity.
Magnus Müller81461cdfffb0
diff --git a/browser_use/browser/python_highlights.py b/browser_use/browser/python_highlights.pyindex 541313e0e..edb3d3532 100644--- a/browser_use/browser/python_highlights.py+++ b/browser_use/browser/python_highlights.py@@ -95,8 +95,8 @@ def draw_enhanced_bounding_box_with_text(try:# Scale font size based on image dimensions for consistent appearance across viewportsimg_width, img_height = image_size- # Base font size scales with viewport width (36px for 1200px viewport)- base_font_size = max(16, min(48, int(img_width * 0.03))) # 3% of viewport width+ # Base font size scales with viewport width (24px for 1200px viewport) - smaller numbers+ base_font_size = max(12, min(32, int(img_width * 0.02))) # 2% of viewport widthbig_font = Nonetry:big_font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', base_font_size)@@ -121,8 +121,8 @@ def draw_enhanced_bounding_box_with_text(text_width = bbox_text[2] - bbox_text[0]text_height = bbox_text[3] - bbox_text[1]- # Scale padding based on viewport size for consistent appearance- padding = max(4, int(img_width * 0.005)) # 0.5% of viewport width+ # Scale padding based on viewport size for consistent appearance - reduced for tighter fit+ padding = max(2, int(img_width * 0.002)) # 0.2% of viewport width - smaller paddingelement_width = x2 - x1element_height = y2 - y1diff --git a/examples/simple.py b/examples/simple.pyindex 556d737e1..a950a7817 100644--- a/examples/simple.py+++ b/examples/simple.py@@ -1,7 +1,7 @@from browser_use import Agent, ChatOpenAIagent = Agent(- task='Find founders of browser-use',+ task='Give me a csv of 20 collage football games season 2025 ',llm=ChatOpenAI(model='gpt-4.1-mini'),)