Skip to content

API Reference parrot_tools.scraping.drivers.selenium_driver

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.scraping.drivers.selenium_driver

View source

Selenium-based browser automation driver.

Wraps the existing :class:SeleniumSetup class to implement the :class:AbstractDriver interface. All blocking Selenium WebDriver calls are dispatched via :func:asyncio.get_running_loop().run_in_executor so the async event loop is never blocked.

The selenium package is imported lazily inside :meth:start so the module can be loaded even when Selenium is not installed.

Alias AbstractDriver

Re-exported from parrot_tools.scraping.drivers.abstract.AbstractDriver.

Class SeleniumDriver

Selenium-based browser automation driver.

Wraps the existing SeleniumSetup class to implement the full AbstractDriver interface. All blocking Selenium calls are run via run_in_executor to avoid blocking the async event loop.

Extended capability methods (HAR, tracing, PDF, interception) are not overridden — the base-class defaults raise NotImplementedError.

Parameter Type Default Description
browser str 'chrome' Browser name ("chrome", "firefox", "edge", "safari", "undetected").
headless bool True Whether to run in headless mode.
auto_install bool True Whether to auto-install the browser driver.
mobile bool False Whether to emulate a mobile viewport.
options Optional[Dict[str, Any]] None Additional keyword arguments forwarded to SeleniumSetup.

Attributes:

Attribute Type Description
current_url str The URL of the current page.

Method SeleniumDriver.start

Launch browser via SeleniumSetup and store the WebDriver.

start() -> None

Method SeleniumDriver.quit

Close browser and release resources.

quit() -> None

Method SeleniumDriver.navigate

Navigate to url.

navigate(url: str, timeout: int = 30) -> None

Parameter Type Default Description
url str
timeout int 30

Method SeleniumDriver.go_back

Navigate back.

go_back() -> None

Method SeleniumDriver.go_forward

Navigate forward.

go_forward() -> None

Method SeleniumDriver.reload

Reload the current page.

reload() -> None

Method SeleniumDriver.click

Click element matching selector.

On ElementClickInterceptedException or a WebDriverException whose message contains "is not clickable", retries once using a JS scrollIntoView + JS click so overlays / off-screen elements don't prevent interaction.

click(selector: str, timeout: int = 10) -> None

Parameter Type Default Description
selector str
timeout int 10

Method SeleniumDriver.fill

Fill input matching selector with value.

fill(selector: str, value: str, timeout: int = 10) -> None

Parameter Type Default Description
selector str
value str
timeout int 10

Method SeleniumDriver.select_option

Select an option in a <select> element.

select_option(selector: str, value: str, *, by: str = 'value', timeout: int = 10) -> None

Parameter Type Default Description
selector str CSS selector for the select element.
value str Value, visible text, or index string to select.
by str 'value' Selection mode — "value", "text", or "index".
timeout int 10 Maximum wait time in seconds.

Method SeleniumDriver.hover

Hover over element matching selector.

hover(selector: str, timeout: int = 10) -> None

Parameter Type Default Description
selector str
timeout int 10

Method SeleniumDriver.press_key

Press a keyboard key.

press_key(key: str) -> None

Parameter Type Default Description
key str

Method SeleniumDriver.get_page_source

Return the full HTML of the current page.

get_page_source() -> str

Returns: str

Method SeleniumDriver.get_text

Return the inner text of the first matching element.

get_text(selector: str, timeout: int = 10) -> str

Parameter Type Default Description
selector str
timeout int 10

Returns: str

Method SeleniumDriver.get_attribute

Return the value of attribute on the matching element.

get_attribute(selector: str, attribute: str, timeout: int = 10) -> Optional[str]

Parameter Type Default Description
selector str
attribute str
timeout int 10

Returns: Optional[str]

Method SeleniumDriver.get_all_texts

Return inner text of every matching element.

get_all_texts(selector: str, timeout: int = 10) -> List[str]

Parameter Type Default Description
selector str
timeout int 10

Returns: List[str]

Method SeleniumDriver.screenshot

Take a screenshot and save to path.

screenshot(path: str, full_page: bool = False) -> bytes

Parameter Type Default Description
path str
full_page bool False

Returns: bytes

Method SeleniumDriver.type_text

Type keystrokes into a selected or currently focused element.

type_text(text: str, selector: Optional[str] = None, delay_ms: int = 0, clear_first: bool = False, timeout: int = 10) -> None

Parameter Type Default Description
text str
selector Optional[str] None
delay_ms int 0
clear_first bool False
timeout int 10

Method SeleniumDriver.screenshot_element

Capture a PNG of a selected element and save it to path.

screenshot_element(selector: str, path: str, timeout: int = 10) -> bytes

Parameter Type Default Description
selector str
path str
timeout int 10

Returns: bytes

Method SeleniumDriver.wait_for_selector

Wait for selector to reach state.

wait_for_selector(selector: str, timeout: int = 10, state: str = 'visible') -> None

Parameter Type Default Description
selector str
timeout int 10
state str 'visible'

Method SeleniumDriver.wait_for_navigation

Wait for a navigation event to complete.

wait_for_navigation(timeout: int = 30) -> None

Parameter Type Default Description
timeout int 30

Method SeleniumDriver.wait_for_load_state

Wait until the page reaches the given load state.

wait_for_load_state(state: str = 'load', timeout: int = 30) -> None

Parameter Type Default Description
state str 'load'
timeout int 30

Method SeleniumDriver.execute_script

Execute JavaScript with arguments in the page context.

execute_script(script: str, *args: Any) -> Any

Parameter Type Default Description
script str
*args Any ()

Returns: Any

Method SeleniumDriver.evaluate

Evaluate a JavaScript expression and return the result.

evaluate(expression: str) -> Any

Parameter Type Default Description
expression str

Returns: Any

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally