API Reference
Welcome to the Pydoll API Reference! This section provides comprehensive documentation for all classes, methods, and functions available in the Pydoll library.
Overview
Pydoll is organized into several key modules, each serving a specific purpose in browser automation:
Browser Module
The browser module contains classes for managing browser instances and their lifecycle.
- Chrome - Chrome browser automation
- Edge - Microsoft Edge browser automation
- Options - Browser configuration options
- Tab - Tab management and interaction
- Managers - Browser lifecycle managers
Elements Module
The elements module provides classes for interacting with web page elements.
- WebElement - Individual element interaction
- Mixins - Reusable element functionality
Connection Module
The connection module handles communication with the browser through the Chrome DevTools Protocol.
- Connection Handler - WebSocket connection management
- Managers - Connection lifecycle managers
Commands Module
The commands module provides low-level Chrome DevTools Protocol command implementations.
- Commands Overview - CDP command implementations by domain
Protocol Module
The protocol module implements the Chrome DevTools Protocol commands and events.
Core Module
The core module contains fundamental utilities, constants, and exceptions.
- Constants - Library constants and enums
- Exceptions - Custom exception classes
- Utils - Utility functions
Quick Navigation
Most Common Classes
Class | Purpose | Module |
---|---|---|
Chrome |
Chrome browser automation | pydoll.browser.chromium |
Edge |
Edge browser automation | pydoll.browser.chromium |
Tab |
Tab interaction and control | pydoll.browser.tab |
WebElement |
Element interaction | pydoll.elements.web_element |
ChromiumOptions |
Browser configuration | pydoll.browser.options |
Key Enums and Constants
Name | Purpose | Module |
---|---|---|
By |
Element selector strategies | pydoll.constants |
Key |
Keyboard key constants | pydoll.constants |
PermissionType |
Browser permission types | pydoll.constants |
Common Exceptions
Exception | When Raised | Module |
---|---|---|
ElementNotFound |
Element not found in DOM | pydoll.exceptions |
WaitElementTimeout |
Element wait timeout | pydoll.exceptions |
BrowserNotStarted |
Browser not started | pydoll.exceptions |
Usage Patterns
Basic Browser Automation
from pydoll.browser.chromium import Chrome
async with Chrome() as browser:
tab = await browser.start()
await tab.go_to("https://example.com")
element = await tab.find(id="my-element")
await element.click()
Element Finding
# Using the modern find() method
element = await tab.find(id="username")
element = await tab.find(tag_name="button", class_name="submit")
# Using CSS selectors or XPath
element = await tab.query("#username")
element = await tab.query("//button[@class='submit']")
Event Handling
Type Hints
Pydoll is fully typed and provides comprehensive type hints for better IDE support and code safety. All public APIs include proper type annotations.
from typing import Optional, List
from pydoll.elements.web_element import WebElement
# Methods return properly typed objects
element: Optional[WebElement] = await tab.find(id="test", raise_exc=False)
elements: List[WebElement] = await tab.find(class_name="item", find_all=True)
Async/Await Support
All Pydoll operations are asynchronous and must be used with async
/await
:
import asyncio
async def main():
# All Pydoll operations are async
async with Chrome() as browser:
tab = await browser.start()
await tab.go_to("https://example.com")
asyncio.run(main())
Browse the sections below to explore the complete API documentation for each module.