DocsScreenshots & Visualbrowser_highlight

browser_highlight

Browser Highlight

Visually highlight an element on the page with a colored border and background overlay. Useful for debugging element selection - verify which element will be clicked before performing actions. The highlight persists until the page is navigated or refreshed.

Usage Example

123456789101112
import asyncio
from owl_browser import OwlBrowser, RemoteConfig
# Async usage
async with OwlBrowser(config) as browser:
context = await browser.create_context()
context_id = context["context_id"]
await browser.highlight(
context_id=context_id,
selector="#element-id"
)

Parameters

Required

context_idstringrequired

The unique identifier of the browser context (e.g., 'ctx_000001')

selectorstringrequired

CSS selector or natural language description of the element to highlight. Useful for debugging element selection before clicking. Examples: '#submit', '.nav-item', 'the login button'

Optional

border_colorstring

CSS color for the highlight border. Default: '#FF0000' (red). Examples: 'blue', '#00FF00', 'rgb(255, 128, 0)'

background_colorstring

CSS color for the highlight background (use alpha for transparency). Default: 'rgba(255, 0, 0, 0.2)'. Examples: 'rgba(0, 255, 0, 0.3)', 'transparent'

indexstring

When multiple elements match the selector, highlight the Nth element (0-based). Default: -1 (first match)

Response

Returns a JSON object with the operation result.

{
  "success": true,
  "result": <value>
}