How to Work With iframes in Vibium
Work with iframes in Vibium. Get a frame with page.frame() and call find() on it directly — frames have the full page API, so there is no switchTo().
To work with an iframe in Vibium, get the frame with page.frame() and call find() on it directly — for example frame = vibe.frame("checkout") then frame.find("#card").type("4242"). The key idea is that Vibium frames have the full page API. In WebDriver BiDi, every iframe is its own browsing context, so Vibium hands you each frame as a page-like object that supports find(), click(), type(), screenshot(), and everything else. That means there is no switchTo().frame() and, crucially, no need to switch back to the main document afterward — the classic Selenium footgun where forgetting to switch out breaks the rest of your test. You keep a reference to the main page and to each frame at the same time, and you act on whichever one you want. Use page.frame(nameOrUrl) to grab a specific frame and page.frames() to list them all. The runnable patterns are below.
How do I find an element inside an iframe?
Get the frame with page.frame(), passing its name or a URL fragment, then call find() on the returned frame object exactly as you would on a page.
from vibium import browser_sync as browser
vibe = browser.launch()
vibe.go("https://example.com/checkout")
# grab the iframe by name (or by a URL substring)
frame = vibe.frame("card-fields")
# the frame has the full page API
frame.find("#card-number").type("4242 4242 4242 4242")
frame.find("#expiry").type("12/30")
frame.find(role="button", text="Pay").click()
vibe.quit()frame.find() searches only inside that iframe's document, so selectors that exist in both the main page and the frame never collide. Because the frame is a full page-like object, every command you know from How to Find Elements in Vibium works on it unchanged.
Do I need to switch back to the main page?
No — and this is the biggest difference from Selenium. You never enter a frame "context," so there is nothing to leave. The main page and the frame are separate references you use side by side.
from vibium import browser_sync as browser
vibe = browser.launch()
vibe.go("https://example.com/article")
# interact with a comments widget inside an iframe
comments = vibe.frame("comments-widget")
comments.find("textarea").type("Great post!")
comments.find(role="button", text="Post").click()
# then keep using the main page — no switch-back required
vibe.find("#newsletter-email").type("me@example.com")
vibe.find(role="button", text="Subscribe").click()
vibe.quit()In Selenium you would call driver.switchTo().frame(...), do your work, then remember to call driver.switchTo().defaultContent() — and forgetting that last step is a common cause of "element not found" failures. Vibium removes the entire problem by treating frames as independent objects. See What is WebDriver BiDi? for why every frame is its own browsing context.
How do I list all iframes on a page?
Call page.frames() to get every frame as a list of page-like objects. This is useful when a frame has no stable name or you need to act on several at once.
from vibium import browser_sync as browser
vibe = browser.launch()
vibe.go("https://example.com/dashboard")
for frame in vibe.frames():
print(frame.url())
# operate on a specific frame from the list
ads_frame = vibe.frames()[0]
ads_frame.find(".close").click()
vibe.quit()Each item in frames() is a full frame object with the same API as the page, so you can inspect its URL, find elements, click, or screenshot it. When a frame does have a stable name or recognizable URL, prefer page.frame(nameOrUrl) for clarity over indexing into the list.
iframes in Vibium vs Selenium
- Selenium —
switchTo().frame()moves a single active context into the iframe; you mustswitchTo().defaultContent()to get back out. - Vibium — each frame is its own page-like reference; you call
find()/click()on it directly and keep using the main page with no switch-back.
Because BiDi models frames as browsing contexts, this is not a convenience layer — it is the natural shape of the protocol, which is why it stays reliable across deeply nested frames.
Next steps
Frequently asked questions
How do I work with an iframe in Vibium?
Get the frame with page.frame() by name or URL, then call find() on the returned frame object directly, like frame = vibe.frame('checkout'); frame.find('#card').type('4242'). Frames have the full page API, so there is no switchTo() and no switching back, unlike Selenium.
Do I need to switch into and out of frames in Vibium?
No. In WebDriver BiDi every frame is its own browsing context, and Vibium exposes each one as a page-like object. You hold a reference to the frame and to the main page at the same time, so you act on whichever you want without entering or leaving a frame context.
How do I list all iframes on a page in Vibium?
Call page.frames() to get every frame on the page as a list of page-like objects. Each one supports go(), find(), click(), and the rest of the page API, so you can iterate over them and operate on whichever frame you need directly.
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 Check a Checkbox in Vibium
Check a checkbox in Vibium with el.check(). Runnable Python examples for ticking, unticking, verifying state, and handling many checkboxes.
3 min read→Commands & APIHow to Clear an Input Field in Vibium
Clear an input field in Vibium with el.clear(). Runnable Python examples for emptying text fields, replacing values, and resetting forms.
2 min read→Commands & APIHow to Click Elements in Vibium
Click buttons and links in Vibium with el.click(). Runnable Python examples plus how auto-waiting and actionability make clicks reliable.
2 min read→Commands & APIHow to Count Elements in Vibium
Count elements in Vibium with el.count() or len(findAll()). Runnable Python examples for counting rows, links, search results, and assertions.
3 min read→