Skip to content

SeleniumBase

Automate browsers without limits. SeleniumBase CDP Mode bypasses bot-detection and CAPTCHAs with ease. Check out the example tests!

Install: pip install seleniumbase

Install

$pip install seleniumbase

Install command taken from the project's README or registry entry. Always review code before running it.

Browser Automation, Web Scraping, and End-to-End Testing.

🚀 Start | 🏰 Features | 🎛️ Options | 📚 Examples | 💻 Scripts | 🗾 Locales

📗 API | 📘 Stealth API | 🔠 Syntax Formats | 🔴 Recorder | 📊 Dashboard

🎖️ GUI | 📰 Test Page | 👤 UC Mode | 🐙 CDP Mode | 📶 Charts | 🖥️ Farm

👁️ How | 🚝 Migration | 🎭 Stealthy Playwright | 🛂 MasterQA | 🚎 Tours

🤖 MCP | 🟨 JS Tools | 🌏 Translator | 🎞️ Presenter | 🖼️ Visual | 🗂️ CPlans


🧪 End-to-End Testing examples are located in ./examples/.

🐙 Stealthy CDP Mode examples are located in ./examples/cdp_mode/.

🎭 Stealthy Playwright examples are located in ./examples/cdp_mode/playwright/.

[!NOTE] Examples that start with test run with pytest. Other examples run directly with raw python.


📝 This example uses seleniumbase sb_cdp (Pure CDP Mode):(It shows some basic methods and bypasses a Cloudflare Turnstile)

from seleniumbase import sb_cdp

sb = sb_cdp.Chrome()  # Launches a stealth browser
sb.goto("https://www.planetminecraft.com/account")
sb.type('[name="email"]', "Test123")
sb.type('[name="password"]', "Pass")
sb.click("input#autologin")  # Unchecks a checkbox
sb.solve_captcha()  # (as backup if not automatic)
sb.assert_element('input[name="login"]')
sb.assert_element_not_visible("input[disabled]")
sb.sleep(1)  # (only to slow down the live demo)
sb.quit()  # (otherwise quits automatically at end)

(Note that the click action only unchecked the "Stay signed in" checkbox.)


✅ sb.solve_captcha() handles CAPTCHAs that aren't bypassed automatically.(If called when there's no CAPTCHA on the page, then nothing happens / no-op.)

ℹ️ sb.assert_* methods wait up to 7 seconds for the expected condition.(Raises an exception if the condition isn't met in time.)


📝 This script searches Hacker News via Algolia. Then prints items and saves to PDF:

from seleniumbase import sb_cdp

sb = sb_cdp.Chrome(fast=True)
sb.goto("https://hn.algolia.com/?query=seleniumbase")
elements = sb.find_elements("div.Story_title > a")
for element in elements:
    print("--> " + element.text)
sb.save_as_pdf("sb_news.pdf", folder="./downloaded_files/")
print("*** PDF saved to: ./downloaded_files/sb_news.pdf")
python raw_cdp_yc_news.py

Similar plugs

An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here…

Open-source web crawler and scraper for LLMs and AI agents: any website into clean, LLM-ready Markdown. Run it yourself, or use Crawl4AI Cloud with one key.

Explore related