Manage browser instances and interact with web pages using natural language
Dendrite
class manages a browser instance using Playwright, allowing interactions with web pages using natural language. It handles initialization with API keys, manages browser contexts, and provides methods for navigation, authentication, and other browser-related tasks.
Initializing it starts a new browser instance.
auth
(str | list[str], optional): Domains to authenticate on. Read moreplaywright_options
(Any, optional): Options for configuring Playwright. Defaults to running in non-headless mode with stealth arguments.url
(str): The URL to navigate to.new_page
(bool, optional): Whether to open the URL in a new page. Defaults to False.timeout
(float, optional): The maximum time (in milliseconds) to wait for the page to load. Defaults to 15000.expected_page
(str, optional): A description of the expected page type for verification at runtime. Defaults to an empty string.Page
and Dendrite
class. If invoked from a
Dendrite
instance, it is performed on the active pageurl
(str): The URL to navigate to.timeout
(float, optional): The maximum time (in milliseconds) to wait for the page to load. Defaults to 15000.expected_page
(str, optional): A description of the expected page type for verification at runtime. Defaults to an empty string.
ReturnsInteractionResponse
: The response from the interaction.
Raises
DendriteException
: If no suitable element is found or if the fill operation fails.
Page
and Dendrite
class. If invoked from a
Dendrite
instance, it is performed on the active pageprompt
(str): The prompt describing the element to be clicked.expected_outcome
(str, optional): The expected outcome of the click action.use_cache
(bool, optional): Whether to use cached results for element retrieval. Defaults to True.timeout
(int, optional): The timeout (in milliseconds) for the click operation. Defaults to 15000.force
(bool, optional): Whether to force the click operation. Defaults to False.InteractionResponse
Page
and Dendrite
class. If invoked from a
Dendrite
instance, it is performed on the active pageget_element
and element.fill
,
allowing for a more concise way to interact with elements on the page.
Usage
prompt
(str): The prompt describing the element to be filled.value
(str): The value to fill the element with.expected_outcome
(str, optional): The expected outcome of the fill action.use_cache
(bool, optional): Whether to use cached results for element retrieval. Defaults to True.max_retries
(int, optional): The maximum number of retry attempts for element retrieval. Defaults to 3.timeout
(int, optional): The timeout (in milliseconds) for the fill operation. Defaults to 15000.InteractionResponse
: The response from the interaction.
Raises
DendriteException
: If no suitable element is found or if the fill operation fails.
Page
and Dendrite
class. If invoked from a
Dendrite
instance, it is performed on the active pagefields
(Dict[str, Any]): A dictionary where each key is a field identifier (e.g., a prompt or selector) and each value is the content to fill in that field.
Returns
None
Page
and Dendrite
class. If invoked from a
Dendrite
instance, it is performed on the active pageprompt
(str, optional): The prompt to guide the extraction.type_spec
(TypeSpec, optional): The type specification for the extracted data.use_cache
(bool, optional): Whether to use cached results. Defaults to True.Page
and Dendrite
class. If invoked from a
Dendrite
instance, it is performed on the active pageprompt
(str): The question or prompt to be asked.type_spec
(TypeSpec, optional): The expected return type, which can be a type or a schema. Defaults to None.DendriteException
: If the request fails, the exception includes the failure message and a screenshot.
Page
and Dendrite
class. If invoked from a
Dendrite
instance, it is performed on the active pageprompt
(str): The prompt to determine the condition to wait for on the page.timeout
(float, optional): The maximum time (in milliseconds) to wait for the condition. Defaults to 30000.True
if condition is met before timeout.
Raises
PageConditionNotMet
if condition is not met before timeout
Page
and Dendrite
class. If invoked from a
Dendrite
instance, it is performed on the active pagekey
(str): The main key to be pressed.hold_shift
(bool, optional): Whether to hold the Shift key. Defaults to False.hold_ctrl
(bool, optional): Whether to hold the Control key. Defaults to False.hold_alt
(bool, optional): Whether to hold the Alt key. Defaults to False.hold_cmd
(bool, optional): Whether to hold the Command key (Meta on some systems). Defaults to False.None
Raises
DendriteException
if key press fails
Page
and Dendrite
class. If invoked from a
Dendrite
instance, it is performed on the active pagefiles
(Union[str, pathlib.Path, FilePayload, Sequence[Union[str, pathlib.Path]], Sequence[FilePayload]]): The file(s) to be uploaded.
This can be a file path, a FilePayload
object, or a sequence of file paths or FilePayload
objects.timeout
(float, optional): The maximum amount of time (in milliseconds) to wait for the file chooser to be ready. Defaults to 30000.None
Page
and Dendrite
class. If invoked from a
Dendrite
instance, it is performed on the active pagedownload.save_as
method on the object returned from get_download
.
Usage
timeout
(float, optional): The maximum amount of time (in milliseconds) to wait for the download to complete. Defaults to 30000.Download
Page
and Dendrite
class. If invoked from a
Dendrite
instance, it is performed on the active pagePage
: The active page object.Page
: The newly opened page.cookies
(List[Dict[str, Any]]): A list of cookies to be added to the browser context.