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. However, the high-level wrapper methods don’t expose this parameter directly. You must use the direct API or the execute_action()/execute() method:
Copy
Ask AI
from tzafon import Computerclient = Computer()with client.create(kind="browser") as computer: # METHOD 1: Use execute_action for tab-specific operations computer.execute_action({ "type": "navigate", "url": "https://example.com", "tab_id": "tab_abc123" }) computer.execute_action({ "type": "click", "x": 100, "y": 200, "tab_id": "tab_abc123" }) computer.execute_action({ "type": "type", "text": "Hello", "tab_id": "tab_abc123" }) result = computer.execute_action({ "type": "screenshot", "tab_id": "tab_abc123" }) # METHOD 2: Use the direct API (via client.computers) client.computers.navigate( computer.id, url="https://example.com", tab_id="tab_abc123" ) client.computers.click( computer.id, x=100, y=200, tab_id="tab_abc123" )
Important: The high-level wrapper methods (computer.navigate(), computer.click(), etc.) do NOT support the tab_id parameter. Use execute_action()/execute() or the direct client.computers.* API for tab-specific operations.
If tab_id is not specified, actions execute on the currently active tab.
from tzafon import Computerclient = Computer()with client.create(kind="browser") as computer: # Create first tab and navigate computer.navigate("https://wikipedia.org") computer.wait(2) # List tabs to get the main tab ID result = computer.execute_action({"type": "list_tabs"}) main_tab = result.result['tabs'][0]['id'] # Create a second tab result = computer.execute_action({ "type": "new_tab", "url": "https://example.com" }) second_tab = result.executed_tab_id # Work on second tab using execute_action computer.execute_action({ "type": "click", "x": 100, "y": 200, "tab_id": second_tab }) computer.execute_action({ "type": "type", "text": "search query", "tab_id": second_tab }) # Switch back to main tab computer.execute_action({ "type": "switch_tab", "tab_id": main_tab }) # Work on main tab computer.execute_action({ "type": "click", "x": 150, "y": 250, "tab_id": main_tab }) # Take screenshots of both tabs screenshot1 = computer.execute_action({ "type": "screenshot", "tab_id": main_tab }) screenshot2 = computer.execute_action({ "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_action({ "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 list_tabs 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.