Browser¶
The Browser domain defines methods and events for browser managing.
Types¶
Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.
-
class
cdp.browser.
WindowID
¶
-
class
cdp.browser.
WindowState
¶ The state of the browser window.
-
FULLSCREEN
= 'fullscreen'¶
-
MAXIMIZED
= 'maximized'¶
-
MINIMIZED
= 'minimized'¶
-
NORMAL
= 'normal'¶
-
-
class
cdp.browser.
Bounds
(left=None, top=None, width=None, height=None, window_state=None)¶ Browser window bounds information
-
height
= None¶ The window height in pixels.
-
left
= None¶ The offset from the left edge of the screen to the window in pixels.
-
top
= None¶ The offset from the top edge of the screen to the window in pixels.
-
width
= None¶ The window width in pixels.
-
window_state
= None¶ The window state. Default to normal.
-
-
class
cdp.browser.
PermissionType
¶ An enumeration.
-
ACCESSIBILITY_EVENTS
= 'accessibilityEvents'¶
-
AUDIO_CAPTURE
= 'audioCapture'¶
-
BACKGROUND_FETCH
= 'backgroundFetch'¶
-
BACKGROUND_SYNC
= 'backgroundSync'¶
-
CLIPBOARD_READ
= 'clipboardRead'¶
-
CLIPBOARD_WRITE
= 'clipboardWrite'¶
-
DURABLE_STORAGE
= 'durableStorage'¶
-
FLASH
= 'flash'¶
-
GEOLOCATION
= 'geolocation'¶
-
IDLE_DETECTION
= 'idleDetection'¶
-
MIDI
= 'midi'¶
-
MIDI_SYSEX
= 'midiSysex'¶
-
NOTIFICATIONS
= 'notifications'¶
-
PAYMENT_HANDLER
= 'paymentHandler'¶
-
PERIODIC_BACKGROUND_SYNC
= 'periodicBackgroundSync'¶
-
PROTECTED_MEDIA_IDENTIFIER
= 'protectedMediaIdentifier'¶
-
SENSORS
= 'sensors'¶
-
VIDEO_CAPTURE
= 'videoCapture'¶
-
WAKE_LOCK_SCREEN
= 'wakeLockScreen'¶
-
WAKE_LOCK_SYSTEM
= 'wakeLockSystem'¶
-
Commands¶
Each command is a generator function. The return
type Generator[x, y, z]
indicates that the generator
yields arguments of type x
, it must be resumed with
an argument of type y
, and it returns type z
. In
this library, types x
and y
are the same for all
commands, and z
is the return type you should pay attention
to. For more information, see
Getting Started: Commands.
-
cdp.browser.
close
()¶ Close browser gracefully.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.browser.
crash
()¶ Crashes browser on the main thread.
EXPERIMENTAL
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.browser.
crash_gpu_process
()¶ Crashes GPU process.
EXPERIMENTAL
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.browser.
get_browser_command_line
()¶ Returns the command line switches for the browser process if, and only if –enable-automation is on the commandline.
EXPERIMENTAL
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],List
[str
]]Returns: Commandline parameters
-
cdp.browser.
get_histogram
(name, delta=None)¶ Get a Chrome histogram by name.
EXPERIMENTAL
Parameters: - name (
str
) – Requested histogram name. - delta (
Optional
[bool
]) – (Optional) If true, retrieve delta since last call.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],Histogram
]Returns: Histogram.
- name (
-
cdp.browser.
get_histograms
(query=None, delta=None)¶ Get Chrome histograms.
EXPERIMENTAL
Parameters: - query (
Optional
[str
]) – (Optional) Requested substring in name. Only histograms which have query as a substring in their name are extracted. An empty or absent query returns all histograms. - delta (
Optional
[bool
]) – (Optional) If true, retrieve delta since last call.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],List
[Histogram
]]Returns: Histograms.
- query (
-
cdp.browser.
get_version
()¶ Returns version information.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],Tuple
[str
,str
,str
,str
,str
]]Returns: A tuple with the following items: - protocolVersion - Protocol version.
- product - Product name.
- revision - Product revision.
- userAgent - User-Agent.
- jsVersion - V8 version.
-
cdp.browser.
get_window_bounds
(window_id)¶ Get position and size of the browser window.
EXPERIMENTAL
Parameters: window_id ( WindowID
) – Browser window id.Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],Bounds
]Returns: Bounds information of the window. When window state is ‘minimized’, the restored window position and size are returned.
-
cdp.browser.
get_window_for_target
(target_id=None)¶ Get the browser window that contains the devtools target.
EXPERIMENTAL
Parameters: target_id ( Optional
[TargetID
]) – (Optional) Devtools agent host id. If called as a part of the session, associated targetId is used.Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],Tuple
[WindowID
,Bounds
]]Returns: A tuple with the following items: - windowId - Browser window id.
- bounds - Bounds information of the window. When window state is ‘minimized’, the restored window position and size are returned.
-
cdp.browser.
grant_permissions
(origin, permissions, browser_context_id=None)¶ Grant specific permissions to the given origin and reject all others.
EXPERIMENTAL
Parameters: - origin (
str
) – - permissions (
List
[PermissionType
]) – - browser_context_id (
Optional
[BrowserContextID
]) – (Optional) BrowserContext to override permissions. When omitted, default browser context is used.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]- origin (
-
cdp.browser.
reset_permissions
(browser_context_id=None)¶ Reset all permission management for all origins.
EXPERIMENTAL
Parameters: browser_context_id ( Optional
[BrowserContextID
]) – (Optional) BrowserContext to reset permissions. When omitted, default browser context is used.Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
-
cdp.browser.
set_dock_tile
(badge_label=None, image=None)¶ Set dock tile details, platform-specific.
EXPERIMENTAL
Parameters: - badge_label (
Optional
[str
]) – (Optional) - image (
Optional
[str
]) – (Optional) Png encoded image.
Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]- badge_label (
-
cdp.browser.
set_window_bounds
(window_id, bounds)¶ Set position and/or size of the browser window.
EXPERIMENTAL
Parameters: Return type: Generator
[Dict
[str
,Any
],Dict
[str
,Any
],None
]
Events¶
There are no events in this module.