Skip to main content

Overview

The Tab class represents a browser tab (or target) and provides methods for navigation, element interaction, and page manipulation. A tab could be a browser window, an iframe, a service worker, or a background script.
Tab objects are created by the Browser. Access them via browser.tabs, browser.main_tab, or by calling browser.get().

Properties

Browser
Reference to the parent Browser instance.
str
Current URL of the tab (updated when you await tab).
str
Unique identifier for this target.
str
Type of target: “page”, “iframe”, “worker”, etc.
str
Frame identifier for the current page.
str
URL to open Chrome DevTools inspector for this tab.

Element Finding Methods

find()

Find a single element by text content. Retries until timeout if not found.
str
required
Text to search for. Script contents are also considered text.
bool
default:"True"
When True, returns the element with the most similar text length. This helps find specific elements like a “login” button instead of scripts containing “login”. When False, returns the first match (faster).
bool
default:"True"
When True, returns the parent element containing the text node. Set to False to get the text node itself.
float | int
default:"10"
Maximum seconds to wait for the element to appear.
Example:

select()

Find a single element by CSS selector. Retries until timeout if not found.
str
required
CSS selector string (e.g., a[href], button[class*=close], a > img[src]).
float | int
default:"10"
Maximum seconds to wait for the element to appear.
Example:

find_all()

Find multiple elements by text content.
str
required
Text to search for.
float | int
default:"10"
Maximum seconds to wait.
Example:

select_all()

Find multiple elements by CSS selector.
str
required
CSS selector string.
float | int
default:"10"
Maximum seconds to wait.
bool
default:"False"
Whether to include results from iframes.
Example:

xpath()

Find elements by XPath expression.
str
required
XPath expression string.
float
default:"2.5"
Maximum seconds to wait.
Example:

query_selector()

Low-level CSS selector query (equivalent to document.querySelector).

query_selector_all()

Low-level CSS selector query for multiple elements (equivalent to document.querySelectorAll).

get()

Navigate to a URL.
str
default:"chrome://welcome"
URL to navigate to.
bool
default:"False"
Open in a new tab.
bool
default:"False"
Open in a new window.
Example:

back()

Navigate back in history.

forward()

Navigate forward in history.

reload()

Reload the current page.
bool
default:"True"
Whether to bypass the cache.
str
default:"None"
JavaScript to execute when the page loads.
Example:

Page Content Methods

get_content()

Get the HTML content of the page.
Example:

evaluate()

Execute JavaScript and get the result.
str
required
JavaScript expression to evaluate.
bool
default:"False"
Whether to await the result if it’s a Promise.
bool
default:"True"
Return the value directly instead of a remote object reference.
Example:

js_dumps()

Dump a JavaScript object with its properties and values as a Python dictionary.
str
required
Name of the JavaScript object to dump (e.g., “window”, “document”, “navigator”).
bool
default:"True"
Return the value directly as a dict. If False, returns the remote object reference.
Complex objects might not be fully serializable. This method provides a best-effort conversion to Python dictionaries.
Example:

Window Management

maximize()

Maximize the window.

minimize()

Minimize the window.

fullscreen()

Set window to fullscreen.

medimize()

Restore window to normal size (not minimized, maximized, or fullscreen).
This is a convenience alias for set_window_state(state="normal").

set_window_size()

Set window position and size.
Example:

activate()

Bring this tab to the front.

close()

Close this tab.

Scrolling Methods

scroll_down()

Scroll down by a specified amount.

scroll_up()

Scroll up by a specified amount.
Example:

Mouse Interaction

mouse_move()

Move the mouse to specific coordinates.
float
required
X coordinate.
float
required
Y coordinate.
int
default:"10"
Number of steps for smooth movement.
bool
default:"False"
Flash the point for visibility.

mouse_click()

Click at specific coordinates.

mouse_drag()

Drag from one position to another.

Screenshots

save_screenshot()

Save a screenshot of the page.
str
default:"screenshot.png"
Path to save the screenshot.
str
default:"png"
Image format: ‘png’ or ‘jpeg’.
bool
default:"False"
Capture the entire page, not just the viewport.
Example:

File Downloads

download_file()

Download a file from a URL.
str
required
URL of the file to download.
PathLike
default:"None"
Optional filename. If None, uses the filename from the URL.
Example:

set_download_path()

Set the default download directory.

Storage Methods

get_local_storage()

Get all localStorage items.

set_local_storage()

Set localStorage items.
Example:

Anti-Detection & Security

verify_cf()

Verify Cloudflare checkbox challenge automatically. This method locates and clicks the Cloudflare verification checkbox.
str
default:"None"
Custom template image for locating the checkbox. The default template is in English. If you need a different language, create a cropped image (111x71 pixels) with the checkbox target centered.
bool
default:"False"
If True, flashes the located checkbox area for debugging.
This method only works when NOT in expert mode. Requires the opencv-python package to be installed.
Example:

bypass_insecure_connection_warning()

Bypass the browser’s insecure connection warning (e.g., when a certificate is invalid).
This method sends the special string “thisisunsafe” to bypass Chrome’s SSL warning page.
Example:

Waiting and Timing

wait()

Wait for a specified time.

sleep()

Alias for wait().

wait_for()

Wait for a condition to be true.
Example:

Inspector

open_external_inspector()

Open Chrome DevTools inspector in your system browser.
Example:

Custom CDP Commands

Send custom Chrome DevTools Protocol commands:

Examples

Complete scraping example

See also