Manage Browser Tabs
Open, switch, and close browser tabs for multi-tab workflows.
Lightcone browser sessions support multi-tab management. Open tabs to compare data across sites, fill forms that span multiple pages, or monitor dashboards side by side. Each tab has its own URL and page state, and you can target actions at specific tabs without switching.
List open tabs
Section titled “List open tabs”from tzafon import Lightcone
client = Lightcone()
session = client.computers.create(kind="browser")
result = client.computers.tabs.list(session.id)print(result.result) # List of tabs with id, url, title, is_main_tabimport Lightcone from "@tzafon/lightcone";
const client = new Lightcone();const session = await client.computers.create({ kind: "browser" });
const result = await client.computers.tabs.list(session.id!);console.log(result.result);Open a new tab
Section titled “Open a new tab”client.computers.tabs.create(session.id, url="https://example.com")await client.computers.tabs.create(session.id!, { url: "https://example.com" });The new tab becomes the active (main) tab automatically.
Switch between tabs
Section titled “Switch between tabs”# List tabs to get IDstabs_result = client.computers.tabs.list(session.id)
# Switch to a specific tab by IDclient.computers.tabs.switch("tab_abc123", id=session.id)const tabsResult = await client.computers.tabs.list(session.id!);
await client.computers.tabs.switch("tab_abc123", { id: session.id! });Close a tab
Section titled “Close a tab”client.computers.tabs.delete("tab_abc123", id=session.id)await client.computers.tabs.delete("tab_abc123", { id: session.id! });Target a specific tab for actions
Section titled “Target a specific tab for actions”Most actions accept a tab_id parameter to target a specific tab without switching:
# Take a screenshot of a background tabclient.computers.screenshot(session.id, tab_id="tab_abc123")
# Type into a background tabclient.computers.type(session.id, text="hello", tab_id="tab_abc123")await client.computers.screenshot(session.id!, { tab_id: "tab_abc123" });await client.computers.type(session.id!, { text: "hello", tab_id: "tab_abc123" });Example: compare two pages
Section titled “Example: compare two pages”with client.computer.create(kind="browser") as computer: # Open first page computer.navigate("https://en.wikipedia.org/wiki/Python_(programming_language)") computer.wait(2)
# Open second page in a new tab client.computers.tabs.create(computer.id, url="https://en.wikipedia.org/wiki/JavaScript")
# Wait for load, then screenshot the second tab computer.wait(2) result = computer.screenshot() print(f"Tab 2: {computer.get_screenshot_url(result)}")
# List tabs to get the first tab's ID tabs = client.computers.tabs.list(computer.id) # Switch back to the first tab first_tab = tabs.result # contains tab IDsconst session = await client.computers.create({ kind: "browser" });const id = session.id!;
try { // Open first page await client.computers.navigate(id, { url: "https://en.wikipedia.org/wiki/Python_(programming_language)", });
// Open second page in a new tab await client.computers.tabs.create(id, { url: "https://en.wikipedia.org/wiki/JavaScript", });
// Screenshot the second tab (now active) const result = await client.computers.screenshot(id); console.log("Tab 2 screenshot:", result.result?.screenshot_url);
// List tabs and switch back const tabs = await client.computers.tabs.list(id); console.log("Open tabs:", tabs.result);} finally { await client.computers.delete(id);}- Tab IDs come from
tabs.list()— always list tabs to discover IDs - New tabs become the main tab — actions without
tab_idtarget the main tab - Tab list may be eventually consistent — wait briefly after creating a tab before listing
- Use
tab_idon actions to interact with background tabs without switching
See also
Section titled “See also”- Computers — session lifecycle, actions, and configuration
- Dashboard monitoring — monitor multiple dashboards with tabs
- Automate a browser — single-tab browser automation walkthrough