Edge
Launches and controls a Microsoft Edge browser over the DevTools Protocol. Learn more in Getting started.
pydoll.browser.chromium.Edge
Bases: Browser
Edge browser implementation for CDP automation.
Initialize Edge browser instance.
| PARAMETER | DESCRIPTION |
|---|---|
options
|
Edge configuration options (default if None).
TYPE:
|
connection_port
|
CDP WebSocket port (random if None).
TYPE:
|
connect
async
Connect to browser using WebSocket address. When we set the _ws_address attribute, the connection handler will use this address instead of resolving it from the connection port.
| PARAMETER | DESCRIPTION |
|---|---|
ws_address
|
WebSocket address of the browser.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tab
|
The first tab in the list of opened tabs. |
Note
You are supposed to use this method only if you want to connect to a browser that is already running.
start
async
Start browser process and establish CDP connection.
| RETURNS | DESCRIPTION |
|---|---|
Tab
|
Initial tab for interaction. |
A start that fails or is cancelled at any point after the process was launched ends that process and removes its temporary profile before the error propagates.
| RAISES | DESCRIPTION |
|---|---|
FailedToStartBrowser
|
If the browser this object started is still
running, if another process already listens on the debugging
port, or if the executable cannot be launched, exits before
answering, or does not answer within |
stop
async
Stop the browser and clean up what start() left behind.
Asks the browser to close with Browser.close while it still
answers, then ends the process start() launched, closes the WebSocket
connection and removes the temporary profile. A browser that crashed
or froze cannot answer, so it is ended without CDP, and
Browser.close gets a short timeout after which the process is
ended anyway. Either way nothing is left behind, even when stop() is
cancelled midway: the cleanup completes before the cancellation
propagates.
Only a browser this object launched, or reached with connect(),
is asked to close: after a start() refused because another browser
holds the port, that browser is left alone.
| RAISES | DESCRIPTION |
|---|---|
BrowserNotRunning
|
If there is nothing to stop: no process was
launched and no browser reached with |
close
async
Closes the WebSocket connections and releases resources.
The connections of the tabs this browser handed out are closed too, and the tabs are dropped from it.
create_browser_context
async
Create isolated browser context (like incognito).
Browser contexts provide isolated storage and don't share session data. Multiple contexts can exist simultaneously.
| PARAMETER | DESCRIPTION |
|---|---|
proxy_server
|
Optional proxy for this context only (scheme://host:port).
TYPE:
|
proxy_bypass_list
|
Comma-separated hosts that bypass proxy.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Browser context ID for use with other methods. |
delete_browser_context
async
Delete browser context and all associated tabs/resources.
Removes all storage (cookies, localStorage, etc.) and closes all tabs. The default browser context cannot be deleted.
Note
Closes all associated tabs immediately. Their Tab objects are dropped from the browser and their connections closed, so they release their callbacks and network logs.
get_browser_contexts
async
Get all browser context IDs including the default context.
new_tab
async
Create new tab for page interaction.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
Initial URL (about:blank if empty).
TYPE:
|
browser_context_id
|
Context to create tab in (default if None).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tab
|
Tab instance for page navigation and element interaction. |
get_targets
async
Get all active targets/pages in browser.
Targets include pages, service workers, shared workers, and browser process. Useful for debugging and managing multiple tabs.
| RETURNS | DESCRIPTION |
|---|---|
list[TargetInfo]
|
List of TargetInfo objects. |
get_opened_tabs
async
Get all opened tabs that are not extensions and have the type 'page'. Tabs that are already opened will be returned as is. If a new target is opened, a new Tab instance will be created.
Only Tabs whose target is gone are dropped (and their connections
closed); a Tab created in a context created with
create_browser_context reports that context.
| RETURNS | DESCRIPTION |
|---|---|
list[Tab]
|
List of Tab instances. The last tab is the most recent one. |
get_tab_by_target
async
The Tab of a target, in the context it belongs to when that one was created.
A target that already has a Tab gets that same Tab back. A new one is
kept by the browser like every other tab, so close(), stop()
and delete_browser_context() close its connection.
set_download_path
async
Set download directory path (convenience method for set_download_behavior).
set_download_behavior
async
Configure download handling.
| PARAMETER | DESCRIPTION |
|---|---|
behavior
|
ALLOW (save to path), DENY (cancel), or DEFAULT.
TYPE:
|
download_path
|
Required if behavior is ALLOW.
TYPE:
|
browser_context_id
|
Context to apply to (default if None).
TYPE:
|
events_enabled
|
Generate download events for progress tracking.
TYPE:
|
delete_all_cookies
async
Delete all cookies (session, persistent, third-party) from browser or context.
set_cookies
async
Set multiple cookies in browser or context.
get_cookies
async
Get all cookies from browser or context.
Note
This method does not work with native incognito mode (--incognito flag).
For incognito mode, use tab.get_cookies() instead.
get_window_id_for_target
async
Get window ID for target (used for window manipulation via CDP).
get_window_id
async
Get window ID for any valid tab.
| RAISES | DESCRIPTION |
|---|---|
NoValidTabFound
|
If no valid attached tab can be found. |
set_window_maximized
async
Maximize browser window (affects all tabs in window).
set_window_bounds
async
Set window position and/or size.
| PARAMETER | DESCRIPTION |
|---|---|
bounds
|
Properties to modify (left, top, width, height, windowState). Only specified properties are changed.
TYPE:
|
grant_permissions
async
Grant browser permissions (geolocation, notifications, camera, etc.).
Bypasses normal permission prompts for automated testing.
| PARAMETER | DESCRIPTION |
|---|---|
permissions
|
Permissions to grant.
TYPE:
|
origin
|
Origin to grant to (all origins if None).
TYPE:
|
browser_context_id
|
Context to apply to (default if None).
TYPE:
|
reset_permissions
async
Reset all permissions to defaults and restore prompting behavior.
on
async
Register CDP event listener at browser level.
Callback runs in background task to prevent blocking. Affects all pages/targets.
| PARAMETER | DESCRIPTION |
|---|---|
event_name
|
CDP event name (e.g., "Network.responseReceived").
|
callback
|
Function called on event (sync or async).
|
temporary
|
Remove after first invocation.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
Callback ID for removal. |
Note
For page-specific events, use Tab.on() instead.
enable_fetch_events
async
Enable network request interception via Fetch domain.
Allows monitoring, modifying, or blocking requests before they're sent. All matching requests are paused until explicitly continued.
| PARAMETER | DESCRIPTION |
|---|---|
handle_auth_requests
|
Intercept authentication challenges.
TYPE:
|
resource_type
|
Filter by type (XHR, Fetch, Document, etc.). Empty = all.
TYPE:
|
Note
Paused requests must be continued or they will timeout.
disable_fetch_events
async
Disable request interception and release any paused requests.
continue_request
async
continue_request(request_id, url=None, method=None, post_data=None, headers=None, intercept_response=None)
Continue paused request without modifications.
fulfill_request
async
Fulfill request with response data.
execute_command
async
Send a raw CDP command on the browser-level session.
Use it for browser-wide domains (Target, Browser, Storage, Emulation
screens) that pydoll does not wrap. Build commands with the factories in
pydoll.commands or pass a plain {'method': ..., 'params': ...} dict.
| PARAMETER | DESCRIPTION |
|---|---|
command
|
CDP command to send.
TYPE:
|
timeout
|
Seconds to wait for the browser's answer.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
T_CommandResponse
|
The browser's response, with the domain result under |
| RAISES | DESCRIPTION |
|---|---|
CommandFailed
|
If the browser answers with an error. |
CommandExecutionTimeout
|
If no answer arrives within |