Skip to content

网页元素

pydoll.elements.web_element.WebElement

WebElement(object_id, connection_handler, method=None, selector=None, attributes_list=[])

Bases: FindElementsMixin

DOM element wrapper for browser automation.

Provides comprehensive functionality for element interaction, inspection, and manipulation using Chrome DevTools Protocol commands.

Initialize WebElement wrapper.

PARAMETER DESCRIPTION
object_id

Unique CDP object identifier for this DOM element.

TYPE: str

connection_handler

Connection instance for browser communication.

TYPE: ConnectionHandler

method

Search method used to find this element (for debugging).

TYPE: Optional[str] DEFAULT: None

selector

Selector string used to find this element (for debugging).

TYPE: Optional[str] DEFAULT: None

attributes_list

Flat list of alternating attribute names and values.

TYPE: list[str] DEFAULT: []

value property

value

Element's value attribute (for form elements).

class_name property

class_name

Element's CSS class name(s).

id property

id

Element's ID attribute.

tag_name property

tag_name

Element's HTML tag name.

is_iframe property

is_iframe

Whether the element represents an iframe.

is_enabled property

is_enabled

Whether element is enabled (not disabled).

text async property

text

Visible text content of the element.

bounds async property

bounds

Element's bounding box coordinates.

Returns coordinates in CSS pixels relative to document origin.

inner_html async property

inner_html

iframe_context async property

iframe_context

Return the resolved iframe context for this element when it is an