Skip to content

Protocol Commands

This section documents the Chrome DevTools Protocol command implementations used by Pydoll.

Page Commands

pydoll.commands.page_commands

PageCommands

This class encapsulates the page commands of the Chrome DevTools Protocol (CDP).

CDP's Page domain allows for interacting with browser pages, including navigation, content manipulation, and page state monitoring. These commands provide powerful capabilities for web automation, testing, and debugging.

The commands defined in this class provide functionality for: - Navigating to URLs and managing page history - Capturing screenshots and generating PDFs - Handling JavaScript dialogs - Enabling and controlling page events - Managing download behavior - Manipulating page content and state

add_script_to_evaluate_on_new_document staticmethod
add_script_to_evaluate_on_new_document(source, world_name=None, include_command_line_api=None, run_immediately=None)

Creates a command to add a script that will be evaluated when a new document is created.

PARAMETER DESCRIPTION
source

Script source to be evaluated when a new document is created.

TYPE: str

world_name

If specified, creates an isolated world with the given name.

TYPE: Optional[str] DEFAULT: None

include_command_line_api

Whether to include command line API.

TYPE: Optional[bool] DEFAULT: None

run_immediately

Whether to run the script immediately on existing contexts.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command[AddScriptToEvaluateOnNewDocumentResponse]

Command[AddScriptToEvaluateOnNewDocumentResponse]: Command object with the identifier of the added script.

bring_to_front staticmethod
bring_to_front()

Brings the page to front.

capture_screenshot staticmethod
capture_screenshot(format=None, quality=None, clip=None, from_surface=None, capture_beyond_viewport=None, optimize_for_speed=None)

Creates a command to capture a screenshot of the current page.

PARAMETER DESCRIPTION
format

Image compression format (jpeg, png, or webp).

TYPE: Optional[str] DEFAULT: None

quality

Compression quality from 0-100 (jpeg only).

TYPE: Optional[int] DEFAULT: None

clip

Region of the page to capture.

TYPE: Optional[Viewport] DEFAULT: None

from_surface

Capture from the surface, not the view.

TYPE: Optional[bool] DEFAULT: None

capture_beyond_viewport

Capture beyond the viewport.

TYPE: Optional[bool] DEFAULT: None

optimize_for_speed

Optimize for speed, not for size.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command[CaptureScreenshotResponse]

Command[CaptureScreenshotResponse]: Command object with base64-encoded image data.

close staticmethod
close()

Creates a command to close the current page.

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to close the page.

create_isolated_world staticmethod
create_isolated_world(frame_id, world_name=None, grant_universal_access=None)

Creates a command to create an isolated world for the given frame.

PARAMETER DESCRIPTION
frame_id

ID of the frame in which to create the isolated world.

TYPE: str

world_name

Name to be reported in the Execution Context.

TYPE: Optional[str] DEFAULT: None

grant_universal_access

Whether to grant universal access.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command[CreateIsolatedWorldResponse]

Command[CreateIsolatedWorldResponse]: Command object with the execution context ID.

disable staticmethod
disable()

Creates a command to disable page domain notifications.

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to disable the Page domain.

enable staticmethod
enable(enable_file_chooser_opened_event=None)

Creates a command to enable page domain notifications.

PARAMETER DESCRIPTION
enable_file_chooser_opened_event

Whether to emit Page.fileChooserOpened event.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to enable the Page domain.

get_app_manifest staticmethod
get_app_manifest(manifest_id=None)

Creates a command to get the manifest for the current document.

RETURNS DESCRIPTION
Command[GetAppManifestResponse]

Command[GetAppManifestResponse]: Command object with manifest information.

get_frame_tree staticmethod
get_frame_tree()

Creates a command to get the frame tree for the current page.

RETURNS DESCRIPTION
Command[GetFrameTreeResponse]

Command[GetFrameTreeResponse]: Command object with frame tree information.

get_layout_metrics staticmethod
get_layout_metrics()

Creates a command to get layout metrics for the page.

RETURNS DESCRIPTION
Command[GetLayoutMetricsResponse]

Command[GetLayoutMetricsResponse]: Command object with layout metrics.

get_navigation_history staticmethod
get_navigation_history()

Creates a command to get the navigation history for the current page.

RETURNS DESCRIPTION
Command[GetNavigationHistoryResponse]

Command[GetNavigationHistoryResponse]: Command object with navigation history.

handle_javascript_dialog staticmethod
handle_javascript_dialog(accept, prompt_text=None)

Creates a command to handle a JavaScript dialog.

PARAMETER DESCRIPTION
accept

Whether to accept or dismiss the dialog.

TYPE: bool

prompt_text

Text to enter in prompt dialogs.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to handle a JavaScript dialog.

navigate staticmethod
navigate(url, referrer=None, transition_type=None, frame_id=None, referrer_policy=None)

Creates a command to navigate to a specific URL.

PARAMETER DESCRIPTION
url

URL to navigate to.

TYPE: str

referrer

Referrer URL.

TYPE: Optional[str] DEFAULT: None

transition_type

Intended transition type.

TYPE: Optional[str] DEFAULT: None

frame_id

Frame ID to navigate.

TYPE: Optional[str] DEFAULT: None

referrer_policy

Referrer policy.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[NavigateResponse]

Command[NavigateResponse]: Command object to navigate to a URL.

navigate_to_history_entry staticmethod
navigate_to_history_entry(entry_id)

Creates a command to navigate to a specific history entry.

PARAMETER DESCRIPTION
entry_id

ID of the history entry to navigate to.

TYPE: int

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to navigate to a history entry.

print_to_pdf staticmethod
print_to_pdf(landscape=None, display_header_footer=None, print_background=None, scale=None, paper_width=None, paper_height=None, margin_top=None, margin_bottom=None, margin_left=None, margin_right=None, page_ranges=None, header_template=None, footer_template=None, prefer_css_page_size=None, transfer_mode=None, generate_tagged_pdf=None, generate_document_outline=None)

Creates a command to print the current page to PDF.

PARAMETER DESCRIPTION
landscape

Paper orientation.

TYPE: Optional[bool] DEFAULT: None

display_header_footer

Display header and footer.

TYPE: Optional[bool] DEFAULT: None

print_background

Print background graphics.

TYPE: Optional[bool] DEFAULT: None

scale

Scale of the webpage rendering.

TYPE: Optional[float] DEFAULT: None

paper_width

Paper width in inches.

TYPE: Optional[float] DEFAULT: None

paper_height

Paper height in inches.

TYPE: Optional[float] DEFAULT: None

margin_top

Top margin in inches.

TYPE: Optional[float] DEFAULT: None

margin_bottom

Bottom margin in inches.

TYPE: Optional[float] DEFAULT: None

margin_left

Left margin in inches.

TYPE: Optional[float] DEFAULT: None

margin_right

Right margin in inches.

TYPE: Optional[float] DEFAULT: None

page_ranges

Paper ranges to print, e.g., '1-5, 8, 11-13'.

TYPE: Optional[str] DEFAULT: None

header_template

HTML template for the print header.

TYPE: Optional[str] DEFAULT: None

footer_template

HTML template for the print footer.

TYPE: Optional[str] DEFAULT: None

prefer_css_page_size

Whether to prefer page size as defined by CSS.

TYPE: Optional[bool] DEFAULT: None

transfer_mode

Transfer mode.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[PrintToPDFResponse]

Command[PrintToPDFResponse]: Command object to print the page to PDF.

reload staticmethod
reload(ignore_cache=None, script_to_evaluate_on_load=None, loader_id=None)

Creates a command to reload the current page.

PARAMETER DESCRIPTION
ignore_cache

If true, browser cache is ignored.

TYPE: Optional[bool] DEFAULT: None

script_to_evaluate_on_load

Script to be injected into the page on load.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to reload the page.

reset_navigation_history staticmethod
reset_navigation_history()

Creates a command to reset the navigation history.

remove_script_to_evaluate_on_new_document staticmethod
remove_script_to_evaluate_on_new_document(identifier)

Creates a command to remove a script that was added to be evaluated on new documents.

PARAMETER DESCRIPTION
identifier

Identifier of the script to remove.

TYPE: str

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to remove a script.

set_bypass_csp staticmethod
set_bypass_csp(enabled)

Creates a command to toggle bypassing page CSP.

PARAMETER DESCRIPTION
enabled

Whether to bypass page CSP.

TYPE: bool

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to toggle bypassing page CSP.

set_document_content staticmethod
set_document_content(frame_id, html)

Creates a command to set the document content of a frame.

PARAMETER DESCRIPTION
frame_id

Frame ID to set the document content for.

TYPE: str

html

HTML content to set.

TYPE: str

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to set the document content.

set_intercept_file_chooser_dialog staticmethod
set_intercept_file_chooser_dialog(enabled)

Creates a command to set whether to intercept file chooser dialogs.

PARAMETER DESCRIPTION
enabled

Whether to intercept file chooser dialogs.

TYPE: bool

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to set file chooser dialog interception.

set_lifecycle_events_enabled staticmethod
set_lifecycle_events_enabled(enabled)

Creates a command to enable/disable lifecycle events.

PARAMETER DESCRIPTION
enabled

Whether to enable lifecycle events.

TYPE: bool

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to enable/disable lifecycle events.

stop_loading staticmethod
stop_loading()

Creates a command to stop loading the page.

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to stop loading the page.

add_compilation_cache staticmethod
add_compilation_cache(url, data)

Creates a command to add a compilation cache entry.

Experimental: This method is experimental and may be subject to change.

PARAMETER DESCRIPTION
url

URL for which to add the compilation cache entry.

TYPE: str

data

Base64-encoded data.

TYPE: str

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to add a compilation cache entry.

capture_snapshot staticmethod
capture_snapshot(format='mhtml')

Creates a command to capture a snapshot of the page.

Experimental: This method is experimental and may be subject to change.

PARAMETER DESCRIPTION
format

Format of the snapshot (only 'mhtml' is supported).

TYPE: Literal['mhtml'] DEFAULT: 'mhtml'

RETURNS DESCRIPTION
Command[CaptureSnapshotResponse]

Command[CaptureSnapshotResponse]: Command object to capture a snapshot.

clear_compilation_cache staticmethod
clear_compilation_cache()

Creates a command to clear the compilation cache.

crash staticmethod
crash()

Creates a command to crash the page.

generate_test_report staticmethod
generate_test_report(message, group=None)

Creates a command to generate a test report.

Experimental: This method is experimental and may be subject to change.

PARAMETER DESCRIPTION
message

Message to be displayed in the report.

TYPE: str

group

Group label for the report.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to generate a test report.

get_ad_script_ancestry_ids staticmethod
get_ad_script_ancestry_ids(frame_id)

Creates a command to get the ad script ancestry IDs for a given frame.

Experimental: This method is experimental and may be subject to change.

PARAMETER DESCRIPTION
frame_id

ID of the frame to get ad script ancestry IDs for.

TYPE: str

RETURNS DESCRIPTION
Command[GetAdScriptAncestryIdsResponse]

Command[GetAdScriptAncestryIdsResponse]: Command object to get ad script ancestry IDs.

get_app_id staticmethod
get_app_id(app_id=None, recommended_id=None)

Creates a command to get the app ID.

Experimental: This method is experimental and may be subject to change.

PARAMETER DESCRIPTION
app_id

App ID for verification.

TYPE: Optional[str] DEFAULT: None

recommended_id

Recommended app ID.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[GetAppIdResponse]

Command[GetAppIdResponse]: Command object to get the app ID.

get_installability_errors staticmethod
get_installability_errors()

Creates a command to get the installability errors.

get_origin_trials staticmethod
get_origin_trials(frame_id)

Creates a command to get origin trials for a given origin.

Experimental: This method is experimental and may be subject to change.

PARAMETER DESCRIPTION
frame_id

Frame ID to get trials for.

TYPE: Optional[str]

RETURNS DESCRIPTION
Command[GetOriginTrialsResponse]

Command[GetOriginTrialsResponse]: Command object to get origin trials.

get_permissions_policy_state staticmethod
get_permissions_policy_state(frame_id)

Creates a command to get the permissions policy state.

get_resource_content staticmethod
get_resource_content(frame_id, url)

Creates a command to get the resource content.

get_resource_tree staticmethod
get_resource_tree()

Creates a command to get the resource tree.

produce_compilation_cache staticmethod
produce_compilation_cache(scripts)

Creates a command to produce a compilation cache entry.

screencast_frame_ack staticmethod
screencast_frame_ack(session_id)

Creates a command to acknowledge a screencast frame.

search_in_resource staticmethod
search_in_resource(frame_id, url, query, case_sensitive=None, is_regex=None)

Creates a command to search for a string in a resource.

set_ad_blocking_enabled staticmethod
set_ad_blocking_enabled(enabled)

Creates a command to set ad blocking enabled.

set_font_families staticmethod
set_font_families(font_families, for_scripts)

Creates a command to set font families.

set_font_sizes staticmethod
set_font_sizes(font_sizes)

Creates a command to set font sizes.

set_prerendering_allowed staticmethod
set_prerendering_allowed(allowed)

Creates a command to set prerendering allowed.

set_rph_registration_mode staticmethod
set_rph_registration_mode(mode)

Creates a command to set the RPH registration mode.

set_spc_transaction_mode staticmethod
set_spc_transaction_mode(mode)

Creates a command to set the SPC transaction mode.

set_web_lifecycle_state staticmethod
set_web_lifecycle_state(state)

Creates a command to set the web lifecycle state.

start_screencast staticmethod
start_screencast(format, quality=None, max_width=None, max_height=None, every_nth_frame=None)

Creates a command to start a screencast.

stop_screencast staticmethod
stop_screencast()

Creates a command to stop a screencast.

wait_for_debugger staticmethod
wait_for_debugger()

Creates a command to wait for a debugger.

Runtime Commands

pydoll.commands.runtime_commands

RuntimeCommands

A class for interacting with the JavaScript runtime using Chrome DevTools Protocol.

This class provides methods to create commands for evaluating JavaScript expressions, calling functions on JavaScript objects, and retrieving object properties through CDP.

ATTRIBUTE DESCRIPTION
EVALUATE_TEMPLATE

Template for the Runtime.evaluate command.

TYPE: dict

CALL_FUNCTION_ON_TEMPLATE

Template for the Runtime.callFunctionOn command.

TYPE: dict

GET_PROPERTIES

Template for the Runtime.getProperties command.

TYPE: dict

add_binding staticmethod
add_binding(name, execution_context_name=None)

Creates a command to add a JavaScript binding.

PARAMETER DESCRIPTION
name

Name of the binding to add.

TYPE: str

execution_context_name

Name of the execution context to bind to.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to add a JavaScript binding.

await_promise staticmethod
await_promise(promise_object_id, return_by_value=None, generate_preview=None)

Creates a command to await a JavaScript promise and return its result.

PARAMETER DESCRIPTION
promise_object_id

ID of the promise to await.

TYPE: str

return_by_value

Whether to return the result by value instead of reference.

TYPE: Optional[bool] DEFAULT: None

generate_preview

Whether to generate a preview for the result.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command[AwaitPromiseResponse]

Command[AwaitPromiseResponse]: Command object to await a promise.

call_function_on staticmethod
call_function_on(function_declaration, object_id=None, arguments=None, silent=None, return_by_value=None, generate_preview=None, user_gesture=None, await_promise=None, execution_context_id=None, object_group=None, throw_on_side_effect=None, unique_context_id=None, serialization_options=None)

Creates a command to call a function with a given declaration on a specific object.

PARAMETER DESCRIPTION
function_declaration

Declaration of the function to call.

TYPE: str

object_id

ID of the object to call the function on.

TYPE: Optional[str] DEFAULT: None

arguments

Arguments to pass to the function.

TYPE: Optional[list[CallArgument]] DEFAULT: None

silent

Whether to silence exceptions.

TYPE: Optional[bool] DEFAULT: None

return_by_value

Whether to return the result by value instead of reference.

TYPE: Optional[bool] DEFAULT: None

generate_preview

Whether to generate a preview for the result.

TYPE: Optional[bool] DEFAULT: None

user_gesture

Whether to treat the call as initiated by user gesture.

TYPE: Optional[bool] DEFAULT: None

await_promise

Whether to await promise result.

TYPE: Optional[bool] DEFAULT: None

execution_context_id

ID of the execution context to call the function in.

TYPE: Optional[str] DEFAULT: None

object_group

Symbolic group name for the result.

TYPE: Optional[str] DEFAULT: None

throw_on_side_effect

Whether to throw if side effect cannot be ruled out.

TYPE: Optional[bool] DEFAULT: None

unique_context_id

Unique context ID for the function call.

TYPE: Optional[str] DEFAULT: None

serialization_options

Serialization options for the result.

TYPE: Optional[SerializationOptions] DEFAULT: None

RETURNS DESCRIPTION
Command[CallFunctionOnResponse]

Command[CallFunctionOnResponse]: Command object to call a function on an object.

compile_script staticmethod
compile_script(expression, source_url=None, persist_script=None, execution_context_id=None)

Creates a command to compile a JavaScript expression.

PARAMETER DESCRIPTION
expression

JavaScript expression to compile.

TYPE: str

source_url

URL of the source file for the script.

TYPE: Optional[str] DEFAULT: None

persist_script

Whether to persist the compiled script.

TYPE: Optional[bool] DEFAULT: None

execution_context_id

ID of the execution context to compile the script in.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[CompileScriptResponse]

Command[CompileScriptResponse]: Command object to compile a script.

disable staticmethod
disable()

Disables the runtime domain.

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to disable the runtime domain.

enable staticmethod
enable()

Enables the runtime domain.

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to enable the runtime domain.

evaluate staticmethod
evaluate(expression, object_group=None, include_command_line_api=None, silent=None, context_id=None, return_by_value=None, generate_preview=None, user_gesture=None, await_promise=None, throw_on_side_effect=None, timeout=None, disable_breaks=None, repl_mode=None, allow_unsafe_eval_blocked_by_csp=None, unique_context_id=None, serialization_options=None)

Creates a command to evaluate a JavaScript expression in the global context.

PARAMETER DESCRIPTION
expression

JavaScript expression to evaluate.

TYPE: str

object_group

Symbolic group name for the result.

TYPE: Optional[str] DEFAULT: None

include_command_line_api

Whether to include command line API.

TYPE: Optional[bool] DEFAULT: None

silent

Whether to silence exceptions.

TYPE: Optional[bool] DEFAULT: None

context_id

ID of the execution context to evaluate in.

TYPE: Optional[str] DEFAULT: None

return_by_value

Whether to return the result by value instead of reference.

TYPE: Optional[bool] DEFAULT: None

generate_preview

Whether to generate a preview for the result.

TYPE: Optional[bool] DEFAULT: None

user_gesture

Whether to treat evaluation as initiated by user gesture.

TYPE: Optional[bool] DEFAULT: None

await_promise

Whether to await promise result.

TYPE: Optional[bool] DEFAULT: None

throw_on_side_effect

Whether to throw if side effect cannot be ruled out.

TYPE: Optional[bool] DEFAULT: None

timeout

Timeout in milliseconds.

TYPE: Optional[float] DEFAULT: None

disable_breaks

Whether to disable breakpoints during evaluation.

TYPE: Optional[bool] DEFAULT: None

repl_mode

Whether to execute in REPL mode.

TYPE: Optional[bool] DEFAULT: None

allow_unsafe_eval_blocked_by_csp

Allow unsafe evaluation.

TYPE: Optional[bool] DEFAULT: None

unique_context_id

Unique context ID for evaluation.

TYPE: Optional[str] DEFAULT: None

serialization_options

Serialization for the result.

TYPE: Optional[SerializationOptions] DEFAULT: None

RETURNS DESCRIPTION
Command[EvaluateResponse]

Command[EvaluateResponse]: Command object to evaluate JavaScript.

get_properties staticmethod
get_properties(object_id, own_properties=None, accessor_properties_only=None, generate_preview=None, non_indexed_properties_only=None)

Creates a command to get properties of a JavaScript object.

PARAMETER DESCRIPTION
object_id

ID of the object to get properties for.

TYPE: str

own_properties

Whether to return only own properties.

TYPE: Optional[bool] DEFAULT: None

accessor_properties_only

Whether to return only accessor properties.

TYPE: Optional[bool] DEFAULT: None

generate_preview

Whether to generate previews for property values.

TYPE: Optional[bool] DEFAULT: None

non_indexed_properties_only

Whether to return only non-indexed properties.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command[GetPropertiesResponse]

Command[GetPropertiesResponse]: Command object to get object properties.

global_lexical_scope_names staticmethod
global_lexical_scope_names(execution_context_id=None)

Creates a command to retrieve names of variables from global lexical scope.

PARAMETER DESCRIPTION
execution_context_id

ID of the execution context to get scope names from.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[GlobalLexicalScopeNamesResponse]

Command[GlobalLexicalScopeNamesResponse]: Command object to get global lexical scope names.

query_objects staticmethod
query_objects(prototype_object_id, object_group=None)

Creates a command to query objects with a given prototype.

PARAMETER DESCRIPTION
prototype_object_id

ID of the prototype object.

TYPE: str

object_group

Symbolic group name for the results.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[QueryObjectsResponse]

Command[QueryObjectsResponse]: Command object to query objects.

release_object staticmethod
release_object(object_id)

Creates a command to release a JavaScript object.

PARAMETER DESCRIPTION
object_id

ID of the object to release.

TYPE: str

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to release an object.

release_object_group staticmethod
release_object_group(object_group)

Creates a command to release all objects in a group.

PARAMETER DESCRIPTION
object_group

Name of the object group to release.

TYPE: str

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to release an object group.

remove_binding staticmethod
remove_binding(name)

Creates a command to remove a JavaScript binding.

PARAMETER DESCRIPTION
name

Name of the binding to remove.

TYPE: str

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to remove a JavaScript binding.

run_script staticmethod
run_script(script_id, execution_context_id=None, object_group=None, silent=None, include_command_line_api=None, return_by_value=None, generate_preview=None, await_promise=None)

Creates a command to run a compiled script.

PARAMETER DESCRIPTION
script_id

ID of the compiled script to run.

TYPE: str

execution_context_id

ID of the execution context to run the script in.

TYPE: Optional[str] DEFAULT: None

object_group

Symbolic group name for the result.

TYPE: Optional[str] DEFAULT: None

silent

Whether to silence exceptions.

TYPE: Optional[bool] DEFAULT: None

include_command_line_api

Whether to include command line API.

TYPE: Optional[bool] DEFAULT: None

return_by_value

Whether to return the result by value instead of reference.

TYPE: Optional[bool] DEFAULT: None

generate_preview

Whether to generate a preview for the result.

TYPE: Optional[bool] DEFAULT: None

await_promise

Whether to await promise result.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command[RunScriptResponse]

Command[RunScriptResponse]: Command object to run a script.

set_async_call_stack_depth staticmethod
set_async_call_stack_depth(max_depth)

Creates a command to set the async call stack depth.

PARAMETER DESCRIPTION
max_depth

Maximum depth of async call stacks.

TYPE: int

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to set async call stack depth.

set_custom_object_formatter_enabled staticmethod
set_custom_object_formatter_enabled(enabled)

Creates a command to enable or disable custom object formatters.

PARAMETER DESCRIPTION
enabled

Whether to enable custom object formatters.

TYPE: bool

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to enable/disable custom object formatters.

set_max_call_stack_size_to_capture staticmethod
set_max_call_stack_size_to_capture(size)

Creates a command to set the maximum call stack size to capture.

PARAMETER DESCRIPTION
size

Maximum call stack size to capture.

TYPE: int

RETURNS DESCRIPTION
Command[Response]

Command[Response]: Command object to set max call stack size.

DOM Commands

pydoll.commands.dom_commands

DomCommands

Implementation of Chrome DevTools Protocol for the DOM domain.

This class provides commands for interacting with the Document Object Model (DOM) in the browser, enabling access and manipulation of the element structure in a web page. The DOM domain in Chrome DevTools Protocol exposes operations for reading and writing to the DOM, which is fundamental for browser automation, testing, and debugging.

Each DOM element is represented by a mirror object with a unique ID. This ID can be used to gather additional information about the node, resolve it into JavaScript object wrappers, manipulate attributes, and perform various other operations on the DOM structure.

describe_node staticmethod
describe_node(node_id=None, backend_node_id=None, object_id=None, depth=None, pierce=None)

Describes a DOM node identified by its ID without requiring domain to be enabled.

The describe_node command is particularly useful in scenarios where you need to quickly gather information about a specific element without subscribing to DOM change events, making it more lightweight for isolated element inspection operations.

PARAMETER DESCRIPTION
node_id

Identifier of the node known to the client.

TYPE: Optional[int] DEFAULT: None

backend_node_id

Identifier of the backend node used internally by the browser.

TYPE: Optional[int] DEFAULT: None

object_id

JavaScript object id of the node wrapper.

TYPE: Optional[str] DEFAULT: None

depth

Maximum depth at which children should be retrieved (default is 1). Use -1 for the entire subtree or provide an integer greater than 0.

TYPE: Optional[int] DEFAULT: None

pierce

Whether iframes and shadow roots should be traversed when returning the subtree (default is false).

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns detailed information about the requested node.

TYPE: Command[DescribeNodeResponse]

disable staticmethod
disable()

Disables DOM agent for the current page.

Disabling the DOM domain stops the CDP from sending DOM-related events and prevents further DOM manipulation operations until the domain is enabled again. This can be important for optimizing performance when you're done with DOM operations and want to minimize background processing.

RETURNS DESCRIPTION
Command

CDP command to disable the DOM domain.

TYPE: Command[Response]

enable staticmethod
enable(include_whitespace=None)

Enables DOM agent for the current page.

Enabling the DOM domain is a prerequisite for receiving DOM events and using most DOM manipulation methods. The DOM events include changes to the DOM tree structure, attribute modifications, and many others. Without enabling this domain first, many DOM operations would fail or provide incomplete information.

PARAMETER DESCRIPTION
include_whitespace

Whether to include whitespace-only text nodes in the children array of returned Nodes. Allowed values: "none", "all".

TYPE: Optional[IncludeWhitespace] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command to enable the DOM domain.

TYPE: Command[Response]

focus staticmethod
focus(node_id=None, backend_node_id=None, object_id=None)

Focuses the given element.

The focus command is crucial for simulating realistic user interactions, as many events (like keyboard input) require that an element has focus first. It's also important for testing proper tab order and keyboard accessibility of web pages.

PARAMETER DESCRIPTION
node_id

Identifier of the node to focus.

TYPE: Optional[int] DEFAULT: None

backend_node_id

Identifier of the backend node to focus.

TYPE: Optional[int] DEFAULT: None

object_id

JavaScript object id of the node wrapper.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command to focus on the specified element.

TYPE: Command[Response]

get_attributes staticmethod
get_attributes(node_id)

Returns attributes for the specified node.

Attribute information is essential in web testing and automation because attributes often contain crucial information about element state, behavior, and metadata. This command provides an efficient way to access all attributes of an element without parsing HTML or using JavaScript evaluation.

PARAMETER DESCRIPTION
node_id

Id of the node to retrieve attributes for.

TYPE: int

RETURNS DESCRIPTION
Command

CDP command that returns an interleaved array of node attribute names and values [name1, value1, name2, value2, ...].

TYPE: Command[GetAttributesResponse]

get_box_model staticmethod
get_box_model(node_id=None, backend_node_id=None, object_id=None)

Returns box model information for the specified node.

The box model is a fundamental concept in CSS that describes how elements are rendered with content, padding, borders, and margins. This command provides detailed information about these dimensions and coordinates, which is invaluable for spatial analysis and precision interactions with elements on the page.

PARAMETER DESCRIPTION
node_id

Identifier of the node.

TYPE: Optional[int] DEFAULT: None

backend_node_id

Identifier of the backend node.

TYPE: Optional[int] DEFAULT: None

object_id

JavaScript object id of the node wrapper.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns the box model for the node, including coordinates for content, padding, border, and margin boxes.

TYPE: Command[GetBoxModelResponse]

get_document staticmethod
get_document(depth=None, pierce=None)

Returns the root DOM node (and optionally the subtree) to the caller.

This is typically the first command called when interacting with the DOM, as it provides access to the document's root node. From this root, you can traverse to any other element on the page. This command implicitly enables DOM domain events for the current target, making it a good starting point for DOM interaction.

PARAMETER DESCRIPTION
depth

Maximum depth at which children should be retrieved (default is 1). Use -1 for the entire subtree or provide an integer greater than 0.

TYPE: Optional[int] DEFAULT: None

pierce

Whether iframes and shadow roots should be traversed when returning the subtree (default is false).

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns the root DOM node.

TYPE: Command[GetDocumentResponse]

get_node_for_location staticmethod
get_node_for_location(x, y, include_user_agent_shadow_dom=None, ignore_pointer_events_none=None)

Returns node id at given location on the page.

This command is particularly useful for bridging the gap between visual/pixel-based information and the DOM structure. It allows you to convert screen coordinates to actual DOM elements, which is essential for creating inspection tools or for testing spatially-oriented interactions.

PARAMETER DESCRIPTION
x

X coordinate relative to the main frame's viewport.

TYPE: int

y

Y coordinate relative to the main frame's viewport.

TYPE: int

include_user_agent_shadow_dom

Whether to include nodes in user agent shadow roots.

TYPE: Optional[bool] DEFAULT: None

ignore_pointer_events_none

Whether to ignore pointer-events:none and test elements underneath them.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns the node at the given location, including frame information when available.

TYPE: Command[GetNodeForLocationResponse]

get_outer_html staticmethod
get_outer_html(node_id=None, backend_node_id=None, object_id=None)

Returns node's HTML markup, including the node itself and all its children.

This command provides a way to access the complete HTML representation of an element, making it valuable for when you need to extract, analyze, or verify HTML content. It's more comprehensive than just getting text content as it preserves the full markup structure including tags, attributes, and child elements.

PARAMETER DESCRIPTION
node_id

Identifier of the node.

TYPE: Optional[int] DEFAULT: None

backend_node_id

Identifier of the backend node.

TYPE: Optional[int] DEFAULT: None

object_id

JavaScript object id of the node wrapper.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns the outer HTML markup of the node.

TYPE: Command[GetOuterHTMLResponse]

hide_highlight staticmethod
hide_highlight()

Hides any DOM element highlight.

This command is particularly useful in automation workflows where multiple elements are highlighted in sequence, and you need to clear previous highlights before proceeding to the next element to avoid visual clutter or interference.

RETURNS DESCRIPTION
Command

CDP command to hide DOM element highlights.

TYPE: Command[Response]

highlight_node staticmethod
highlight_node()

Highlights DOM node.

Highlighting nodes is especially valuable during development and debugging sessions to visually confirm which elements are being selected by selectors or coordinates.

RETURNS DESCRIPTION
Command

CDP command to highlight a DOM node.

TYPE: Command[Response]

highlight_rect staticmethod
highlight_rect()

Highlights given rectangle.

Unlike node highlighting, rectangle highlighting allows highlighting arbitrary regions of the page, which is useful for highlighting computed areas or regions that don't correspond directly to DOM elements.

RETURNS DESCRIPTION
Command

CDP command to highlight a rectangular area.

TYPE: Command[Response]

move_to staticmethod
move_to(node_id, target_node_id, insert_before_node_id=None)

Moves node into the new container, placing it before the given anchor.

This command allows for more complex DOM restructuring than simple attribute or content changes. It's particularly useful when testing applications that involve rearranging elements, such as sortable lists, kanban boards, or drag-and-drop interfaces.

PARAMETER DESCRIPTION
node_id

Id of the node to move.

TYPE: int

target_node_id

Id of the element to drop the moved node into.

TYPE: int

insert_before_node_id

Drop node before this one (if absent, the moved node becomes the last child of target_node_id).

TYPE: Optional[int] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command to move a node, returning the new id of the moved node.

TYPE: Command[MoveToResponse]

query_selector staticmethod
query_selector(node_id, selector)

Executes querySelector on a given node.

This method is one of the most fundamental tools for element location, allowing the use of standard CSS selectors to find elements in the DOM. Unlike JavaScript's querySelector, this can be executed on any node (not just document), enabling scoped searches within specific sections of the page.

PARAMETER DESCRIPTION
node_id

Id of the node to query upon.

TYPE: int

selector

CSS selector string.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command that returns the first element matching the selector.

TYPE: Command[QuerySelectorResponse]

query_selector_all staticmethod
query_selector_all(node_id, selector)

Executes querySelectorAll on a given node.

This method extends querySelector by returning all matching elements rather than just the first one. This is essential for operations that need to process multiple elements, such as extracting data from tables, lists, or grids, or verifying that the correct number of elements are present.

PARAMETER DESCRIPTION
node_id

Id of the node to query upon.

TYPE: int

selector

CSS selector string.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command that returns all elements matching the selector.

TYPE: Command[QuerySelectorAllResponse]

remove_attribute staticmethod
remove_attribute(node_id, name)

Removes attribute with given name from an element with given id.

This command allows direct manipulation of element attributes without using JavaScript in the page context. It's useful for testing how elements behave when specific attributes are removed or for preparing elements for specific test conditions.

PARAMETER DESCRIPTION
node_id

Id of the element to remove attribute from.

TYPE: int

name

Name of the attribute to remove.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command to remove the specified attribute.

TYPE: Command[Response]

remove_node staticmethod
remove_node(node_id)

Removes node with given id.

This command allows direct removal of DOM elements, which can be useful when testing how an application responds to missing elements or when simplifying a page for focused testing scenarios.

PARAMETER DESCRIPTION
node_id

Id of the node to remove.

TYPE: int

RETURNS DESCRIPTION
Command

CDP command to remove the specified node.

TYPE: Command[Response]

request_child_nodes staticmethod
request_child_nodes(node_id, depth=None, pierce=None)

Requests that children of the node with given id are returned to the caller.

This method is particularly useful when dealing with large DOM trees, as it allows for more efficient exploration by loading children on demand rather than loading the entire tree at once. Child nodes are returned as setChildNodes events.

PARAMETER DESCRIPTION
node_id

Id of the node to get children for.

TYPE: int

depth

The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree.

TYPE: Optional[int] DEFAULT: None

pierce

Whether or not iframes and shadow roots should be traversed.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command to request child nodes.

TYPE: Command[Response]

request_node staticmethod
request_node(object_id)

Requests that the node is sent to the caller given the JavaScript node object reference.

This method bridges the gap between JavaScript objects in the page context and the CDP's node representation system, allowing automation to work with elements that might only be available as JavaScript references (e.g., from event handlers).

PARAMETER DESCRIPTION
object_id

JavaScript object id to convert into a Node.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command that returns the Node id for the given object.

TYPE: Command[RequestNodeResponse]

resolve_node staticmethod
resolve_node(node_id=None, backend_node_id=None, object_group=None, execution_context_id=None)

Resolves the JavaScript node object for a given NodeId or BackendNodeId.

This method provides the opposite functionality of requestNode - instead of getting a CDP node from a JavaScript object, it gets a JavaScript object from a CDP node. This enables executing JavaScript operations on nodes identified through CDP.

PARAMETER DESCRIPTION
node_id

Id of the node to resolve.

TYPE: Optional[int] DEFAULT: None

backend_node_id

Backend id of the node to resolve.

TYPE: Optional[int] DEFAULT: None

object_group

Symbolic group name that can be used to release multiple objects.

TYPE: Optional[str] DEFAULT: None

execution_context_id

Execution context in which to resolve the node.

TYPE: Optional[int] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns a JavaScript object wrapper for the node.

TYPE: Command[ResolveNodeResponse]

scroll_into_view_if_needed staticmethod
scroll_into_view_if_needed(node_id=None, backend_node_id=None, object_id=None, rect=None)

Scrolls the specified node into view if not already visible.

This command is crucial for reliable web automation, as it ensures elements are actually visible in the viewport before attempting interactions. Modern websites often use lazy loading and have long scrollable areas, making this command essential for working with elements that may not be initially visible.

PARAMETER DESCRIPTION
node_id

Identifier of the node.

TYPE: Optional[int] DEFAULT: None

backend_node_id

Identifier of the backend node.

TYPE: Optional[int] DEFAULT: None

object_id

JavaScript object id of the node wrapper.

TYPE: Optional[str] DEFAULT: None

rect

Optional rect to scroll into view, relative to the node bounds.

TYPE: Optional[Rect] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command to scroll the element into view.

TYPE: Command[Response]

set_attributes_as_text staticmethod
set_attributes_as_text(node_id, text, name=None)

Sets attribute for an element with given id, using text representation.

This command allows for more complex attribute manipulation than set_attribute_value, as it accepts a text representation that can potentially define multiple attributes or include special formatting. It's particularly useful when trying to replicate exactly how attributes would be defined in HTML source code.

PARAMETER DESCRIPTION
node_id

Id of the element to set attribute for.

TYPE: int

text

Text with a new attribute value.

TYPE: str

name

Attribute name to replace with new text value.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command to set an attribute as text.

TYPE: Command[Response]

set_attribute_value staticmethod
set_attribute_value(node_id, name, value)

Sets attribute for element with given id.

This command provides direct control over element attributes without using JavaScript, which is essential for testing how applications respond to attribute changes or for setting up specific test conditions by controlling element attributes directly.

PARAMETER DESCRIPTION
node_id

Id of the element to set attribute for.

TYPE: int

name

Attribute name.

TYPE: str

value

Attribute value.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command to set an attribute value.

TYPE: Command[Response]

set_file_input_files staticmethod
set_file_input_files(files, node_id=None, backend_node_id=None, object_id=None)

Sets files for the given file input element.

This command solves one of the most challenging automation problems: working with file inputs. It bypasses the OS-level file dialog that normally appears when clicking a file input, allowing automated tests to provide files programmatically.

PARAMETER DESCRIPTION
files

list of file paths to set.

TYPE: list[str]

node_id

Identifier of the node.

TYPE: Optional[int] DEFAULT: None

backend_node_id

Identifier of the backend node.

TYPE: Optional[int] DEFAULT: None

object_id

JavaScript object id of the node wrapper.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command to set files for a file input element.

TYPE: Command[Response]

set_node_name staticmethod
set_node_name(node_id, name)

Sets node name for a node with given id.

This command allows changing the actual tag name of an element, which can be useful for testing how applications handle different types of elements or for testing the impact of semantic HTML choices on accessibility and behavior.

PARAMETER DESCRIPTION
node_id

Id of the node to set name for.

TYPE: int

name

New node name.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command that returns the new node id after the name change.

TYPE: Command[SetNodeNameResponse]

set_node_value staticmethod
set_node_value(node_id, value)

Sets node value for a node with given id.

This command is particularly useful for updating the content of text nodes and comments, allowing direct manipulation of text content without changing the surrounding HTML structure.

PARAMETER DESCRIPTION
node_id

Id of the node to set value for.

TYPE: int

value

New node value.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command to set a node's value.

TYPE: Command[Response]

set_outer_html staticmethod
set_outer_html(node_id, outer_html)

Sets node HTML markup, replacing existing one.

This is one of the most powerful DOM manipulation commands, as it allows completely replacing an element and all its children with new HTML. This is useful for making major structural changes to the page or for testing how applications handle dynamically inserted content.

PARAMETER DESCRIPTION
node_id

Id of the node to set outer HTML for.

TYPE: int

outer_html

HTML markup to set.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command to set the outer HTML of a node.

TYPE: Command[Response]

collect_class_names_from_subtree staticmethod
collect_class_names_from_subtree(node_id)

Collects class names for the node with given id and all of its children.

This method is valuable for understanding the styling landscape of a page, especially in complex applications where multiple CSS frameworks might be in use or where classes are dynamically applied.

PARAMETER DESCRIPTION
node_id

Id of the node to collect class names for.

TYPE: int

RETURNS DESCRIPTION
Command

CDP command that returns a list of all unique class names in the subtree.

TYPE: Command[CollectClassNamesFromSubtreeResponse]

copy_to staticmethod
copy_to(node_id, target_node_id, insert_before_node_id=None)

Creates a deep copy of the specified node and places it into the target container.

Unlike move_to, this command creates a copy of the node, leaving the original intact. This is useful when you want to duplicate content rather than move it, such as when testing how multiple instances of the same component behave.

PARAMETER DESCRIPTION
node_id

Id of the node to copy.

TYPE: int

target_node_id

Id of the element to drop the copy into.

TYPE: int

insert_before_node_id

Drop the copy before this node (if absent, the copy becomes the last child of target_node_id).

TYPE: Optional[int] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns the id of the new copy.

TYPE: Command[CopyToResponse]

discard_search_results staticmethod
discard_search_results(search_id)

Discards search results from the session with the given id.

This method helps manage resources when performing multiple searches during a session, allowing explicit cleanup of search results that are no longer needed.

PARAMETER DESCRIPTION
search_id

Unique search session identifier.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command to discard search results.

TYPE: Command[Response]

get_anchor_element staticmethod
get_anchor_element(node_id, anchor_specifier=None)

Finds the closest ancestor node that is an anchor element for the given node.

This method is useful when working with content inside links or when you need to find the enclosing link element for text or other elements. This helps in cases where you might locate text but need to find the actual link around it.

PARAMETER DESCRIPTION
node_id

Id of the node to search for an anchor around.

TYPE: int

anchor_specifier

Optional specifier for anchor tag properties.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns the anchor element node information.

TYPE: Command[GetAnchorElementResponse]

get_container_for_node staticmethod
get_container_for_node(node_id, container_name=None, physical_axes=None, logical_axes=None, queries_scroll_state=None)

Finds a containing element for the given node based on specified parameters.

This method helps in understanding the structural and layout context of elements, particularly in complex layouts using CSS features like flexbox, grid, or when dealing with scrollable containers.

PARAMETER DESCRIPTION
node_id

Id of the node to find the container for.

TYPE: int

container_name

Name of the container to look for (e.g., 'scrollable', 'flex').

TYPE: Optional[str] DEFAULT: None

physical_axes

Physical axes to consider (Horizontal, Vertical, Both).

TYPE: Optional[PhysicalAxes] DEFAULT: None

logical_axes

Logical axes to consider (Inline, Block, Both).

TYPE: Optional[LogicalAxes] DEFAULT: None

queries_scroll_state

Whether to query scroll state or not.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns information about the containing element.

TYPE: Command[GetContainerForNodeResponse]

get_content_quads staticmethod
get_content_quads(node_id=None, backend_node_id=None, object_id=None)

Returns quads that describe node position on the page.

This method provides detailed geometric information about an element's position on the page, accounting for any transformations, rotations, or other CSS effects. This is more precise than getBoxModel for complex layouts.

PARAMETER DESCRIPTION
node_id

Identifier of the node.

TYPE: Optional[int] DEFAULT: None

backend_node_id

Identifier of the backend node.

TYPE: Optional[int] DEFAULT: None

object_id

JavaScript object id of the node wrapper.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns the quads describing the node position.

TYPE: Command[GetContentQuadsResponse]

get_detached_dom_nodes staticmethod
get_detached_dom_nodes()

Returns information about detached DOM tree elements.

This method is primarily useful for debugging memory issues related to the DOM, as detached DOM nodes (nodes no longer in the document but still referenced in JavaScript) are a common cause of memory leaks in web applications.

RETURNS DESCRIPTION
Command

CDP command that returns information about detached DOM nodes.

TYPE: Command[GetDetachedDomNodesResponse]

get_element_by_relation staticmethod
get_element_by_relation(node_id, relation)

Retrieves an element related to the given one in a specified way.

This method provides a way to find elements based on their relationships to other elements, such as finding the next focusable element after a given one. This is useful for simulating keyboard navigation or for analyzing element relationships.

PARAMETER DESCRIPTION
node_id

Id of the reference node.

TYPE: int

relation

Type of relationship (e.g., nextSibling, previousSibling, firstChild).

TYPE: ElementRelation

RETURNS DESCRIPTION
Command

CDP command that returns the related element node.

TYPE: Command[GetElementByRelationResponse]

get_file_info staticmethod
get_file_info(object_id)

Returns file information for the given File object.

This method is useful when working with file inputs and the File API, providing access to file metadata like name, size, and MIME type for files selected in file input elements or created programmatically.

PARAMETER DESCRIPTION
object_id

JavaScript object id of the File object to get info for.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command that returns file information.

TYPE: Command[GetFileInfoResponse]

get_frame_owner staticmethod
get_frame_owner(frame_id)

Returns iframe element that owns the given frame.

This method is essential when working with pages that contain iframes, as it allows mapping between frame IDs (used in CDP) and the actual iframe elements in the parent document.

PARAMETER DESCRIPTION
frame_id

Id of the frame to get the owner element for.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command that returns the frame owner element.

TYPE: Command[GetFrameOwnerResponse]

get_nodes_for_subtree_by_style staticmethod
get_nodes_for_subtree_by_style(node_id, computed_styles, pierce=None)

Finds nodes with a given computed style in a subtree.

This method allows finding elements based on their computed styles rather than just structure or attributes. This is powerful for testing visual aspects of a page or for finding elements that match specific visual criteria.

PARAMETER DESCRIPTION
node_id

Node to start the search from.

TYPE: int

computed_styles

list of computed style properties to match against.

TYPE: list[CSSComputedStyleProperty]

pierce

Whether or not iframes and shadow roots should be traversed.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns nodes matching the specified styles.

TYPE: Command[GetNodesForSubtreeByStyleResponse]

get_node_stack_traces staticmethod
get_node_stack_traces(node_id)

Gets stack traces associated with a specific node.

This method is powerful for debugging, as it reveals the JavaScript execution paths that led to the creation of specific DOM elements, helping developers understand the relationship between their code and the resulting DOM structure.

PARAMETER DESCRIPTION
node_id

Id of the node to get stack traces for.

TYPE: int

RETURNS DESCRIPTION
Command

CDP command that returns stack traces related to the node.

TYPE: Command[GetNodeStackTracesResponse]

get_querying_descendants_for_container staticmethod
get_querying_descendants_for_container(node_id)

Returns the querying descendants for container.

This method is particularly useful for working with CSS Container Queries, helping to identify which descendant elements are affected by or querying a particular container element.

PARAMETER DESCRIPTION
node_id

Id of the container node to find querying descendants for.

TYPE: int

RETURNS DESCRIPTION
Command

CDP command that returns querying descendant information.

TYPE: Command[GetQueryingDescendantForContainerResponse]

get_relayout_boundary staticmethod
get_relayout_boundary(node_id)

Returns the root of the relayout boundary for the given node.

This method helps in understanding layout performance by identifying the boundary of layout recalculations when a particular element changes. This is valuable for optimizing rendering performance.

PARAMETER DESCRIPTION
node_id

Id of the node to find relayout boundary for.

TYPE: int

RETURNS DESCRIPTION
Command

CDP command that returns the relayout boundary node.

TYPE: Command[GetRelayoutBoundaryResponse]

get_search_results staticmethod
get_search_results(search_id, from_index, to_index)

Returns search results from given fromIndex to given toIndex from a search.

This method is used in conjunction with performSearch to retrieve search results in batches, which is essential when dealing with large result sets that might be inefficient to transfer all at once.

PARAMETER DESCRIPTION
search_id

Unique search session identifier from performSearch.

TYPE: str

from_index

Start index to retrieve results from.

TYPE: int

to_index

End index to retrieve results to (exclusive).

TYPE: int

RETURNS DESCRIPTION
Command

CDP command that returns the requested search results.

TYPE: Command[GetSearchResultsResponse]

get_top_layer_elements staticmethod
get_top_layer_elements()

Returns all top layer elements in the document.

This method is valuable for working with modern web UIs that make extensive use of overlays, modals, dropdowns, and other elements that need to appear above the normal document flow.

RETURNS DESCRIPTION
Command

CDP command that returns the top layer element information.

TYPE: Command[GetTopLayerElementsResponse]

mark_undoable_state staticmethod
mark_undoable_state()

Marks last undoable state.

This method helps in managing DOM manipulation state, allowing the creation of savepoints that can be reverted to with the undo command. This is useful for complex sequences of DOM operations that should be treated as a unit.

RETURNS DESCRIPTION
Command

CDP command to mark the current state as undoable.

TYPE: Command[Response]

perform_search(query, include_user_agent_shadow_dom=None)

Searches for a given string in the DOM tree.

This method initiates a search across the DOM tree, supporting plain text, CSS selectors, or XPath expressions. It's a powerful way to find elements or content across the entire document without knowing the exact structure.

PARAMETER DESCRIPTION
query

Plain text or query selector or XPath search query.

TYPE: str

include_user_agent_shadow_dom

True to include user agent shadow DOM in the search.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns search results identifier and count.

TYPE: Command[PerformSearchResponse]

push_node_by_path_to_frontend staticmethod
push_node_by_path_to_frontend(path)

Requests that the node is sent to the caller given its path.

This method provides an alternative way to reference nodes when node IDs aren't available, using path expressions instead. This can be useful when integrating with systems that identify elements by path rather than by ID.

PARAMETER DESCRIPTION
path

Path to node in the proprietary format.

TYPE: str

RETURNS DESCRIPTION
Command

CDP command that returns the node id for the node.

TYPE: Command[PushNodeByPathToFrontendResponse]

push_nodes_by_backend_ids_to_frontend staticmethod
push_nodes_by_backend_ids_to_frontend(backend_node_ids)

Requests that a batch of nodes is sent to the caller given their backend node ids.

This method allows for efficient batch processing when you have multiple backend node IDs and need to convert them to frontend node IDs for further operations.

PARAMETER DESCRIPTION
backend_node_ids

The array of backend node ids.

TYPE: list[int]

RETURNS DESCRIPTION
Command

CDP command that returns an array of node ids.

TYPE: Command[PushNodesByBackendIdsToFrontendResponse]

redo staticmethod
redo()

Re-does the last undone action.

This method works in conjunction with undo and markUndoableState to provide a transactional approach to DOM manipulations, allowing for stepping back and forth through a sequence of changes.

RETURNS DESCRIPTION
Command

CDP command to redo the last undone action.

TYPE: Command[Response]

set_inspected_node staticmethod
set_inspected_node(node_id)

Enables console to refer to the node with given id via $x command line API.

This method creates a bridge between automated testing/scripting and manual console interaction, making it easy to reference specific nodes in the console for debugging or experimentation.

PARAMETER DESCRIPTION
node_id

DOM node id to be accessible by means of $x command line API.

TYPE: int

RETURNS DESCRIPTION
Command

CDP command to set the inspected node.

TYPE: Command[Response]

set_node_stack_traces_enabled staticmethod
set_node_stack_traces_enabled(enable)

Sets if stack traces should be captured for Nodes.

This method enables or disables the collection of stack traces when DOM nodes are created, which can be extremely valuable for debugging complex applications to understand where and why specific DOM elements are being created.

PARAMETER DESCRIPTION
enable

Enable or disable stack trace collection.

TYPE: bool

RETURNS DESCRIPTION
Command

CDP command to enable or disable node stack traces.

TYPE: Command[Response]

undo staticmethod
undo()

Undoes the last performed action.

This method works in conjunction with redo and markUndoableState to provide transactional control over DOM manipulations, allowing for reverting changes when needed.

RETURNS DESCRIPTION
Command

CDP command to undo the last performed action.

TYPE: Command[Response]

Network Commands

pydoll.commands.network_commands

NetworkCommands

Implementation of Chrome DevTools Protocol for the Network domain.

This class provides commands for monitoring and manipulating network activities, enabling detailed inspection and control over HTTP requests and responses. The Network domain exposes comprehensive network-related information including: - Request/response headers and bodies - Resource timing and caching behavior - Cookie management and security details - Network conditions emulation - Traffic interception and modification

The commands allow developers to analyze performance, debug network issues, and test application behavior under various network conditions.

clear_browser_cache staticmethod
clear_browser_cache()

Clears browser cache storage.

This command is essential for testing cache behavior and ensuring fresh resource loading. It affects all cached resources including: - CSS/JavaScript files - Images and media assets - API response caching

Use cases: - Testing cache invalidation strategies - Reproducing issues with stale content - Performance benchmarking without cache influence

RETURNS DESCRIPTION
Command

CDP command to clear the entire browser cache

TYPE: Command[Response]

clear_browser_cookies staticmethod
clear_browser_cookies()

Command to clear all cookies stored in the browser.

This can be beneficial for testing scenarios where you need to simulate a fresh user session without any previously stored cookies that might affect the application's behavior.

RETURNS DESCRIPTION
Command[Response]

Command[Response]: A command to clear all cookies in the browser.

delete_cookies staticmethod
delete_cookies(name, url=None, domain=None, path=None, partition_key=None)

Deletes browser cookies with matching criteria.

Provides granular control over cookie removal through multiple parameters: - Delete by name only (affects all matching cookies) - Scope deletion using URL, domain, or path - Handle partitioned cookies for privacy-aware applications

PARAMETER DESCRIPTION
name

Name of the cookies to remove (required)

TYPE: str

url

Delete cookies for specific URL (domain/path must match)

TYPE: Optional[str] DEFAULT: None

domain

Exact domain for cookie deletion

TYPE: Optional[str] DEFAULT: None

path

Exact path for cookie deletion

TYPE: Optional[str] DEFAULT: None

partition_key

Partition key attributes for cookie isolation

TYPE: Optional[CookiePartitionKey] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command to execute selective cookie deletion

TYPE: Command[Response]

disable staticmethod
disable()

Stops network monitoring and event reporting.

Preserves network state but stops: - Request/response events - WebSocket message tracking - Loading progress notifications

Use when: - Reducing overhead during non-network operations - Pausing monitoring temporarily - Finalizing network-related tests

RETURNS DESCRIPTION
Command

CDP command to disable network monitoring

TYPE: Command[Response]

enable staticmethod
enable(max_total_buffer_size=None, max_resource_buffer_size=None, max_post_data_size=None)

Enables network monitoring with configurable buffers.

PARAMETER DESCRIPTION
max_total_buffer_size

Total memory buffer for network data (bytes)

TYPE: Optional[int] DEFAULT: None

max_resource_buffer_size

Per-resource buffer limit (bytes)

TYPE: Optional[int] DEFAULT: None

max_post_data_size

Maximum POST payload to capture (bytes)

TYPE: Optional[int] DEFAULT: None

Recommended settings: - Increase buffers for long-running sessions - Adjust post size for API testing - Monitor memory usage with large buffers

RETURNS DESCRIPTION
Command

CDP command to enable network monitoring

TYPE: Command[Response]

get_cookies staticmethod
get_cookies(urls=None)

Retrieves cookies matching specified URLs.

PARAMETER DESCRIPTION
urls

list of URLs to scope cookie retrieval

TYPE: Optional[list[str]] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command returning cookie details including: - Name, value, and attributes - Security and scope parameters - Expiration and size information

TYPE: Command[GetCookiesResponse]

Usage notes: - Empty URL list returns all cookies - Includes HTTP-only and secure cookies - Shows partitioned cookie status

get_request_post_data staticmethod
get_request_post_data(request_id)

Retrieves POST data from a specific network request.

Essential for: - Form submission analysis - API request debugging - File upload monitoring - Security testing

PARAMETER DESCRIPTION
request_id

Unique identifier for the network request

TYPE: str

RETURNS DESCRIPTION
Command

CDP command that returns: - Raw POST data content - Multipart form data (excluding file contents) - Content encoding information

TYPE: Command[GetRequestPostDataResponse]

Note: Large POST bodies may be truncated based on buffer settings

get_response_body staticmethod
get_response_body(request_id)

Retrieves the full content of a network response.

Supports various content types: - Text-based resources (HTML, CSS, JSON) - Base64-encoded binary content (images, media) - Gzip/deflate compressed responses

PARAMETER DESCRIPTION
request_id

Unique network request identifier

TYPE: str

Important considerations: - Response must be available in browser memory - Large responses may require streaming approaches - Sensitive data should be handled securely

RETURNS DESCRIPTION
Command

CDP command returning response body and encoding details

TYPE: Command[GetResponseBodyResponse]

set_cache_disabled staticmethod
set_cache_disabled(cache_disabled)

Controls browser's cache mechanism.

Use cases: - Testing resource update behavior - Forcing fresh content loading - Performance impact analysis - Cache-busting scenarios

PARAMETER DESCRIPTION
cache_disabled

True to disable caching, False to enable

TYPE: bool

RETURNS DESCRIPTION
Command

CDP command to modify cache behavior

TYPE: Command[Response]

Note: Affects all requests until re-enabled

set_cookie(name, value, url=None, domain=None, path=None, secure=None, http_only=None, same_site=None, expires=None, priority=None, same_party=None, source_scheme=None, source_port=None, partition_key=None)

Creates or updates a cookie with specified attributes.

Comprehensive cookie control supporting: - Session and persistent cookies - Security attributes (Secure, HttpOnly) - SameSite policies - Cookie partitioning - Priority levels

PARAMETER DESCRIPTION
name

Cookie name

TYPE: str

value

Cookie value

TYPE: str

url

Target URL for the cookie

TYPE: Optional[str] DEFAULT: None

domain

Cookie domain scope

TYPE: Optional[str] DEFAULT: None

path

Cookie path scope

TYPE: Optional[str] DEFAULT: None

secure

Require HTTPS

TYPE: Optional[bool] DEFAULT: None

http_only

Prevent JavaScript access

TYPE: Optional[bool] DEFAULT: None

same_site

Cross-site access policy

TYPE: Optional[CookieSameSite] DEFAULT: None

expires

Expiration timestamp

TYPE: Optional[float] DEFAULT: None

priority

Cookie priority level

TYPE: Optional[CookiePriority] DEFAULT: None

same_party

First-Party Sets flag

TYPE: Optional[bool] DEFAULT: None

source_scheme

Cookie source context

TYPE: Optional[CookieSourceScheme] DEFAULT: None

source_port

Source port restriction

TYPE: Optional[int] DEFAULT: None

partition_key

Storage partition key

TYPE: Optional[CookiePartitionKey] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command that returns success status

TYPE: Command[SetCookieResponse]

Security considerations: - Use secure flag for sensitive data - Consider SameSite policies - Be aware of cross-site implications

set_cookies staticmethod
set_cookies(cookies)

Sets multiple cookies in a single operation.

Efficient for: - Batch cookie operations - Session state restoration - Testing multiple authentication states - Cross-domain cookie setup

PARAMETER DESCRIPTION
cookies

list of cookie parameters including name, value, and attributes

TYPE: list[SetCookieParams]

RETURNS DESCRIPTION
Command

CDP command for bulk cookie setting

TYPE: Command[Response]

Performance note: - More efficient than multiple set_cookie calls - Consider memory impact with large batches

set_extra_http_headers staticmethod
set_extra_http_headers(headers)

Applies custom HTTP headers to all subsequent requests.

Enables advanced scenarios: - A/B testing with custom headers - Authentication bypass for testing - Content negotiation simulations - Security header validation

PARAMETER DESCRIPTION
headers

list of key-value header pairs

TYPE: list[HeaderEntry]

Security notes: - Headers are applied browser-wide - Sensitive headers (e.g., Authorization) persist until cleared - Use with caution in shared environments

RETURNS DESCRIPTION
Command

CDP command to set global HTTP headers

TYPE: Command[Response]

set_useragent_override staticmethod
set_useragent_override(user_agent, accept_language=None, platform=None, user_agent_metadata=None)

Overrides the browser's User-Agent string.

Use cases: - Device/browser simulation - Compatibility testing - Content negotiation - Bot detection bypass

PARAMETER DESCRIPTION
user_agent

Complete User-Agent string

TYPE: str

accept_language

Language preference header

TYPE: Optional[str] DEFAULT: None

platform

Platform identifier

TYPE: Optional[str] DEFAULT: None

user_agent_metadata

Detailed UA metadata

TYPE: Optional[UserAgentMetadata] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command to override user agent

TYPE: Command[Response]

Testing considerations: - Affects all subsequent requests - May impact server-side behavior - Consider mobile/desktop differences

clear_accepted_encodings_override staticmethod
clear_accepted_encodings_override()

Restores default content encoding acceptance.

Effects: - Resets compression preferences - Restores default Accept-Encoding header - Allows server-chosen encoding

Use when: - Testing encoding fallbacks - Debugging compression issues - Resetting after encoding tests

RETURNS DESCRIPTION
Command

CDP command to clear encoding overrides

TYPE: Command[Response]

enable_reporting_api staticmethod
enable_reporting_api(enabled)

Controls the Reporting API functionality.

Features: - Network error reporting - Deprecation notices - CSP violation reports - CORS issues

PARAMETER DESCRIPTION
enabled

True to enable, False to disable

TYPE: bool

RETURNS DESCRIPTION
Command

CDP command to configure Reporting API

TYPE: Command[Response]

Note: Requires browser support for Reporting API

search_in_response_body staticmethod
search_in_response_body(request_id, query, case_sensitive=False, is_regex=False)

Searches for content within response bodies.

Powerful for: - Content verification - Security scanning - Data extraction - Response validation

PARAMETER DESCRIPTION
request_id

Target response identifier

TYPE: str

query

Search string or pattern

TYPE: str

case_sensitive

Match case sensitivity

TYPE: bool DEFAULT: False

is_regex

Use regular expression matching

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
Command

CDP command returning match results

TYPE: Command[SearchInResponseBodyResponse]

Performance tip: - Use specific queries for large responses - Consider regex complexity

set_blocked_urls staticmethod
set_blocked_urls(urls)

Blocks specified URLs from loading.

Key features: - Pattern-based URL blocking - Resource type filtering - Network request prevention - Error simulation

PARAMETER DESCRIPTION
urls

list of URL patterns to block Supports wildcards and pattern matching

TYPE: list[str]

RETURNS DESCRIPTION
Command

CDP command to set URL blocking rules

TYPE: Command[Response]

Common applications: - Ad/tracker blocking simulation - Resource loading control - Error handling testing - Network isolation testing

set_bypass_service_worker staticmethod
set_bypass_service_worker(bypass)

Controls Service Worker interception of network requests.

Use cases: - Testing direct network behavior - Bypassing offline functionality - Debug caching issues - Performance comparison

PARAMETER DESCRIPTION
bypass

True to skip Service Worker, False to allow

TYPE: bool

RETURNS DESCRIPTION
Command

CDP command to configure Service Worker behavior

TYPE: Command[Response]

Impact: - Affects offline capabilities - Changes caching behavior - Modifies push notifications

get_certificate staticmethod
get_certificate(origin)

Retrieves SSL/TLS certificate information for a domain.

Provides: - Certificate chain details - Validation status - Expiration information - Issuer details

PARAMETER DESCRIPTION
origin

Target domain for certificate inspection

TYPE: str

RETURNS DESCRIPTION
Command

CDP command returning certificate data

TYPE: Command[GetCertificateResponse]

Security applications: - Certificate validation - SSL/TLS verification - Security assessment - Chain of trust verification

get_response_body_for_interception staticmethod
get_response_body_for_interception(interception_id)

Retrieves response body from an intercepted request.

Essential for: - Response modification - Content inspection - Security testing - API response validation

PARAMETER DESCRIPTION
interception_id

Identifier for intercepted request

TYPE: str

RETURNS DESCRIPTION
Command

CDP command providing intercepted response content

TYPE: Command[GetResponseBodyForInterceptionResponse]

Note: - Must be used with interception enabled - Supports streaming responses - Handles various content types

set_accepted_encodings staticmethod
set_accepted_encodings(encodings)

Specifies accepted content encodings for requests.

Controls: - Compression algorithms - Transfer encoding - Content optimization

PARAMETER DESCRIPTION
encodings

list of accepted encoding methods (gzip, deflate, br, etc.)

TYPE: list[ContentEncoding]

RETURNS DESCRIPTION
Command

CDP command to set encoding preferences

TYPE: Command[Response]

Performance implications: - Affects bandwidth usage - Impacts response time - Changes server behavior

set_attach_debug_stack staticmethod
set_attach_debug_stack(enabled)

Enables/disables debug stack attachment to requests.

Debug features: - Stack trace collection - Request origin tracking - Initialization context - Call site identification

PARAMETER DESCRIPTION
enabled

True to attach debug info, False to disable

TYPE: bool

RETURNS DESCRIPTION
Command

CDP command to configure debug stack attachment

TYPE: Command[Response]

Performance note: - May impact performance when enabled - Useful for development/debugging - Consider memory usage

set_cookie_controls(enable_third_party_cookie_restriction, disable_third_party_cookie_metadata=None, disable_third_party_cookie_heuristics=None)

Configures third-party cookie handling policies.

Privacy features: - Cookie access control - Third-party restrictions - Tracking prevention - Privacy policy enforcement

PARAMETER DESCRIPTION
enable_third_party_cookie_restriction

Enable restrictions

TYPE: bool

disable_third_party_cookie_metadata

Skip metadata checks

TYPE: Optional[bool] DEFAULT: None

disable_third_party_cookie_heuristics

Disable detection logic

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command to set cookie control policies

TYPE: Command[Response]

Security implications: - Affects cross-site tracking - Changes authentication behavior - Impacts embedded content

stream_resource_content staticmethod
stream_resource_content(request_id)

Enables streaming of response content.

Useful for: - Large file downloads - Progressive loading - Memory optimization - Real-time processing

PARAMETER DESCRIPTION
request_id

Target request identifier

TYPE: str

RETURNS DESCRIPTION
Command

CDP command to initiate content streaming

TYPE: Command[StreamResourceContentResponse]

Best practices: - Monitor memory usage - Handle stream chunks efficiently - Consider error recovery

take_response_body_for_interception_as_stream staticmethod
take_response_body_for_interception_as_stream(interception_id)

Creates a stream for intercepted response body.

Applications: - Large response handling - Content modification - Bandwidth optimization - Progressive processing

PARAMETER DESCRIPTION
interception_id

Intercepted response identifier

TYPE: str

RETURNS DESCRIPTION
Command

CDP command returning stream handle

TYPE: Command[TakeResponseBodyForInterceptionAsStreamResponse]

Stream handling: - Supports chunked transfer - Manages memory efficiently - Enables real-time processing

emulate_network_conditions staticmethod
emulate_network_conditions(offline, latency, download_throughput, upload_throughput, connection_type=None, packet_loss=None, packet_queue_length=None, packet_reordering=None)

Emulates custom network conditions for realistic testing scenarios.

Simulates various network profiles including: - Offline mode - High-latency connections - Bandwidth throttling - Unreliable network characteristics

PARAMETER DESCRIPTION
offline

Simulate complete network disconnection

TYPE: bool

latency

Minimum latency in milliseconds (round-trip time)

TYPE: float

download_throughput

Max download speed (bytes/sec, -1 to disable)

TYPE: float

upload_throughput

Max upload speed (bytes/sec, -1 to disable)

TYPE: float

connection_type

Network connection type (cellular, wifi, etc.)

TYPE: Optional[ConnectionType] DEFAULT: None

packet_loss

Simulated packet loss percentage (0-100)

TYPE: Optional[float] DEFAULT: None

packet_queue_length

Network buffer size simulation

TYPE: Optional[int] DEFAULT: None

packet_reordering

Enable packet order randomization

TYPE: Optional[bool] DEFAULT: None

Typical use cases: - Testing progressive loading states - Validating offline-first functionality - Performance optimization under constrained networks

RETURNS DESCRIPTION
Command

CDP command to activate network emulation

TYPE: Command[Response]

get_security_isolation_status staticmethod
get_security_isolation_status(frame_id=None)

Retrieves security isolation information.

Provides: - CORS status - Cross-origin isolation - Security context - Frame isolation

PARAMETER DESCRIPTION
frame_id

Optional frame to check

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command returning isolation status

TYPE: Command[GetSecurityIsolationStatusResponse]

Security aspects: - Cross-origin policies - Iframe security - Site isolation - Content protection

load_network_resource staticmethod
load_network_resource(url, options, frame_id=None)

Loads a network resource with specific options.

Features: - Custom request configuration - Resource loading control - Frame-specific loading - Error handling

PARAMETER DESCRIPTION
url

Resource URL to load

TYPE: str

options

Loading configuration

TYPE: LoadNetworkResourceOptions

frame_id

Target frame context

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

CDP command to load resource

TYPE: Command[LoadNetworkResourceResponse]

Usage considerations: - Respects CORS policies - Handles authentication - Manages redirects - Supports streaming

replay_xhr staticmethod
replay_xhr(request_id)

Replays an XHR request.

Applications: - Request debugging - Response testing - Race condition analysis - API verification

PARAMETER DESCRIPTION
request_id

XHR request to replay

TYPE: str

RETURNS DESCRIPTION
Command

CDP command to replay XHR

TYPE: Command[Response]

Note: - Maintains original headers - Preserves request body - Updates timestamps - Creates new request ID

Input Commands

pydoll.commands.input_commands

InputCommands

A class for simulating user input events using Chrome DevTools Protocol.

The Input domain provides methods for simulating user input, including: - Keyboard events (key presses, releases) - Mouse events (clicks, movements, wheel) - Touch events (taps, multi-touch gestures) - Drag and drop events - Synthetic gestures (pinch, scroll, tap)

These methods allow for programmatic control of input events without requiring actual user interaction, making it useful for testing and automation.

cancel_dragging staticmethod
cancel_dragging()

Generates a command to cancel any active dragging in the page.

This is useful when you need to interrupt an ongoing drag operation that might have been started with dispatchDragEvent or by other means.

RETURNS DESCRIPTION
Command

The CDP command to cancel dragging.

TYPE: Command[Response]

dispatch_key_event staticmethod
dispatch_key_event(type, modifiers=None, timestamp=None, text=None, unmodified_text=None, key_identifier=None, code=None, key=None, windows_virtual_key_code=None, native_virtual_key_code=None, auto_repeat=None, is_keypad=None, is_system_key=None, location=None, commands=None)

Generates a command to dispatch a key event to the page.

This method can simulate various types of keyboard events such as key presses, key releases, and character inputs.

PARAMETER DESCRIPTION
type

Type of the key event. Allowed values: keyDown, keyUp, rawKeyDown, char. - keyDown: Corresponds to a user pressing a key - keyUp: Corresponds to a user releasing a key - rawKeyDown: A physical key press, without the text processing - char: Generates a character without explicit key events

TYPE: KeyEventType

modifiers

Bit field representing pressed modifier keys. Values: Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). For example, to simulate Ctrl+Shift, use 10.

TYPE: Optional[KeyModifier] DEFAULT: None

timestamp

Time at which the event occurred, in seconds since epoch.

TYPE: Optional[float] DEFAULT: None

text

Text as generated by processing a virtual key code with a keyboard layout. Not needed for 'keyUp' and 'rawKeyDown' events (default: "").

TYPE: Optional[str] DEFAULT: None

unmodified_text

Text that would have been generated by the keyboard without modifiers (except for shift). Useful for shortcut key handling (default: "").

TYPE: Optional[str] DEFAULT: None

key_identifier

Unique key identifier (e.g., 'U+0041') (default: "").

TYPE: Optional[str] DEFAULT: None

code

Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: "").

TYPE: Optional[str] DEFAULT: None

key

Unique DOM defined string value describing the meaning of the key in the context of active modifiers, keyboard layout, etc. (e.g., 'AltGr') (default: "").

TYPE: Optional[str] DEFAULT: None

windows_virtual_key_code

Windows virtual key code (default: 0).

TYPE: Optional[int] DEFAULT: None

native_virtual_key_code

Native virtual key code (default: 0).

TYPE: Optional[int] DEFAULT: None

auto_repeat

Whether the event was generated from auto repeat (default: false).

TYPE: Optional[bool] DEFAULT: None

is_keypad

Whether the event was generated from the keypad (default: false).

TYPE: Optional[bool] DEFAULT: None

is_system_key

Whether the event was a system key event (default: false).

TYPE: Optional[bool] DEFAULT: None

location

Whether the event was from the left or right side of the keyboard: 0=Default, 1=Left, 2=Right (default: 0).

TYPE: Optional[KeyLocation] DEFAULT: None

commands

Editing commands to send with the key event (e.g., 'selectAll') (default: []). These are related to but not equal to the command names used in document.execCommand and NSStandardKeyBindingResponding.

TYPE: Optional[list[str]] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to dispatch the key event.

TYPE: Command[Response]

dispatch_mouse_event staticmethod
dispatch_mouse_event(type, x, y, modifiers=None, timestamp=None, button=None, click_count=None, force=None, tangential_pressure=None, tilt_x=None, tilt_y=None, twist=None, delta_x=None, delta_y=None, pointer_type=None)

Generates a command to dispatch a mouse event to the page.

This method allows simulating various mouse interactions such as clicks, movements, and wheel scrolling.

PARAMETER DESCRIPTION
type

Type of the mouse event. Allowed values: - mousePressed: Mouse button pressed - mouseReleased: Mouse button released - mouseMoved: Mouse moved - mouseWheel: Mouse wheel rotated

TYPE: MouseEventType

x

X coordinate of the event relative to the main frame's viewport in CSS pixels.

TYPE: int

y

Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport, and Y increases going down.

TYPE: int

modifiers

Bit field representing pressed modifier keys. Values: Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).

TYPE: Optional[KeyModifier] DEFAULT: None

timestamp

Time at which the event occurred, in seconds since epoch.

TYPE: Optional[float] DEFAULT: None

button

Mouse button being pressed/released. Default is "none". Allowed values: "none", "left", "middle", "right", "back", "forward".

TYPE: Optional[MouseButton] DEFAULT: None

click_count

Number of times the mouse button was clicked (default: 0). For example, 2 for a double-click.

TYPE: Optional[int] DEFAULT: None

force

The normalized pressure, which has a range of [0,1] (default: 0). Used primarily for pressure-sensitive inputs.

TYPE: Optional[float] DEFAULT: None

tangential_pressure

The normalized tangential pressure, which has a range of [-1,1] (default: 0). Used for stylus input.

TYPE: Optional[float] DEFAULT: None

tilt_x

The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90]. A positive tiltX is to the right (default: 0).

TYPE: Optional[float] DEFAULT: None

tilt_y

The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90]. A positive tiltY is towards the user (default: 0).

TYPE: Optional[float] DEFAULT: None

twist

The clockwise rotation of a pen stylus around its own major axis, in degrees in the range [0,359] (default: 0).

TYPE: Optional[int] DEFAULT: None

delta_x

X delta in CSS pixels for mouse wheel event (default: 0). Positive values scroll right.

TYPE: Optional[float] DEFAULT: None

delta_y

Y delta in CSS pixels for mouse wheel event (default: 0). Positive values scroll up.

TYPE: Optional[float] DEFAULT: None

pointer_type

Pointer type (default: "mouse"). Allowed values: "mouse", "pen".

TYPE: Optional[PointerType] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to dispatch the mouse event.

TYPE: Command[Response]

dispatch_touch_event staticmethod
dispatch_touch_event(type, touch_points=None, modifiers=None, timestamp=None)

Generates a command to dispatch a touch event to the page.

This method allows simulating touch interactions on touch-enabled devices or emulated touch environments.

PARAMETER DESCRIPTION
type

Type of the touch event. Allowed values: - touchStart: Touch started - at least one point must be specified - touchEnd: Touch ended - points that are no longer pressed should be removed - touchMove: Touch moved - active points should be updated - touchCancel: Touch canceled - clears all touch points Touch end and cancel events must not contain any touch points, while touch start and move must contain at least one.

TYPE: TouchEventType

touch_points

list of active touch points. One event per any changed point (compared to previous event) is generated, emulating pressing/moving/releasing points one by one. Each point includes coordinates and other properties.

TYPE: Optional[list[TouchPoint]] DEFAULT: None

modifiers

Bit field representing pressed modifier keys. Values: Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).

TYPE: Optional[KeyModifier] DEFAULT: None

timestamp

Time at which the event occurred, in seconds since epoch.

TYPE: Optional[float] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to dispatch the touch event.

TYPE: Command[Response]

set_ignore_input_events staticmethod
set_ignore_input_events(enabled)

Generates a command to ignore input events (useful while auditing page).

When enabled, all input events will be ignored, which can be useful during automated tests or when you want to prevent user interaction while performing certain operations.

PARAMETER DESCRIPTION
enabled

If true, input events processing will be ignored.

TYPE: bool

RETURNS DESCRIPTION
Command

The CDP command to set ignore input events.

TYPE: Command[Response]

dispatch_drag_event staticmethod
dispatch_drag_event(type, x, y, data=None, modifiers=None)

Generates a command to dispatch a drag event into the page.

This experimental method allows simulating drag and drop operations by dispatching drag events at specific coordinates.

PARAMETER DESCRIPTION
type

Type of the drag event. Allowed values: - dragEnter: Fired when a dragged item enters a valid drop target - dragOver: Fired when a dragged item is being dragged over a valid drop target - drop: Fired when an item is dropped on a valid drop target - dragCancel: Fired when a drag operation is being canceled

TYPE: DragEventType

x

X coordinate of the event relative to the main frame's viewport in CSS pixels.

TYPE: int

y

Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport, and Y increases going down.

TYPE: int

data

Drag data containing items being dragged, their MIME types, and other information.

TYPE: Optional[DragData] DEFAULT: None

modifiers

Bit field representing pressed modifier keys. Values: Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).

TYPE: Optional[KeyModifier] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to dispatch the drag event.

TYPE: Command[Response]

emulate_touch_from_mouse_event staticmethod
emulate_touch_from_mouse_event(type, x, y, button, timestamp=None, delta_x=None, delta_y=None, modifiers=None, click_count=None)

Generates a command to emulate touch event from the mouse event parameters.

This experimental method allows converting mouse events into touch events, useful for testing touch interactions in environments where touch is not available.

PARAMETER DESCRIPTION
type

Type of the mouse event to convert. Allowed values: - mousePressed: Converted to touchStart - mouseReleased: Converted to touchEnd - mouseMoved: Converted to touchMove - mouseWheel: May trigger scrolling

TYPE: MouseEventType

x

X coordinate of the mouse pointer in device-independent pixels (DIP).

TYPE: int

y

Y coordinate of the mouse pointer in DIP.

TYPE: int

button

Mouse button. Only "none", "left", "right" are supported.

TYPE: MouseButton

timestamp

Time at which the event occurred, in seconds since epoch. Default is current time.

TYPE: Optional[float] DEFAULT: None

delta_x

X delta in DIP for mouse wheel event (default: 0). Used for scrolling.

TYPE: Optional[float] DEFAULT: None

delta_y

Y delta in DIP for mouse wheel event (default: 0). Used for scrolling.

TYPE: Optional[float] DEFAULT: None

modifiers

Bit field representing pressed modifier keys. Values: Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).

TYPE: Optional[KeyModifier] DEFAULT: None

click_count

Number of times the mouse button was clicked (default: 0). For example, 2 for a double-click.

TYPE: Optional[int] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to emulate touch from mouse event.

TYPE: Command[Response]

ime_set_composition staticmethod
ime_set_composition(text, selection_start, selection_end, replacement_start=None, replacement_end=None)

Generates a command to set the current candidate text for IME.

This experimental method sets the text for Input Method Editors (IME), which are used for entering characters in languages that require more keystrokes than the number of characters (like Chinese, Japanese, Korean).

Use imeCommitComposition to commit the final text. Use imeSetComposition with empty string as text to cancel composition.

PARAMETER DESCRIPTION
text

The text to insert as the IME composition.

TYPE: str

selection_start

Start position of the selection within the composition text.

TYPE: int

selection_end

End position of the selection within the composition text.

TYPE: int

replacement_start

Start position of the text to be replaced (default: same as selection_start).

TYPE: Optional[int] DEFAULT: None

replacement_end

End position of the text to be replaced (default: same as selection_end).

TYPE: Optional[int] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to set IME composition.

TYPE: Command[Response]

insert_text staticmethod
insert_text(text)

Generates a command to emulate inserting text that doesn't come from a key press.

This experimental method is useful for inserting text that would normally come from sources other than keyboard, such as emoji pickers, IMEs, or clipboard pastes.

PARAMETER DESCRIPTION
text

The text to insert.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to insert text.

TYPE: Command[Response]

set_intercept_drags staticmethod
set_intercept_drags(enabled)

Generates a command to control interception of drag and drop events.

This experimental method prevents default drag and drop behavior and instead emits Input.dragIntercepted events. Drag and drop behavior can then be directly controlled via Input.dispatchDragEvent.

This is useful for implementing custom drag and drop logic or for testing drag and drop behavior in automated tests.

PARAMETER DESCRIPTION
enabled

If true, drag events will be intercepted and reported as dragIntercepted events, preventing the default behavior.

TYPE: bool

RETURNS DESCRIPTION
Command

The CDP command to set drag interception.

TYPE: Command[Response]

synthesize_pinch_gesture staticmethod
synthesize_pinch_gesture(x, y, scale_factor, relative_speed=None, gesture_source_type=None)

Generates a command to synthesize a pinch gesture over a time period.

This experimental method creates a synthetic pinch gesture (zoom in/out) by issuing appropriate touch events over time. This is useful for testing pinch-to-zoom functionality in web applications.

PARAMETER DESCRIPTION
x

X coordinate of the start of the gesture in CSS pixels.

TYPE: int

y

Y coordinate of the start of the gesture in CSS pixels.

TYPE: int

scale_factor

Relative scale factor after zooming: - >1.0 zooms in (fingers moving apart) - <1.0 zooms out (fingers moving together)

TYPE: float

relative_speed

Relative pointer speed in pixels per second (default: 800). Controls how fast the gesture happens.

TYPE: Optional[float] DEFAULT: None

gesture_source_type

Which type of input events to be generated: - 'default': Platform's preferred input type - 'touch': Touch input - 'mouse': Mouse input

TYPE: Optional[GestureSourceType] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to synthesize a pinch gesture.

TYPE: Command[Response]

synthesize_scroll_gesture staticmethod
synthesize_scroll_gesture(x, y, x_distance=None, y_distance=None, x_overscroll=None, y_overscroll=None, prevent_fling=None, speed=None, gesture_source_type=None, repeat_count=None, repeat_delay_ms=None, interaction_marker_name=None)

Generates a command to synthesize a scroll gesture over a time period.

This experimental method creates a synthetic scroll gesture by issuing appropriate touch events over time. This is useful for testing scrolling behavior in web applications.

PARAMETER DESCRIPTION
x

X coordinate of the start of the gesture in CSS pixels.

TYPE: int

y

Y coordinate of the start of the gesture in CSS pixels.

TYPE: int

x_distance

The distance to scroll along the X axis (positive to scroll left).

TYPE: Optional[float] DEFAULT: None

y_distance

The distance to scroll along the Y axis (positive to scroll up).

TYPE: Optional[float] DEFAULT: None

x_overscroll

The number of additional pixels to scroll back along the X axis, in addition to the given distance. This creates an overscroll effect (rubber-banding).

TYPE: Optional[float] DEFAULT: None

y_overscroll

The number of additional pixels to scroll back along the Y axis, in addition to the given distance. This creates an overscroll effect (rubber-banding).

TYPE: Optional[float] DEFAULT: None

prevent_fling

Prevent fling (default: true). If false, a fling animation might continue after the gesture.

TYPE: Optional[bool] DEFAULT: None

speed

Swipe speed in pixels per second (default: 800).

TYPE: Optional[int] DEFAULT: None

gesture_source_type

Which type of input events to be generated: - 'default': Platform's preferred input type - 'touch': Touch input - 'mouse': Mouse input

TYPE: Optional[GestureSourceType] DEFAULT: None

repeat_count

The number of times to repeat the gesture (default: 0).

TYPE: Optional[int] DEFAULT: None

repeat_delay_ms

The number of milliseconds delay between each repeat (default: 250).

TYPE: Optional[int] DEFAULT: None

interaction_marker_name

The name of the interaction markers to generate, if not empty. Used for tracking gesture timing in performance measurements.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to synthesize a scroll gesture.

TYPE: Command[Response]

synthesize_tap_gesture staticmethod
synthesize_tap_gesture(x, y, duration=None, tap_count=None, gesture_source_type=None)

Generates a command to synthesize a tap gesture over a time period.

This experimental method creates a synthetic tap gesture by issuing appropriate touch events over time. This is useful for testing touch interaction in web applications.

PARAMETER DESCRIPTION
x

X coordinate of the start of the gesture in CSS pixels.

TYPE: int

y

Y coordinate of the start of the gesture in CSS pixels.

TYPE: int

duration

Duration between touchdown and touchup events in milliseconds (default: 50). Controls how long the tap gesture takes.

TYPE: Optional[int] DEFAULT: None

tap_count

Number of times to perform the tap (e.g., 2 for a double tap, default: 1).

TYPE: Optional[int] DEFAULT: None

gesture_source_type

Which type of input events to be generated: - 'default': Platform's preferred input type - 'touch': Touch input - 'mouse': Mouse input

TYPE: Optional[GestureSourceType] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to synthesize a tap gesture.

TYPE: Command[Response]

Fetch Commands

pydoll.commands.fetch_commands

FetchCommands

This class encapsulates the fetch commands of the Chrome DevTools Protocol (CDP).

CDP's Fetch domain allows interception and modification of network requests at the application layer. This enables developers to examine, modify, and control network traffic, which is particularly useful for testing, debugging, and advanced automation scenarios.

The commands defined in this class provide functionality for: - Enabling and disabling fetch request interception - Continuing, fulfilling, or failing intercepted requests - Handling authentication challenges - Retrieving and modifying response bodies - Processing response data as streams

continue_request staticmethod
continue_request(request_id, url=None, method=None, post_data=None, headers=None, intercept_response=None)

Creates a command to continue a paused fetch request.

This command allows the browser to resume a fetch operation that has been intercepted. You can modify the fetch request URL, method, headers, and body before continuing.

PARAMETER DESCRIPTION
request_id

The ID of the fetch request to continue.

TYPE: str

url

The new URL for the fetch request. Defaults to None.

TYPE: Optional[str] DEFAULT: None

method

The HTTP method to use (e.g., 'GET', 'POST'). Defaults to None.

TYPE: Optional[RequestMethod] DEFAULT: None

post_data

The body data to send with the fetch request. Defaults to None.

TYPE: Optional[dict] DEFAULT: None

headers

A list of HTTP headers to include in the fetch request. Defaults to None.

TYPE: Optional[list[HeaderEntry]] DEFAULT: None

intercept_response

Indicates if the response should be intercepted. Defaults to None.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: A command for continuing the fetch request.

continue_request_with_auth staticmethod
continue_request_with_auth(request_id, auth_challenge_response, proxy_username=None, proxy_password=None)

Creates a command to continue a paused fetch request with authentication.

This command is used when the fetch operation requires authentication. It provides the necessary credentials to continue the request.

PARAMETER DESCRIPTION
request_id

The ID of the fetch request to continue.

TYPE: str

auth_challenge_response

The authentication challenge response type.

TYPE: AuthChallengeResponseValues

proxy_username

The username for proxy authentication. Defaults to None.

TYPE: Optional[str] DEFAULT: None

proxy_password

The password for proxy authentication. Defaults to None.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: A command for continuing the fetch request with authentication.

disable staticmethod
disable()

Creates a command to disable fetch interception.

This command stops the browser from intercepting fetch requests.

RETURNS DESCRIPTION
Command[Response]

Command[Response]: A command for disabling fetch interception.

enable staticmethod
enable(handle_auth_requests, url_pattern='*', resource_type=None, request_stage=None)

Creates a command to enable fetch interception.

This command allows the browser to start intercepting fetch requests. You can specify whether to handle authentication challenges and the types of resources to intercept.

PARAMETER DESCRIPTION
handle_auth_requests

Indicates if authentication requests should be handled.

TYPE: bool

url_pattern

Pattern to match URLs for interception. Defaults to '*'.

TYPE: str DEFAULT: '*'

resource_type

The type of resource to intercept. Defaults to None.

TYPE: Optional[ResourceType] DEFAULT: None

request_stage

The stage of the request to intercept. Defaults to None.

TYPE: Optional[RequestStage] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: A command for enabling fetch interception.

fail_request staticmethod
fail_request(request_id, error_reason)

Creates a command to simulate a failure in a fetch request.

This command allows you to simulate a failure for a specific fetch operation, providing a reason for the failure.

PARAMETER DESCRIPTION
request_id

The ID of the fetch request to fail.

TYPE: str

error_reason

The reason for the failure.

TYPE: NetworkErrorReason

RETURNS DESCRIPTION
Command[Response]

Command[Response]: A command for failing the fetch request.

fulfill_request staticmethod
fulfill_request(request_id, response_code, response_headers=None, body=None, response_phrase=None)

Creates a command to fulfill a fetch request with a custom response.

This command allows you to provide a custom response for a fetch operation, including the HTTP status code, headers, and body content.

PARAMETER DESCRIPTION
request_id

The ID of the fetch request to fulfill.

TYPE: str

response_code

The HTTP status code to return.

TYPE: int

response_headers

A list of response headers. Defaults to None.

TYPE: Optional[list[HeaderEntry]] DEFAULT: None

body

The body content of the response. Defaults to None.

TYPE: Optional[dict] DEFAULT: None

response_phrase

The response phrase (e.g., 'OK', 'Not Found'). Defaults to None.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: A command for fulfilling the fetch request.

get_response_body staticmethod
get_response_body(request_id)

Creates a command to retrieve the response body of a fetch request.

This command allows you to access the body of a completed fetch operation, which can be useful for analyzing the response data.

PARAMETER DESCRIPTION
request_id

The ID of the fetch request to retrieve the body from.

TYPE: str

RETURNS DESCRIPTION
Command[GetResponseBodyResponse]

Command[GetResponseBodyResponse]: A command for getting the response body.

continue_response staticmethod
continue_response(request_id, response_code=None, response_headers=None, response_phrase=None)

Creates a command to continue a fetch response for an intercepted request.

This command allows the browser to continue the response flow for a specific fetch request, including customizing the HTTP status code, headers, and response phrase.

PARAMETER DESCRIPTION
request_id

The ID of the fetch request to continue the response for.

TYPE: str

response_code

The HTTP status code to send. Defaults to None.

TYPE: Optional[int] DEFAULT: None

response_headers

A list of response headers. Defaults to None.

TYPE: Optional[list[HeaderEntry]] DEFAULT: None

response_phrase

The response phrase (e.g., 'OK'). Defaults to None.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: A command for continuing the fetch response.

take_response_body_as_stream staticmethod
take_response_body_as_stream(request_id)

Creates a command to take the response body as a stream.

This command allows you to receive the response body as a stream which can be useful for handling large responses.

PARAMETER DESCRIPTION
request_id

The ID of the fetch request to take the response body stream from.

TYPE: str

RETURNS DESCRIPTION
Command[TakeResponseBodyAsStreamResponse]

Command[TakeResponseBodyAsStreamResponse]: A command for taking the response body as a stream.

Browser Commands

pydoll.commands.browser_commands

BrowserCommands

BrowserCommands class provides a set of commands to interact with the browser's main functionality based on CDP. These commands allow for managing browser windows, such as closing windows, retrieving window IDs, and adjusting window bounds (size and state).

The commands defined in this class provide functionality for: - Managing browser windows and targets. - Setting permissions and download behavior. - Controlling browser windows (size, state). - Retrieving browser information and versioning.

get_version staticmethod
get_version()

Generates a command to get browser version information.

RETURNS DESCRIPTION
Command[GetVersionResponse]

Command[GetVersionResponse]: The CDP command that returns browser version details including protocol version, product name, revision, and user agent.

reset_permissions staticmethod
reset_permissions(browser_context_id=None)

Generates a command to reset all permissions.

PARAMETER DESCRIPTION
browser_context_id

The browser context to reset permissions for. If not specified, resets permissions for the default context.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: The CDP command that returns a basic success response.

cancel_download staticmethod
cancel_download(guid, browser_context_id=None)

Generates a command to cancel a download.

PARAMETER DESCRIPTION
guid

Global unique identifier of the download.

TYPE: str

browser_context_id

The browser context the download belongs to. If not specified, uses the default context.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: The CDP command that returns a basic success response.

crash staticmethod
crash()

Generates a command to crash the browser main process.

RETURNS DESCRIPTION
Command[Response]

Command[Response]: The CDP command that returns a basic success response before crashing the browser.

crash_gpu_process staticmethod
crash_gpu_process()

Generates a command to crash the browser GPU process.

RETURNS DESCRIPTION
Command[Response]

Command[Response]: The CDP command that returns a basic success response before crashing the GPU process.

set_download_behavior staticmethod
set_download_behavior(behavior, download_path=None, browser_context_id=None, events_enabled=True)

Generates a command to set the download behavior for the browser.

PARAMETER DESCRIPTION
behavior

The behavior to set for downloads.

TYPE: DownloadBehavior

download_path

The path to set for downloads.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: The CDP command that returns a basic success response after setting the download path.

close staticmethod
close()

Generates a command to close the browser.

RETURNS DESCRIPTION
Command[Response]

Command[Response]: The CDP command that returns a basic success response before closing the browser.

get_window_for_target staticmethod
get_window_for_target(target_id)

Generates a command to get the window for a given target ID.

PARAMETER DESCRIPTION
target_id

The target_id to get the window for.

TYPE: str

RETURNS DESCRIPTION
Command[GetWindowForTargetResponse]

Command[GetWindowForTargetResponse]: The CDP command that returns window information including windowId and bounds.

set_window_bounds staticmethod
set_window_bounds(window_id, bounds)

Generates a command to set the bounds of a window.

PARAMETER DESCRIPTION
window_id

The ID of the window to set the bounds for.

TYPE: int

bounds

The bounds to set for the window, which should include windowState and optionally width, height, x, and y coordinates.

TYPE: WindowBoundsDict

RETURNS DESCRIPTION
Command[Response]

Command[Response]: The CDP command that returns a basic success response after setting the window bounds.

set_window_maximized staticmethod
set_window_maximized(window_id)

Generates a command to maximize a window.

PARAMETER DESCRIPTION
window_id

The ID of the window to maximize.

TYPE: int

RETURNS DESCRIPTION
Command[Response]

Command[Response]: The CDP command that returns a basic success response after maximizing the window.

set_window_minimized staticmethod
set_window_minimized(window_id)

Generates a command to minimize a window.

PARAMETER DESCRIPTION
window_id

The ID of the window to minimize.

TYPE: int

RETURNS DESCRIPTION
Command[Response]

Command[Response]: The CDP command that returns a basic success response after minimizing the window.

grant_permissions staticmethod
grant_permissions(permissions, origin=None, browser_context_id=None)

Generates a command to grant specific permissions to the given origin.

PARAMETER DESCRIPTION
permissions

list of permissions to grant. See PermissionType enum for available permissions.

TYPE: list[PermissionType]

origin

The origin to grant permissions to. If not specified, grants for all origins.

TYPE: Optional[str] DEFAULT: None

browser_context_id

The browser context to grant permissions in. If not specified, uses the default context.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command[Response]

Command[Response]: The CDP command that returns a basic success response after granting the specified permissions.

Target Commands

pydoll.commands.target_commands

TargetCommands

A class for managing browser targets using Chrome DevTools Protocol.

The Target domain of CDP supports additional targets discovery and allows to attach to them. Targets can represent browser tabs, windows, frames, web workers, service workers, etc. The domain provides methods to create, discover, and control these targets.

This class provides methods to create commands for interacting with browser targets, including creating, activating, attaching to, and closing targets through CDP commands.

activate_target staticmethod
activate_target(target_id)

Generates a command to activate (focus) a target.

PARAMETER DESCRIPTION
target_id

ID of the target to activate.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to activate the target.

TYPE: Command[Response]

attach_to_target staticmethod
attach_to_target(target_id, flatten=None)

Generates a command to attach to a target with the given ID.

When attached to a target, you can send commands to it and receive events from it. This is essential for controlling and automating targets like browser tabs.

PARAMETER DESCRIPTION
target_id

ID of the target to attach to.

TYPE: str

flatten

If true, enables "flat" access to the session via specifying sessionId attribute in the commands. This is recommended as the non-flattened mode is being deprecated. See https://crbug.com/991325

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to attach to the target, which will return a sessionId.

TYPE: Command[AttachToTargetResponse]

close_target staticmethod
close_target(target_id)

Generates a command to close a target.

If the target is a page or a tab, it will be closed. This is equivalent to clicking the close button on a browser tab.

PARAMETER DESCRIPTION
target_id

ID of the target to close.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to close the target, which will return a success flag.

TYPE: Command[Response]

create_browser_context staticmethod
create_browser_context(dispose_on_detach=None, proxy_server=None, proxy_bypass_list=None, origins_with_universal_network_access=None)

Generates a command to create a new empty browser context.

A browser context is similar to an incognito profile but you can have more than one. Each context has its own set of cookies, local storage, and other browser data. This is useful for testing multiple users or isolating sessions.

PARAMETER DESCRIPTION
dispose_on_detach

If specified, the context will be disposed when the debugging session disconnects.

TYPE: Optional[bool] DEFAULT: None

proxy_server

Proxy server string, similar to the one passed to --proxy-server command line argument (e.g., "socks5://192.168.1.100:1080").

TYPE: Optional[str] DEFAULT: None

proxy_bypass_list

Proxy bypass list, similar to the one passed to --proxy-bypass-list command line argument (e.g., "*.example.com,localhost").

TYPE: Optional[str] DEFAULT: None

origins_with_universal_network_access

An optional list of origins to grant unlimited cross-origin access to. Parts of the URL other than those constituting origin are ignored.

TYPE: Optional[list[str]] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to create a browser context, which will return the ID of the created context.

TYPE: Command[CreateBrowserContextResponse]

create_target staticmethod
create_target(url, left=None, top=None, width=None, height=None, window_state=None, browser_context_id=None, enable_begin_frame_control=None, new_window=None, background=None, for_tab=None, hidden=None)

Generates a command to create a new page (target).

This is one of the primary methods to open a new tab or window with specific properties such as position, size, and browser context.

PARAMETER DESCRIPTION
url

The initial URL the page will navigate to. An empty string indicates about:blank.

TYPE: str

left

Frame left position in device-independent pixels (DIP). Requires newWindow to be true or in headless mode.

TYPE: Optional[int] DEFAULT: None

top

Frame top position in DIP. Requires newWindow to be true or in headless mode.

TYPE: Optional[int] DEFAULT: None

width

Frame width in DIP.

TYPE: Optional[int] DEFAULT: None

height

Frame height in DIP.

TYPE: Optional[int] DEFAULT: None

window_state

Frame window state: normal, minimized, maximized, or fullscreen. Default is normal.

TYPE: Optional[WindowState] DEFAULT: None

browser_context_id

The browser context to create the page in. If not specified, the default browser context is used.

TYPE: Optional[str] DEFAULT: None

enable_begin_frame_control

Whether BeginFrames for this target will be controlled via DevTools (headless shell only, not supported on MacOS yet, false by default).

TYPE: Optional[bool] DEFAULT: None

new_window

Whether to create a new window or tab (false by default, not supported by headless shell).

TYPE: Optional[bool] DEFAULT: None

background

Whether to create the target in background or foreground (false by default, not supported by headless shell).

TYPE: Optional[bool] DEFAULT: None

for_tab

Whether to create the target of type "tab".

TYPE: Optional[bool] DEFAULT: None

hidden

Whether to create a hidden target. The hidden target is observable via protocol, but not present in the tab UI strip. Cannot be created with forTab:true, newWindow:true or background:false. The life-time of the tab is limited to the life-time of the session.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to create a target, which will return the ID of the created target.

TYPE: Command[CreateTargetResponse]

detach_from_target staticmethod
detach_from_target(session_id=None)

Generates a command to detach a session from its target.

After detaching, you will no longer receive events from the target and cannot send commands to it.

PARAMETER DESCRIPTION
session_id

Session ID to detach. If not specified, detaches all sessions.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to detach from the target.

TYPE: Command[Response]

dispose_browser_context staticmethod
dispose_browser_context(browser_context_id)

Generates a command to delete a browser context.

All pages belonging to the browser context will be closed without calling their beforeunload hooks. This is similar to closing an incognito profile.

PARAMETER DESCRIPTION
browser_context_id

The ID of the browser context to dispose.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to dispose the browser context.

TYPE: Command[Response]

get_browser_contexts staticmethod
get_browser_contexts()

Generates a command to get all browser contexts created with createBrowserContext.

This is useful for obtaining a list of all available contexts for managing multiple isolated browser sessions.

RETURNS DESCRIPTION
Command

The CDP command to get all browser contexts, which will return an array of browser context IDs.

TYPE: Command[GetBrowserContextsResponse]

get_targets staticmethod
get_targets(filter=None)

Generates a command to retrieve a list of available targets.

Targets include tabs, extensions, web workers, and other attachable entities in the browser. This is useful for discovering what targets exist before attaching to them.

PARAMETER DESCRIPTION
filter

Only targets matching the filter will be reported. If filter is not specified and target discovery is currently enabled, a filter used for target discovery is used for consistency.

TYPE: Optional[list] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to get targets, which will return a list of TargetInfo objects with details about each target.

TYPE: Command[GetTargetsResponse]

set_auto_attach staticmethod
set_auto_attach(auto_attach, wait_for_debugger_on_start=None, flatten=None, filter=None)

Generates a command to control whether to automatically attach to new targets.

This method controls whether to automatically attach to new targets which are considered to be directly related to the current one (for example, iframes or workers). When turned on, it also attaches to all existing related targets. When turned off, it automatically detaches from all currently attached targets.

PARAMETER DESCRIPTION
auto_attach

Whether to auto-attach to related targets.

TYPE: bool

wait_for_debugger_on_start

Whether to pause new targets when attaching to them. Use Runtime.runIfWaitingForDebugger to run paused targets.

TYPE: Optional[bool] DEFAULT: None

flatten

Enables "flat" access to the session via specifying sessionId attribute in the commands. This mode is being preferred, and non-flattened mode is being deprecated (see crbug.com/991325).

TYPE: Optional[bool] DEFAULT: None

filter

Only targets matching filter will be attached.

TYPE: Optional[list] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to set auto-attach behavior.

TYPE: Command[Response]

set_discover_targets staticmethod
set_discover_targets(discover, filter=None)

Generates a command to control target discovery.

This method controls whether to discover available targets and notify via targetCreated/targetInfoChanged/targetDestroyed events. Target discovery is useful for monitoring when new tabs, workers, or other targets are created or destroyed.

PARAMETER DESCRIPTION
discover

Whether to discover available targets.

TYPE: bool

filter

Only targets matching filter will be discovered. If discover is false, filter must be omitted or empty.

TYPE: Optional[list] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to set target discovery.

TYPE: Command[Response]

attach_to_browser_target staticmethod
attach_to_browser_target(session_id)

Generates a command to attach to the browser target.

This is an experimental method that attaches to the browser target, only using flat sessionId mode. The browser target is a special target that represents the browser itself rather than a page or other content.

PARAMETER DESCRIPTION
session_id

ID of the session to attach to the browser target.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to attach to the browser target, which will return a new session ID.

TYPE: Command[AttachToBrowserTargetResponse]

get_target_info staticmethod
get_target_info(target_id)

Generates a command to get information about a specific target.

This experimental method returns detailed information about a target, such as its type, URL, title, and other properties.

PARAMETER DESCRIPTION
target_id

ID of the target to get information about.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to get target information, which will return a TargetInfo object with details about the target.

TYPE: Command[GetTargetInfoResponse]

set_remote_locations staticmethod
set_remote_locations(locations)

Generates a command to enable target discovery for specified remote locations.

This experimental method enables target discovery for remote locations when setDiscoverTargets was set to true. This is useful for discovering targets on remote devices or in different browser instances.

PARAMETER DESCRIPTION
locations

list of remote locations, each containing a host and port.

TYPE: list[RemoteLocation]

RETURNS DESCRIPTION
Command

The CDP command to set remote locations for target discovery.

TYPE: Command[Response]

Storage Commands

pydoll.commands.storage_commands

StorageCommands

A class for interacting with browser storage using Chrome DevTools Protocol (CDP).

The Storage domain of CDP allows managing various types of browser storage, including: - Cookies - Cache Storage - IndexedDB - Web Storage (localStorage/sessionStorage) - Shared Storage - Storage Buckets - Trust Tokens - Interest Groups - Attribution Reporting

This class provides static methods that generate CDP commands to manage these types of storage without the need for traditional webdrivers.

clear_cookies staticmethod
clear_cookies(browser_context_id=None)

Generates a command to clear all browser cookies.

PARAMETER DESCRIPTION
browser_context_id

Browser context ID (optional). Useful when working with multiple contexts (e.g., multiple windows or tabs).

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to clear all cookies.

TYPE: Command[Response]

clear_data_for_origin staticmethod
clear_data_for_origin(origin, storage_types)

Generates a command to clear storage data for a specific origin.

PARAMETER DESCRIPTION
origin

The security origin (e.g., "https://example.com").

TYPE: str

storage_types

Comma-separated list of storage types to clear. Possible values include: "cookies", "local_storage", "indexeddb", "cache_storage", etc. Use "all" to clear all types.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to clear data for the specified origin.

TYPE: Command[Response]

clear_data_for_storage_key staticmethod
clear_data_for_storage_key(storage_key, storage_types)

Generates a command to clear data for a specific storage key.

PARAMETER DESCRIPTION
storage_key

The storage key for which to clear data. Unlike origin, a storage key is a more specific identifier that may include partition isolation.

TYPE: str

storage_types

Comma-separated list of storage types to clear. Possible values include: "cookies", "local_storage", "indexeddb", "cache_storage", etc. Use "all" to clear all types.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to clear data for the specified storage key.

TYPE: Command[Response]

get_cookies staticmethod
get_cookies(browser_context_id=None)

Generates a command to get all browser cookies.

PARAMETER DESCRIPTION
browser_context_id

Browser context ID (optional). Useful when working with multiple contexts (e.g., multiple windows or tabs).

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to get all cookies, which will return an array of Cookie objects.

TYPE: Command[GetCookiesResponse]

get_storage_key_for_frame staticmethod
get_storage_key_for_frame(frame_id)

Generates a command to get the storage key for a specific frame.

Storage keys are used to isolate data between different origins or partitions in the browser.

PARAMETER DESCRIPTION
frame_id

The ID of the frame for which to get the storage key.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to get the storage key for the specified frame.

TYPE: Command[GetStorageKeyForFrameResponse]

get_usage_and_quota staticmethod
get_usage_and_quota(origin)

Generates a command to get storage usage and quota information for an origin.

Useful for monitoring or debugging storage consumption of a site.

PARAMETER DESCRIPTION
origin

The security origin (e.g., "https://example.com") for which to get information.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command that will return: - usage: Storage usage in bytes - quota: Storage quota in bytes - usageBreakdown: Breakdown of usage by storage type - overrideActive: Whether there is an active quota override

TYPE: Command[GetUsageAndQuotaResponse]

set_cookies staticmethod
set_cookies(cookies, browser_context_id=None)

Generates a command to set browser cookies.

PARAMETER DESCRIPTION
cookies

list of Cookie objects to set.

TYPE: list[CookieParam]

browser_context_id

Browser context ID (optional). Useful when working with multiple contexts (e.g., multiple windows or tabs).

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to set the specified cookies.

TYPE: Command[Response]

set_protected_audience_k_anonymity staticmethod
set_protected_audience_k_anonymity(owner, name, hashes)

Generates a command to set K-anonymity for protected audience.

This command is used to configure anonymity in privacy-preserving advertising systems (part of Google's Privacy Sandbox).

PARAMETER DESCRIPTION
owner

Owner of the K-anonymity configuration.

TYPE: str

name

Name of the K-anonymity configuration.

TYPE: str

hashes

list of hashes for the configuration.

TYPE: list[str]

RETURNS DESCRIPTION
Command

The CDP command to set protected audience K-anonymity.

TYPE: Command[Response]

track_cache_storage_for_origin staticmethod
track_cache_storage_for_origin(origin)

Generates a command to register an origin to receive notifications about changes to its Cache Storage.

Cache Storage is primarily used by Service Workers to store resources for offline use.

PARAMETER DESCRIPTION
origin

The security origin (e.g., "https://example.com") to monitor.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to register monitoring of the origin's Cache Storage.

TYPE: Command[Response]

track_cache_storage_for_storage_key staticmethod
track_cache_storage_for_storage_key(storage_key)

Generates a command to register a storage key to receive notifications about changes to its Cache Storage.

Similar to track_cache_storage_for_origin, but uses the storage key for more precise isolation.

PARAMETER DESCRIPTION
storage_key

The storage key to monitor.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to register monitoring of the key's Cache Storage.

TYPE: Command[Response]

track_indexed_db_for_origin staticmethod
track_indexed_db_for_origin(origin)

Generates a command to register an origin to receive notifications about changes to its IndexedDB.

IndexedDB is a NoSQL database system in the browser for storing large amounts of structured data.

PARAMETER DESCRIPTION
origin

The security origin (e.g., "https://example.com") to monitor.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to register monitoring of the origin's IndexedDB.

TYPE: Command[Response]

track_indexed_db_for_storage_key staticmethod
track_indexed_db_for_storage_key(storage_key)

Generates a command to register a storage key to receive notifications about changes to its IndexedDB.

Similar to track_indexed_db_for_origin, but uses the storage key for more precise isolation.

PARAMETER DESCRIPTION
storage_key

The storage key to monitor.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to register monitoring of the key's IndexedDB.

TYPE: Command[Response]

untrack_cache_storage_for_origin staticmethod
untrack_cache_storage_for_origin(origin)

Generates a command to unregister an origin from receiving notifications about changes to its Cache Storage.

Use this method to stop monitoring Cache Storage after using track_cache_storage_for_origin.

PARAMETER DESCRIPTION
origin

The security origin (e.g., "https://example.com") to stop monitoring.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to cancel monitoring of the origin's Cache Storage.

TYPE: Command[Response]

untrack_cache_storage_for_storage_key staticmethod
untrack_cache_storage_for_storage_key(storage_key)

Generates a command to unregister a storage key from receiving notifications about changes to its Cache Storage.

Use this method to stop monitoring Cache Storage after using track_cache_storage_for_storage_key.

PARAMETER DESCRIPTION
storage_key

The storage key to stop monitoring.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to cancel monitoring of the key's Cache Storage.

TYPE: Command[Response]

untrack_indexed_db_for_origin staticmethod
untrack_indexed_db_for_origin(origin)

Generates a command to unregister an origin from receiving notifications about changes to its IndexedDB.

Use this method to stop monitoring IndexedDB after using track_indexed_db_for_origin.

PARAMETER DESCRIPTION
origin

The security origin (e.g., "https://example.com") to stop monitoring.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to cancel monitoring of the origin's IndexedDB.

TYPE: Command[Response]

untrack_indexed_db_for_storage_key staticmethod
untrack_indexed_db_for_storage_key(storage_key)

Generates a command to unregister a storage key from receiving notifications about changes to its IndexedDB.

Use this method to stop monitoring IndexedDB after using track_indexed_db_for_storage_key.

PARAMETER DESCRIPTION
storage_key

The storage key to stop monitoring.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to cancel monitoring of the key's IndexedDB.

TYPE: Command[Response]

clear_shared_storage_entries staticmethod
clear_shared_storage_entries(owner_origin)

Generates a command to clear all Shared Storage entries for a specific origin.

Shared Storage is an experimental API that allows cross-origin shared storage with privacy protections.

PARAMETER DESCRIPTION
owner_origin

The owner origin of the Shared Storage to clear.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to clear the Shared Storage entries.

TYPE: Command[Response]

clear_trust_tokens staticmethod
clear_trust_tokens(issuer_origin)

Generates a command to remove all Trust Tokens issued by the specified origin.

Trust Tokens are an experimental API for combating fraud while preserving user privacy. This command keeps other stored data, including the issuer's redemption records, intact.

PARAMETER DESCRIPTION
issuer_origin

The issuer origin of the tokens to remove.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to clear Trust Tokens, which will return: - didDeleteTokens: True if any tokens were deleted, False otherwise.

TYPE: Command[ClearTrustTokensResponse]

delete_shared_storage_entry staticmethod
delete_shared_storage_entry(owner_origin, key)

Generates a command to delete a specific Shared Storage entry.

PARAMETER DESCRIPTION
owner_origin

The owner origin of the Shared Storage.

TYPE: str

key

The key of the entry to delete.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to delete the Shared Storage entry.

TYPE: Command[Response]

delete_storage_bucket staticmethod
delete_storage_bucket(bucket)

Generates a command to delete a Storage Bucket with the specified key and name.

Storage Buckets are an experimental API for managing storage data with greater granularity and expiration control.

PARAMETER DESCRIPTION
bucket

A StorageBucket object containing the storageKey and name of the bucket to delete.

TYPE: StorageBucket

RETURNS DESCRIPTION
Command

The CDP command to delete the Storage Bucket.

TYPE: Command[Response]

get_affected_urls_for_third_party_cookie_metadata(first_party_url, third_party_urls)

Generates a command to get the list of URLs from a page and its embedded resources that match existing grace period URL pattern rules.

This command is useful for monitoring which URLs would be affected by the Privacy Sandbox's third-party cookie policies.

PARAMETER DESCRIPTION
first_party_url

The URL of the page being visited (first-party).

TYPE: str

third_party_urls

Optional list of embedded third-party resource URLs.

TYPE: list[str]

RETURNS DESCRIPTION
Command

The CDP command to get URLs affected by third-party cookie metadata.

TYPE: Command[GetAffectedUrlsForThirdPartyCookieMetadataResponse]

get_interest_group_details staticmethod
get_interest_group_details(owner_origin, name)

Generates a command to get details of a specific interest group.

Interest Groups are part of the FLEDGE/Protected Audience API for privacy-preserving advertising, enabling in-browser ad auctions.

PARAMETER DESCRIPTION
owner_origin

The owner origin of the interest group.

TYPE: str

name

The name of the interest group.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to get interest group details.

TYPE: Command[GetInterestGroupDetailsResponse]

get_related_website_sets(sets)

Generates a command to get related website sets.

Related Website Sets are an API that allows sites under the same entity to share some data, despite third-party cookie restrictions.

PARAMETER DESCRIPTION
sets

list of RelatedWebsiteSet objects.

TYPE: list[RelatedWebsiteSet]

RETURNS DESCRIPTION
Command

The CDP command to get related website sets.

TYPE: Command[GetRelatedWebsiteSetsResponse]

get_shared_storage_entries staticmethod
get_shared_storage_entries(owner_origin)

Generates a command to get all Shared Storage entries for an origin.

PARAMETER DESCRIPTION
owner_origin

The owner origin of the Shared Storage.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to get the Shared Storage entries.

TYPE: Command[GetSharedStorageEntriesResponse]

get_shared_storage_metadata staticmethod
get_shared_storage_metadata(owner_origin)

Generates a command to get Shared Storage metadata for an origin.

Metadata includes information such as usage, budget, and creation time.

PARAMETER DESCRIPTION
owner_origin

The owner origin of the Shared Storage.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to get Shared Storage metadata.

TYPE: Command[GetSharedStorageMetadataResponse]

get_trust_tokens staticmethod
get_trust_tokens()

Generates a command to get all available Trust Tokens.

RETURNS DESCRIPTION
Command

The CDP command to get Trust Tokens, which will return pairs of issuer origin and count of available tokens.

TYPE: Command[GetTrustTokensResponse]

override_quota_for_origin staticmethod
override_quota_for_origin(origin, quota_size=None)

Generates a command to override the storage quota for a specific origin.

This command is useful for storage exhaustion testing or simulating different storage conditions.

PARAMETER DESCRIPTION
origin

The origin for which to override the quota.

TYPE: str

quota_size

The size of the new quota in bytes (optional). If not specified, any existing override will be removed.

TYPE: Optional[float] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to override the origin's quota.

TYPE: Command[Response]

reset_shared_storage_budget staticmethod
reset_shared_storage_budget(owner_origin)

Generates a command to reset the Shared Storage budget for an origin.

Shared Storage uses a budget system to limit the amount of operations or specific operations to preserve user privacy.

PARAMETER DESCRIPTION
owner_origin

The owner origin of the Shared Storage.

TYPE: str

RETURNS DESCRIPTION
Command

The CDP command to reset the Shared Storage budget.

TYPE: Command[Response]

run_bounce_tracking_mitigations staticmethod
run_bounce_tracking_mitigations()

Generates a command to run bounce tracking mitigations.

Bounce tracking is a tracking technique that involves redirecting users through intermediate URLs to establish tracking cookies. This command activates protections against this technique.

RETURNS DESCRIPTION
Command

The CDP command to run bounce tracking mitigations.

TYPE: Command[RunBounceTrackingMitigationsResponse]

send_pending_attribution_reports staticmethod
send_pending_attribution_reports()

Generates a command to send pending attribution reports.

Attribution Reporting is an API that allows measuring conversions while preserving user privacy. This command forces sending reports that are waiting to be sent.

RETURNS DESCRIPTION
Command

The CDP command to send pending attribution reports.

TYPE: Command[SendPendingAttributionReportsResponse]

set_attribution_reporting_local_testing_mode staticmethod
set_attribution_reporting_local_testing_mode(enable)

Generates a command to enable or disable local testing mode for Attribution Reporting.

Testing mode makes it easier to develop and test the Attribution Reporting API by removing restrictions like delays and rate limits that would normally apply.

PARAMETER DESCRIPTION
enable

True to enable local testing mode, False to disable it.

TYPE: bool

RETURNS DESCRIPTION
Command

The CDP command to set Attribution Reporting local testing mode.

TYPE: Command[Response]

set_attribution_reporting_tracking staticmethod
set_attribution_reporting_tracking(enable)

Generates a command to enable or disable Attribution Reporting tracking.

PARAMETER DESCRIPTION
enable

True to enable tracking, False to disable it.

TYPE: bool

RETURNS DESCRIPTION
Command

The CDP command to set Attribution Reporting tracking.

TYPE: Command[Response]

set_interest_group_auction_tracking staticmethod
set_interest_group_auction_tracking(enable)

Generates a command to enable or disable interest group auction tracking.

Interest group auctions are part of the FLEDGE/Protected Audience API and allow for in-browser ad auctions in a privacy-preserving way.

PARAMETER DESCRIPTION
enable

True to enable tracking, False to disable it.

TYPE: bool

RETURNS DESCRIPTION
Command

The CDP command to set interest group auction tracking.

TYPE: Command[Response]

set_interest_group_tracking staticmethod
set_interest_group_tracking(enable)

Generates a command to enable or disable interest group tracking.

PARAMETER DESCRIPTION
enable

True to enable tracking, False to disable it.

TYPE: bool

RETURNS DESCRIPTION
Command

The CDP command to set interest group tracking.

TYPE: Command[Response]

set_shared_storage_entry staticmethod
set_shared_storage_entry(owner_origin, key, value, ignore_if_present=None)

Generates a command to set an entry in Shared Storage.

PARAMETER DESCRIPTION
owner_origin

The owner origin of the Shared Storage.

TYPE: str

key

The key of the entry to set.

TYPE: str

value

The value of the entry to set.

TYPE: str

ignore_if_present

If True, won't replace an existing entry with the same key.

TYPE: Optional[bool] DEFAULT: None

RETURNS DESCRIPTION
Command

The CDP command to set a Shared Storage entry.

TYPE: Command[Response]

set_shared_storage_tracking staticmethod
set_shared_storage_tracking(enable)

Generates a command to enable or disable Shared Storage tracking.

When enabled, events related to Shared Storage usage will be emitted.

PARAMETER DESCRIPTION
enable

True to enable tracking, False to disable it.

TYPE: bool

RETURNS DESCRIPTION
Command

The CDP command to set Shared Storage tracking.

TYPE: Command[Response]

set_storage_bucket_tracking staticmethod
set_storage_bucket_tracking(storage_key, enable)

Generates a command to enable or disable Storage Bucket tracking.

When enabled, events related to changes in storage buckets will be emitted.

PARAMETER DESCRIPTION
storage_key

The storage key for which to set tracking.

TYPE: str

enable

True to enable tracking, False to disable it.

TYPE: bool

RETURNS DESCRIPTION
Command

The CDP command to set Storage Bucket tracking.

TYPE: Command[Response]