VLearnVibium

How 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.

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

To automate a search box with Vibium, find() the input, type() your query, then press("Enter") to submit — Vibium auto-waits for the field to be actionable, so there are no manual sleeps. Many search boxes return results asynchronously, so after submitting you wait for the first result to appear before reading the list with findAll(). This pattern — find, type, submit, wait, read — handles both classic search pages that reload and live, type-ahead boxes that update as you type. Because Vibium drives a real Chrome browser, it sees results rendered by JavaScript exactly as a user would, and its auto-waiting means you do not race the page. The whole flow is a handful of lines of Python with no driver setup, no headless plumbing, and no fragile fixed delays scattered through your script.

What is the search-automation script?

from vibium import browser_sync as browser
 
vibe = browser.launch()
vibe.go("https://example.com")
 
# Type the query and submit
box = vibe.find('input[name="q"]')
box.type("vibium automation")
box.press("Enter")
 
# Wait for results, then read them
vibe.find(".result").wait_until("visible")
for r in vibe.findAll(".result"):
    print(r.text())
 
vibe.quit()

This finds the search input, types a query character by character like a real user, submits with Enter, waits for the first result to render, then prints every result. type() leaves any existing text in place and fires keystroke events, which is what live, type-ahead search boxes listen for.

How does each step work?

  1. vibe.go(url) — opens the page that hosts the search box.
  2. find('input[name="q"]') — locates the search field. Vibium waits until it is visible and enabled before you type. See find element for semantic options like placeholder.
  3. box.type("...") — enters the query keystroke by keystroke, triggering any autocomplete the page wires up.
  4. box.press("Enter") — submits the search, the same way a user would.
  5. find(".result").wait_until("visible") — waits for results to render before reading.
  6. findAll(".result") — returns the full list of result elements so you can read each one.

Should I submit with Enter or a button?

Both work — pick whichever the page actually uses. Pressing Enter from the input mirrors real user behavior and needs no second selector:

box.type("vibium automation")
box.press("Enter")

If the search only runs when a button is clicked, target that button instead:

vibe.find('input[name="q"]').type("vibium automation")
vibe.find(role="button", text="Search").click()

When in doubt, the button-click form is the safest because it triggers the exact handler the site attached to its search action.

How do I handle autocomplete suggestions?

For type-ahead boxes, type the query, wait for the suggestion dropdown, then pick a suggestion instead of pressing Enter:

box = vibe.find("#search")
box.type("vibi")
 
# Wait for the suggestion list, then click the first one
vibe.find(".suggestion").wait_until("visible")
vibe.findAll(".suggestion")[0].click()

Because type() sends real keystrokes, the page's autocomplete fires naturally, and wait_until("visible") holds until the dropdown renders so you do not click before it exists.

How do I read and count the results?

After results render, findAll() gives you the whole set as a list. Count them, read each label, or pull a link from each:

results = vibe.findAll(".result")
print(f"{len(results)} results")
 
for r in results:
    title = r.find("h3").text()
    href = r.find("a").attr("href")
    print(title, "->", href)

A scoped r.find(...) searches only inside each result element, so you cleanly pull the title and link for every hit. Handle the empty case too: if findAll() returns an empty list, the search found nothing.

Tips for reliable search automation

  • Wait for one result before readingfindAll() returns immediately, so waiting on a single result first avoids an empty read on async search.
  • Use type() for live search — keystroke events trigger autocomplete; fill() sets the value in one shot and may skip them.
  • Scope per result — read titles and links with a scoped find() inside each result element so your selectors stay simple.

Next steps

Frequently asked questions

How do I automate a search box with Vibium?

Find the search input with find(), type() your query, then press('Enter') to submit. Vibium auto-waits for the field to be actionable, so you do not need a sleep. After submitting, wait for the first result to appear, then read the results with findAll().

How do I submit a search in Vibium, by Enter or by button?

Use el.press('Enter') to submit from the input, just as a user would. If the search uses a button instead, click it with find(role='button', text='Search').click(). Both work; choose whichever the page actually wires up to run the query.

How do I wait for search results to load in Vibium?

After submitting, wait on the first result element with find('.result').wait_until('visible') before reading. findAll() returns immediately, so waiting for one result first ensures the list has rendered, avoiding an empty read on a slow or asynchronous search.

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

Related guides