from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: # Open multiple tabs session.execute(type="goto", url="https://example.com") session.execute(type="goto_new_tab", url="https://example.com/products") # Switch back to first tab session.execute(type="switch_tab", tab_index=0)
Parameters:
tab_index (int): Zero-based index of the tab to switch to
Use for: Managing multiple tabs, comparing content across pages
from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: session.execute(type="goto", url="https://example.com") session.execute(type="goto", url="https://example.com/products") # Go back to homepage session.execute(type="go_back")
Use for: Browser back button functionality, returning to previous pages
from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: session.execute(type="goto", url="https://example.com") session.execute(type="goto", url="https://example.com/products") session.execute(type="go_back") # Now go forward again session.execute(type="go_forward")
from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: session.execute(type="goto", url="https://example.com") # Click by CSS selector session.execute(type="click", selector="button#submit") # Click by ID from observe() session.execute(type="click", id="B1") # Click by text selector session.execute(type="click", selector="button:has-text('Submit')")
Parameters:
selector (str): CSS selector for the element
id (str): Element ID
text (str): Exact text content
aria_label (str): ARIA label attribute
placeholder (str): Placeholder text
title (str): Title attribute
Use for: Clicking buttons, links, checkboxes, any clickable element
from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: session.execute(type="goto", url="https://example.com") # Fill by selector session.execute(type="fill", selector="input[name='email']", value="user@example.com") # Fill by ID from observe() session.execute(type="fill", id="I1", value="user@example.com") # Fill by placeholder selector session.execute(type="fill", selector="input[placeholder='Enter your email']", value="user@example.com")
from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: session.execute(type="goto", url="https://example.com") # Select by visible text session.execute(type="select_dropdown_option", selector="select#country", value="United States") # Select by value attribute session.execute(type="select_dropdown_option", selector="select#country", value="us")
Parameters:
selector (str): CSS selector for the select element
option_text (str): Visible text of the option
option_value (str): Value attribute of the option
Use for: Selecting from dropdowns, choosing options
from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: session.execute(type="goto", url="https://example.com/upload") # Upload from local file session.execute(type="upload_file", selector="input[type='file']", file_path="/path/to/document.pdf") # Upload with ID session.execute(type="upload_file", id="file-upload", file_path="/path/to/image.jpg")
Parameters:
selector (str): CSS selector for the file input
id (str): Element ID
file_path (str): Path to the file to upload
Use for: Uploading documents, images, any file input
from notte_sdk import NotteClientfrom pydantic import BaseModelclient = NotteClient()class Product(BaseModel): name: str price: floatwith client.Session() as session: session.execute(type="goto", url="https://example.com") # Get page markdown markdown = session.scrape() # Extract with instructions data = session.scrape(instructions="Extract all product names and prices") # Structured extraction (wrap list in a model) products = session.scrape(response_format=Product, instructions="Extract all products")
Parameters:
instructions (str): Natural language extraction instructions
response_format (type[BaseModel]): Pydantic model for structured output
only_main_content (bool): Extract only main content, ignore headers/footers
Use for: Data extraction, web scraping, content analysisSee Scraping for detailed documentation.
from collections.abc import Sequencefrom notte_sdk import NotteClientfrom notte_sdk.types import EmailResponseclient = NotteClient()def extract_link(messages: Sequence[EmailResponse]) -> str: # Extract verification link from messages for msg in messages: if msg.text_content and "verify" in msg.text_content.lower(): return msg.text_content return ""# Create persona with emailpersona = client.Persona()# Use in sessionwith client.Session() as session: # Trigger email (e.g., verification email) session.execute(type="fill", selector="input[name='email']", value=persona.info.email) session.execute(type="click", selector="button.send-verification") # Read emails from persona messages = persona.emails() # Extract verification link link = extract_link(messages)
Parameters:
persona_id (str): Persona ID with email address
Use for: Reading verification emails, email-based authenticationSee Personas for details.
from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: session.execute(type="goto", url="https://example.com") # Check if element exists result = session.execute(type="click", selector="button.optional", raise_on_failure=False) if result.success: # Element was there and clicked session.execute(type="click", selector="button.next") else: # Element wasn't there, skip print("Optional button not found, continuing...")
from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: session.execute(type="goto", url="https://example.com") # By ID session.execute(type="click", selector="#submit-button") # By class session.execute(type="click", selector=".btn-primary") # By attribute session.execute(type="click", selector="button[type='submit']") # By combination session.execute(type="click", selector="form#login button.submit") # By nth-child session.execute(type="click", selector="ul li:nth-child(2)")
from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: session.execute(type="goto", url="https://example.com") # By ID from observe() session.execute(type="click", id="B1") # By selector session.execute(type="click", selector="button[type='submit']") # By placeholder selector session.execute(type="fill", selector="input[placeholder='Enter email']", value="user@example.com") # By ARIA label selector session.execute(type="click", selector="button[aria-label='Close dialog']")
from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: session.execute(type="goto", url="https://example.com") # Good - uses ID (stable) session.execute(type="click", id="submit-btn") # Good - uses data attribute session.execute(type="click", selector="button[data-testid='submit']") # Avoid - fragile position-based session.execute(type="click", selector="div > div > button:nth-child(3)")
Use specific selectors:
specific_selectors.py
from notte_sdk import NotteClientclient = NotteClient()with client.Session() as session: session.execute(type="goto", url="https://example.com") # Good - specific session.execute(type="fill", selector="form#login input[name='email']", value="user@example.com") # Less specific - might match wrong element session.execute(type="fill", selector="input", value="user@example.com")
from notte_sdk import NotteClientclient = NotteClient()def process_data(data): print(f"Processed: {data[:100]}...")with client.Session() as session: # Open multiple tabs session.execute(type="goto", url="https://site1.com") session.execute(type="goto_new_tab", url="https://site2.com") session.execute(type="goto_new_tab", url="https://site3.com") # Extract from each tab for tab_index in range(3): session.execute(type="switch_tab", tab_index=tab_index) data = session.scrape() process_data(data)