Overview
TheBrowser class represents the root browser process and manages all tabs, windows, and resources. There should typically be only one Browser instance per process.
Create a Browser instance using
await Browser.create() or the start() function, not by calling Browser() directly.Creation
Properties
Config
The configuration object used to launch the browser.
Connection
The websocket connection to the browser.
List[Tab]
All current targets including tabs, iframes, workers, and background processes.
List[Tab]
Only the targets that are of type “page” (actual browser tabs).
Tab
The first tab that was launched with the browser.
bool
Whether the browser process has stopped.
CookieJar
Cookie management interface for the browser.
str
The WebSocket debugger URL for the browser.
Methods
create()
Create a new Browser instance.Config
default:"None"
Configuration object. If not provided, a new Config is created from the other parameters.
get()
Navigate to a URL using the first available tab, or create a new tab/window.str
default:"chrome://welcome"
The URL to navigate to.
bool
default:"False"
Open URL in a new tab.
bool
default:"False"
Open URL in a new window.
wait()
Wait for a specified time while updating targets.float | int
default:"0.1"
Time to wait in seconds.
sleep()
Alias forwait(). Wait for a specified time.
stop()
Stop the browser process.grant_all_permissions()
Grant all possible permissions to the browser.- accessibilityEvents
- audioCapture
- backgroundSync
- clipboardReadWrite
- displayCapture
- geolocation
- notifications
- videoCapture
- And many more…
tile_windows()
Arrange browser windows in a grid layout.List[Tab]
default:"None"
Specific windows to tile. If None, tiles all tabs.
int
default:"0"
Maximum number of columns. If 0, automatically calculated.
create_context()
Create a new browser context, useful for managing multiple sessions with different proxies.str
default:"chrome://welcome"
Initial URL to navigate to.
str
default:"None"
Proxy server URL. Supports http, https, and socks5 with authentication:
http://USERNAME:PASSWORD@SERVER:PORTsocks5://USERNAME:PASSWORD@SERVER:PORT
List[str]
default:"None"
List of hosts to bypass proxy.
update_targets()
Update the list of available targets (tabs, iframes, workers).Iteration
You can iterate over browser tabs:Context Manager
Use BrowserContext for automatic cleanup:Examples
Basic browser control
Working with multiple tabs
See also
- Tab class - Control individual browser tabs
- Config class - Browser configuration options
- start() - Launch a browser instance