> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.toolkits.async browser toolkit

<a id="camel.toolkits.async_browser_toolkit" />

<a id="camel.toolkits.async_browser_toolkit.extract_function_name" />

## extract\_function\_name

```python theme={"system"}
def extract_function_name(s: str):
```

Extract the pure function name from a string (without parameters or
parentheses)

**Parameters:**

* **s** (str): Input string, e.g., `1.`**`click_id(14)`**, `scroll_up()`, `\'visit_page(url)\'`, etc.

**Returns:**

str: Pure function name (e.g., `click_id`, `scroll_up`, `visit_page`)

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser" />

## AsyncBaseBrowser

```python theme={"system"}
class AsyncBaseBrowser:
```

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    headless = True,
    cache_dir: Optional[str] = None,
    channel: Literal['chrome', 'msedge', 'chromium'] = 'chromium',
    cookie_json_path: Optional[str] = None,
    user_data_dir: Optional[str] = None
):
```

Initialize the asynchronous browser core.

**Parameters:**

* **headless** (bool): Whether to run the browser in headless mode.
* **cache\_dir** (Union\[str, None]): The directory to store cache files.
* **channel** (`Literal["chrome", "msedge", "chromium"]`): The browser channel to use. Must be one of "chrome", "msedge", or "chromium".
* **cookie\_json\_path** (Optional\[str]): Path to a JSON file containing authentication cookies and browser storage state. If provided and the file exists, the browser will load this state to maintain authenticated sessions. This is primarily used when `user_data_dir` is not set.
* **user\_data\_dir** (Optional\[str]): The directory to store user data for persistent context. If None, a fresh browser instance is used without saving data. (default: :obj:`None`)

**Returns:**

None

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.init" />

### init

```python theme={"system"}
def init(self):
```

Initialize the browser asynchronously.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.clean_cache" />

### clean\_cache

```python theme={"system"}
def clean_cache(self):
```

Delete the cache directory and its contents.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.wait_for_load" />

### wait\_for\_load

```python theme={"system"}
def wait_for_load(self, timeout: int = 20):
```

Wait for a certain amount of time for the page to load.

**Parameters:**

* **timeout** (int): Timeout in seconds.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.click_blank_area" />

### click\_blank\_area

```python theme={"system"}
def click_blank_area(self):
```

Click a blank area of the page to unfocus the current element.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.visit_page" />

### visit\_page

```python theme={"system"}
def visit_page(self, url: str):
```

Visit a page with the given URL.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.ask_question_about_video" />

### ask\_question\_about\_video

```python theme={"system"}
def ask_question_about_video(self, question: str):
```

Ask a question about the video on the current page,
such as YouTube video.

**Parameters:**

* **question** (str): The question to ask.

**Returns:**

str: The answer to the question.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.get_screenshot" />

### get\_screenshot

```python theme={"system"}
def get_screenshot(self, save_image: bool = False):
```

Get a screenshot of the current page.

**Parameters:**

* **save\_image** (bool): Whether to save the image to the cache directory.

**Returns:**

Tuple\[Image.Image, str]: A tuple containing the screenshot
image and the path to the image file if saved, otherwise
:obj:`None`.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.capture_full_page_screenshots" />

### capture\_full\_page\_screenshots

```python theme={"system"}
def capture_full_page_screenshots(self, scroll_ratio: float = 0.8):
```

Capture full page screenshots by scrolling the page with
a buffer zone.

**Parameters:**

* **scroll\_ratio** (float): The ratio of viewport height to scroll each step (default: 0.8).

**Returns:**

List\[str]: A list of paths to the captured screenshots.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.get_visual_viewport" />

### get\_visual\_viewport

```python theme={"system"}
def get_visual_viewport(self):
```

Get the visual viewport of the current page.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.get_interactive_elements" />

### get\_interactive\_elements

```python theme={"system"}
def get_interactive_elements(self):
```

**Returns:**

Dict\[str, InteractiveRegion]: A dictionary of interactive elements.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.get_som_screenshot" />

### get\_som\_screenshot

```python theme={"system"}
def get_som_screenshot(self, save_image: bool = False):
```

Get a screenshot of the current viewport with interactive elements
marked.

**Parameters:**

* **save\_image** (bool): Whether to save the image to the cache directory.

**Returns:**

Tuple\[Image.Image, str]: A tuple containing the screenshot image
and the path to the image file.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.scroll_up" />

### scroll\_up

```python theme={"system"}
def scroll_up(self):
```

Scroll up the page.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.scroll_down" />

### scroll\_down

```python theme={"system"}
def scroll_down(self):
```

Scroll down the page.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.get_url" />

### get\_url

```python theme={"system"}
def get_url(self):
```

Get the URL of the current page.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.click_id" />

### click\_id

```python theme={"system"}
def click_id(self, identifier: Union[str, int]):
```

Click an element with the given identifier.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.extract_url_content" />

### extract\_url\_content

```python theme={"system"}
def extract_url_content(self):
```

Extract the content of the current page.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.download_file_id" />

### download\_file\_id

```python theme={"system"}
def download_file_id(self, identifier: Union[str, int]):
```

Download a file with the given identifier.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.fill_input_id" />

### fill\_input\_id

```python theme={"system"}
def fill_input_id(self, identifier: Union[str, int], text: str):
```

Fill an input field with the given text, and then press Enter.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.scroll_to_bottom" />

### scroll\_to\_bottom

```python theme={"system"}
def scroll_to_bottom(self):
```

Scroll to the bottom of the page.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.scroll_to_top" />

### scroll\_to\_top

```python theme={"system"}
def scroll_to_top(self):
```

Scroll to the top of the page.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.hover_id" />

### hover\_id

```python theme={"system"}
def hover_id(self, identifier: Union[str, int]):
```

Hover over an element with the given identifier.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.find_text_on_page" />

### find\_text\_on\_page

```python theme={"system"}
def find_text_on_page(self, search_text: str):
```

Find the next given text on the page, and scroll the page to
the targeted text. It is equivalent to pressing Ctrl + F and
searching for the text.

**Parameters:**

* **search\_text** (str): The text to search for.

**Returns:**

str: The result of the action.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.back" />

### back

```python theme={"system"}
def back(self):
```

Navigate back to the previous page.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.close" />

### close

```python theme={"system"}
def close(self):
```

Close the browser.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.show_interactive_elements" />

### show\_interactive\_elements

```python theme={"system"}
def show_interactive_elements(self):
```

Show simple interactive elements on the current page.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser.get_webpage_content" />

### get\_webpage\_content

```python theme={"system"}
def get_webpage_content(self):
```

Extract the content of the current page.

<a id="camel.toolkits.async_browser_toolkit.AsyncBaseBrowser._ensure_browser_installed" />

### \_ensure\_browser\_installed

```python theme={"system"}
def _ensure_browser_installed(self):
```

Ensure the browser is installed.

<a id="camel.toolkits.async_browser_toolkit.AsyncBrowserToolkit" />

## AsyncBrowserToolkit

```python theme={"system"}
class AsyncBrowserToolkit(BaseToolkit):
```

An asynchronous class for browsing the web and interacting
with web pages.

This class provides methods for browsing the web and interacting with web
pages.

<a id="camel.toolkits.async_browser_toolkit.AsyncBrowserToolkit.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    headless: bool = False,
    cache_dir: Optional[str] = None,
    channel: Literal['chrome', 'msedge', 'chromium'] = 'chromium',
    history_window: int = 5,
    web_agent_model: Optional[BaseModelBackend] = None,
    planning_agent_model: Optional[BaseModelBackend] = None,
    output_language: str = 'en',
    cookie_json_path: Optional[str] = None,
    user_data_dir: Optional[str] = None
):
```

Initialize the BrowserToolkit instance.

**Parameters:**

* **headless** (bool): Whether to run the browser in headless mode.
* **cache\_dir** (Union\[str, None]): The directory to store cache files.
* **channel** (`Literal["chrome", "msedge", "chromium"]`): The browser channel to use. Must be one of "chrome", "msedge", or "chromium".
* **history\_window** (int): The window size for storing the history of actions.
* **web\_agent\_model** (Optional\[BaseModelBackend]): The model backend for the web agent.
* **planning\_agent\_model** (Optional\[BaseModelBackend]): The model backend for the planning agent.
* **output\_language** (str): The language to use for output. (default: :obj:`"en`")
* **cookie\_json\_path** (Optional\[str]): Path to a JSON file containing authentication cookies and browser storage state. If provided and the file exists, the browser will load this state to maintain authenticated sessions without requiring manual login. (default: :obj:`None`)
* **user\_data\_dir** (Optional\[str]): The directory to store user data for persistent context. (default: :obj:`"user_data_dir/"`)

<a id="camel.toolkits.async_browser_toolkit.AsyncBrowserToolkit._reset" />

### \_reset

```python theme={"system"}
def _reset(self):
```

<a id="camel.toolkits.async_browser_toolkit.AsyncBrowserToolkit._initialize_agent" />

### \_initialize\_agent

```python theme={"system"}
def _initialize_agent(self):
```

Initialize the planning and web agents.

<a id="camel.toolkits.async_browser_toolkit.AsyncBrowserToolkit.get_tools" />

### get\_tools

```python theme={"system"}
def get_tools(self):
```
