How to Automate a Multi-Tab Flow with Vibium
Automate a multi-tab flow with Vibium in Python — open new tabs with new_page(), switch with bring_to_front(), capture popups, and close tabs cleanly.
To automate a multi-tab flow with Vibium, open extra tabs with browser.new_page(), drive each returned page object independently, switch focus with page.bring_to_front(), and capture link- or script-opened tabs by registering browser.on_popup() before the click. Vibium is built on WebDriver BiDi, where every tab is an independently addressable browsing context — so there is no Selenium-style window-handle switching. You hold a reference to each tab and call methods on the one you want. browser.pages() lists all open tabs, page.close() closes a single tab, and browser.close() tears everything down. Because Vibium auto-waits for actionability on every command, parallel tabs stay reliable without manual sleeps. The pattern below works for comparison shopping, cross-tab dashboards, OAuth popups, and "open in new tab" link checks — all in plain Python with the verified sync API.
How do you open and drive multiple tabs?
Open each tab with browser.new_page(), which returns a page object you control on its own. The example below loads two different pages side by side, then reads from each without any window switching:
from vibium import browser_sync as browser
bro = browser.launch()
# First tab
dash = bro.new_page()
dash.go("https://app.example.com/dashboard")
# Second tab, opened independently
settings = bro.new_page()
settings.go("https://app.example.com/settings")
# Act on whichever tab you want — no switching needed
print(dash.find("h1").text())
print(settings.find("h1").text())
bro.quit()Each page keeps its own URL, history, and DOM. You are not "on" one tab at a time as you would be with a classic WebDriver session — you simply call methods on the reference you hold. To see every open tab, call bro.pages(), which returns a list you can iterate.
How do you switch focus between tabs?
Use page.bring_to_front() to give a specific tab operating-system focus (the equivalent of clicking its tab strip). You rarely need this for scripted actions — Vibium can read and interact with a background tab directly — but it matters when a page only behaves correctly while visible, such as media that pauses when hidden or layout that depends on visibilityState.
dash.bring_to_front() # this tab is now the active, visible one
dash.screenshot() # capture it while focused
settings.bring_to_front() # flip focus to the other tabFor the underlying model behind these independent contexts, see what WebDriver BiDi is and how Vibium works.
How do you capture a tab opened by a link or popup?
Register browser.on_popup() (for window.open() popups) or browser.on_page() (for any new tab/window) before the action that opens it, then trigger the click. Vibium passes the new page into your callback so you can drive it immediately, instead of guessing which window appeared:
from vibium import browser_sync as browser
bro = browser.launch()
vibe = bro.new_page()
vibe.go("https://example.com/reports")
opened = []
bro.on_popup(lambda page: opened.append(page))
# A link with target="_blank" or a window.open() trigger
vibe.find('a[data-report="quarterly"]').click()
new_tab = opened[0]
new_tab.go(new_tab.url()) # ensure it's loaded
print(new_tab.title())
new_tab.close() # close just this tab
bro.quit()This is the reliable way to handle OAuth consent windows, "open invoice in new tab" links, and any flow where the app — not your script — decides to open a tab.
How do you close tabs cleanly?
Close a single tab with page.close(); close the whole browser (and every tab) with browser.quit(). Closing tabs you no longer need keeps memory low during long multi-tab runs:
settings.close() # close one tab, keep the rest of the session alive
bro.quit() # close all tabs and end the sessionA good rule: close transient popups as soon as you have read what you need, and leave a single bro.quit() at the end as the catch-all teardown.
Common multi-tab pitfalls
- Registering the popup listener too late. Always call
on_popup()/on_page()before the click that opens the tab, or you may miss it. - Assuming a popup is loaded. A freshly opened tab may still be navigating. Read its
url()/title()after it settles, or re-navigate as shown above. - Leaking tabs. Each abandoned tab keeps consuming memory. Close popups you are done with and rely on
quit()for final cleanup.
Next steps
Frequently asked questions
How do I open a new tab in Vibium?
Call browser.new_page() on the launched browser to open a fresh tab and get back a page object you can drive independently. Each page keeps its own navigation, so you can load different URLs in parallel and switch between them with bring_to_front().
How does Vibium switch between tabs?
Vibium needs no driver-style window switching. Every tab is an independent page reference, so you act on the one you want directly. Use page.bring_to_front() to give a tab OS focus, and browser.pages() to list every open tab in the session.
Can Vibium catch tabs opened by a link or popup?
Yes. Register browser.on_popup() before clicking a target="_blank" link or a window.open() trigger. When the new tab opens, Vibium hands you its page object in the callback so you can drive it without guessing which window appeared.
Vibium is created by Jason Huggins. This is an independent tutorial — see the official Vibium site and GitHub repo for canonical docs.
Related guides
How to Automate a Checkout Flow with Vibium
Automate an e-commerce checkout with Vibium in Python — add to cart, fill shipping and payment fields, place the order, and verify the confirmation page.
4 min read→How-To RecipesHow to Automate a Google Search with Vibium
Automate a Google search with Vibium in Python — open Google, type a query, submit it, and read the result titles in about ten lines of code.
3 min read→How-To RecipesHow to Automate a Search Box with Vibium
Automate a search box with Vibium in Python — find the input, type your query, press Enter, wait for results to render, and read them back with findAll.
3 min read→How-To RecipesHow to Capture Console Logs with Vibium
Capture browser console logs with Vibium in Python — register on_console() to collect log, warn, and error messages, then read each entry's text and type.
3 min read→