Browser Actor
Browser automation and control interface
The BrowserActor class provides methods for browser automation, screenshot capture, and video recording.
Constructor
Parameters
Optional Playwright browser instance. If not provided, a new one will be created
Whether to run the browser in headless mode
Enable video recording of browser interactions
Properties
page
Returns the current page instance, creating a new one if none exists.
has_recording
Returns whether a video recording is available.
recording_data
Returns the cached video recording data if available.
has_screenshot
Returns whether a screenshot is available.
screenshot_data
Returns the cached screenshot data if available.
Methods
take_screenshot
Takes and returns a screenshot of the current page.
Parameters
If True, captures the full scrollable page. If False, captures only the current viewport.
Returns
PIL Image of the screenshot if page is open, None otherwise.
navigate_to_url
Navigates the browser to the specified URL.
Parameters
The URL to navigate to
execute
Executes a browser interaction (click, scroll, type, hover, or wait).
Parameters
The browser interaction to execute
save_recording
Saves the browser recording to the specified path if available.
Parameters
Path where the recording should be saved
Returns
True if recording was saved successfully, False otherwise.
close
Cleans up all browser resources and saves recording if enabled. Should be called when finished using the browser.