VLearnVibium

How to Dismiss a Cookie Banner with Vibium

Dismiss a cookie banner with Vibium in Python — find the accept or reject button by role and text, click it, and verify the overlay is gone before automating the page.

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

To dismiss a cookie banner with Vibium, find the consent button by its role and visible text — for example find(role="button", text="Accept") — then click() it. Vibium auto-waits for the button to become actionable, so the banner is cleared the moment it appears. This matters because consent overlays sit on top of the page and intercept clicks: ignore the banner and your next click() may hit the overlay instead of the link you wanted. Targeting the button by its accessible role and label, rather than a brittle CSS class, keeps your script working even when the consent widget changes its markup. For a faster, more reliable approach you can skip the banner entirely by pre-seeding the consent cookie before the page loads, so the site never renders the prompt. Both techniques are a few lines of Python with no driver setup.

What is the dismiss-banner script?

from vibium import browser_sync as browser
 
vibe = browser.launch()
vibe.go("https://example.com")
 
# Find the consent button by what the user sees, then click it
vibe.find(role="button", text="Accept all").click()
 
# Now the overlay is gone and the rest of the page is clickable
vibe.find("a", text="Pricing").click()
 
vibe.quit()

This opens the page, clicks the consent button by its role and label, and then proceeds to interact with the page normally. Because Vibium waits for the button to be visible and enabled first, you do not need a sleep to let the banner animate in.

How does each step work?

  1. vibe.go(url) — opens the page; the consent banner typically renders during or just after load.
  2. find(role="button", text="Accept all") — matches the button by its accessible role and visible text, far more durable than a CSS class that changes between deploys. See find element for the full semantic options.
  3. .click() — dismisses the banner. Vibium scrolls it into view and waits until it is actionable.
  4. The next find().click() — now lands on the real page, because the blocking overlay is gone.

Semantic targeting is the key idea: a human clicks the button labeled "Accept all," and that is exactly what find(role="button", text="Accept all") expresses.

How do I handle "Accept" vs "Reject" wording?

Consent buttons vary — "Accept all," "Reject all," "I agree," "Got it." Pick the action you want and match its text. To reject non-essential cookies, target the reject button instead:

# Decline optional cookies
vibe.find(role="button", text="Reject all").click()

If the exact wording differs by site, match on a partial label the widget uses consistently, or fall back to the container's CSS:

# CSS fallback when text varies
vibe.find("#cookie-banner button.accept").click()

Prefer the semantic role + text form when you can — it survives redesigns that break CSS selectors.

How do I skip the banner entirely?

Clicking the banner every run is fine, but the fastest path is to never show it. Most consent widgets read a cookie on load and skip the prompt when consent already exists. Pre-seed that value with add_init_script, which runs before the page's own scripts:

from vibium import browser_sync as browser
 
vibe = browser.launch()
 
# Runs before page scripts on every navigation in this context
vibe.add_init_script(
    "document.cookie = 'cookie_consent=accepted; path=/';"
)
 
vibe.go("https://example.com")
# The site reads the existing consent value and never renders the banner
 
vibe.quit()

The exact cookie name and value depend on the site — inspect the cookie the banner sets after you accept it once, then replicate it. This is the most robust option for repeatable runs because it removes the timing and clicking entirely.

How do I verify the banner is actually gone?

After dismissing, confirm the overlay is no longer present before continuing, so a slow animation does not swallow your next click:

vibe.find(role="button", text="Accept all").click()
vibe.find("#cookie-banner").wait_until("hidden")  # or "detached"

wait_until() polls until the element reaches the requested state (visible, hidden, attached, or detached) or the timeout fires, so you only proceed once the banner has truly cleared.

  • Match by role and text first — it is the most durable target and reads like the user's intent.
  • Pre-seed the cookie for repeat runsadd_init_script removes the click and the timing risk altogether.
  • Wait for "hidden" or "detached" — verify the overlay is gone before the next interaction so clicks do not get intercepted.

Next steps

Frequently asked questions

How do I dismiss a cookie banner with Vibium?

Find the consent button by its role and visible text, such as find(role='button', text='Accept'), then click it. Vibium auto-waits for the button to be actionable, so the banner is dismissed as soon as it appears, clearing overlays that would otherwise block your other clicks.

How do I close a cookie banner without knowing its exact selector?

Use Vibium's semantic find with the button's visible text, like find(role='button', text='Accept all'). This matches the button by its accessible role and label instead of a brittle CSS class, so it keeps working even when the consent widget changes its markup.

How do I stop a cookie banner from appearing at all?

Set the consent cookie before the page loads with context.addInitScript, or pre-seed cookies on the context. When the site reads an existing consent value on load, it skips rendering the banner entirely, which is faster and more reliable than clicking it every run.

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

Related guides