Browser sessions support multi-tab management, allowing you to open, switch between, and control multiple tabs within a single computer instance. This enables complex workflows like:
Comparing content across multiple pages
Filling forms on different sites simultaneously
Monitoring multiple dashboards
Cross-tab automation workflows
Multi-tab management is browser sessions only. Desktop instances do not support tabs.
All browser actions support targeting specific tabs using the tab_id parameter. The high-level wrapper methods (computer.navigate(), computer.click(), etc.) don’t expose this parameter directly. Use computer.execute() for tab-specific operations:
Copy
Ask AI
from tzafon import Computerclient = Computer()with client.create(kind="browser") as computer: # Use execute() for tab-specific operations computer.execute({ "type": "go_to_url", "url": "https://example.com", "tab_id": "tab_abc123" }) computer.execute({ "type": "click", "x": 100, "y": 200, "tab_id": "tab_abc123" }) computer.execute({ "type": "type", "text": "Hello", "tab_id": "tab_abc123" }) result = computer.execute({ "type": "screenshot", "tab_id": "tab_abc123" })
Important: The high-level wrapper methods (computer.navigate(), computer.click(), etc.) do NOT support the tab_id parameter. Use computer.execute() for tab-specific operations.
If tab_id is not specified, actions execute on the currently active tab.
The TypeScript SDK exposes tab endpoints via client.computers.tabs:
TypeScript
Copy
Ask AI
import Computer from '@tzafon/computer';const client = new Computer();const computer = await client.create({ kind: 'browser' });const computerId = computer.id;// List all tabsconst result = await client.computers.tabs.list(computerId);const tabs = result.result.tabs; // array of tab objects with tab_id, url, is_main// Create a new tabconst createResult = await client.computers.tabs.create(computerId, { url: 'https://example.com' });const tabId = createResult.result.created_tab_id;// Switch to a tabawait client.computers.tabs.switch(tabId, computerId);// Close/delete a tabawait client.computers.tabs.delete(tabId, computerId);await computer.terminate();
The Python SDK uses execute() for tab operations:
Python
Copy
Ask AI
from tzafon import Computerclient = Computer()with client.create(kind="browser") as computer: # List all tabs result = computer.execute({"type": "list_tabs"}) tabs = result.result["tabs"] # list of tab dicts with "tab_id", "url", "is_main" # Create a new tab result = computer.execute({ "type": "new_tab", "url": "https://example.com" }) tab_id = result.result["created_tab_id"] # Switch to a tab computer.execute({ "type": "switch_tab", "tab_id": tab_id }) # Close a tab computer.execute({ "type": "close_tab", "tab_id": tab_id })
from tzafon import Computerclient = Computer()with client.create(kind="browser") as computer: # Navigate the initial tab computer.navigate("https://wikipedia.org") computer.wait(2) # List tabs to get the main tab ID result = computer.execute({"type": "list_tabs"}) main_tab = result.result["tabs"][0]["tab_id"] # Create a second tab result = computer.execute({ "type": "new_tab", "url": "https://example.com" }) second_tab = result.result["created_tab_id"] # Work on second tab using execute() with tab_id computer.execute({"type": "click", "x": 100, "y": 200, "tab_id": second_tab}) computer.execute({"type": "type", "text": "search query", "tab_id": second_tab}) # Switch back to main tab computer.execute({ "type": "switch_tab", "tab_id": main_tab }) # Work on main tab computer.execute({"type": "click", "x": 150, "y": 250, "tab_id": main_tab}) # Take screenshots of both tabs screenshot1 = computer.execute({"type": "screenshot", "tab_id": main_tab}) screenshot2 = computer.execute({"type": "screenshot", "tab_id": second_tab}) print(f"Tab 1: {screenshot1.result['screenshot_url']}") print(f"Tab 2: {screenshot2.result['screenshot_url']}") # Close the second tab computer.execute({ "type": "close_tab", "tab_id": second_tab })
Track your tab IDs carefully. Store tab IDs in variables to avoid confusion when managing multiple tabs. Executing actions on the wrong tab is a common mistake.
Use client.computers.tabs.list() periodically to verify which tabs are still open and get their current state.
Always close tabs you no longer need to free up browser resources. Each tab consumes memory and CPU.