VLearnVibium

How to Switch Between Tabs in Vibium

Work with multiple tabs in Vibium. Each page is independently addressable, so there is no switchTo() — just hold a reference and act on it directly.

By Pramod Dutta··3 min read·Verified with Vibium 26.2
▶ Animated overview · made with Remotion

In Vibium you do not "switch" tabs — each tab is its own page object you act on directly. Where Selenium makes you call driver.switchTo().window() to move a single active focus between tabs, Vibium gives every tab an independent reference. You open a tab with bro.new_page(), keep the returned page in a variable (vibe1, vibe2), and call methods on whichever one you want. There is no global "current tab" and no switching ceremony — vibe1.find(...) and vibe2.find(...) operate on their own tabs simultaneously. When a tab is opened by the page itself (a target="_blank" link, a popup), you grab it with bro.onPage(fn) registered before the click, or by reading bro.pages() afterward. This model maps cleanly onto WebDriver BiDi, where every tab and frame is an addressable browsing context. The runnable patterns for opening, using, and closing tabs are below.

How do I open and use multiple tabs?

Open each tab with new_page() and keep its reference. Then call methods on whichever page you want — both stay live at once.

from vibium import browser_sync as browser
 
bro = browser.launch()
 
vibe1 = bro.new_page()
vibe2 = bro.new_page()
 
vibe1.go("https://example.com/dashboard")
vibe2.go("https://example.com/settings")
 
# act on each tab directly — no switching needed
print(vibe1.title())
print(vibe2.title())
 
bro.close()

Because each page is independent, there is no risk of "operating on the wrong tab" — you literally name the tab you mean. This is one of the cleaner parts of Vibium's design; see What is Vibium? for how the page model fits the overall architecture.

When clicking a link opens a new tab (for example a target="_blank" link), register bro.onPage(fn) before the click so you capture the new page as it is created.

from vibium import browser_sync as browser
 
bro = browser.launch()
vibe = bro.new_page()
vibe.go("https://example.com")
 
# capture any new tab the page opens
new_tabs = []
bro.onPage(lambda page: new_tabs.append(page))
 
vibe.find(role="link", text="Open report").click()
 
report = new_tabs[-1]
print(report.url())
print(report.title())
 
bro.close()

Registering the handler before the click matters: the tab can be created the instant the click lands, so you want the listener already in place. The captured object is a full page — you can call go(), find(), click(), and everything else on it directly.

How do I list and close tabs?

Read every open tab with bro.pages(), and close a single tab with close() on that page object. Closing one tab leaves the others untouched.

from vibium import browser_sync as browser
 
bro = browser.launch()
 
vibe1 = bro.new_page()
vibe2 = bro.new_page()
vibe1.go("https://example.com")
vibe2.go("https://example.com/about")
 
# list all open tabs
for page in bro.pages():
    print(page.url())
 
# close just the second tab
vibe2.close()
 
# end the whole session (all remaining tabs)
bro.close()

page.close() closes one tab; bro.close() ends the entire browser session and every tab with it. Use the per-page close when a flow spawns a tab you are done with, and the browser close at the very end of your script.

Tabs in Vibium vs Selenium

  • Selenium — one active window; you call switchTo().window(handle) to move focus before every action.
  • Vibium — every tab is its own page reference; you act on vibe1 or vibe2 directly, with no switching and no shared active state.

This independent-reference model removes a common source of bugs (acting on a stale or wrong window handle) and makes parallel multi-tab flows straightforward.

Next steps

Frequently asked questions

How do I switch between tabs in Vibium?

You do not switch — each tab is a separate page object you act on directly. Create tabs with bro.new_page() and keep a reference to each, like vibe1 and vibe2. Call methods on whichever page you want; there is no global active tab and no switchTo() like Selenium requires.

How do I handle a tab opened by clicking a link in Vibium?

Register a handler with bro.onPage(fn) before the click, or read bro.pages() after it to get the new page object. Vibium exposes every browsing context as a page, so a tab opened by target=_blank becomes a page you can call go(), find(), and click() on directly.

How do I close a single tab in Vibium?

Call close() on that page object, for example vibe2.close(). It closes only that tab and leaves the others open. To end the whole session and all tabs at once, call bro.close() (or quit()) on the browser instead.

Vibium is created by Jason Huggins. This is an independent tutorial — see the official Vibium site and GitHub repo for canonical docs.

Related guides