MCPcopy Index your code
hub / github.com/seleniumbase/SeleniumBase

github.com/seleniumbase/SeleniumBase @v4.50.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.50.5 ↗ · + Follow
4,399 symbols 18,431 edges 572 files 829 documented · 19% updated 3d agov4.50.5 · 2026-07-03★ 12,83014 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

SeleniumBase

All-in-one Browser Automation Framework:

Web Crawling / Testing / Scraping / Stealth

PyPI version SeleniumBase PyPI downloads SeleniumBase Docs SeleniumBase GitHub Actions YouTube Subscribers

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

📗 API | 📘 Stealth API | 🔠 DesignPatterns | 🔴 Recorder | 📊 Dashboard

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

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

🤖 CI/CD | 🟨 JSMgr | 🌏 Translator | 🎞️ Presenter | 🖼️ Visual | 🗂️ CPlans


  • 🐙 CDP Mode bypasses bot-detection with Chromium-based browsers.
  • 🎭 Stealthy Playwright Mode extends CDP Mode's stealth to Playwright.
  • pip install seleniumbase for the main framework.
  • pip install playwright for the Playwright integration.

📝 Here's a Python example that uses Pure CDP Mode (sb_cdp):

(It navigates to Browserscan where it bypasses bot-detection.)

from seleniumbase import sb_cdp

sb = sb_cdp.Chrome()
sb.goto("https://browserscan.net/bot-detection")
sb.sleep(3)
sb.quit()

BrowserScan Test Results: Normal

(All BrowserScan bot-detection tests passed successfully.)

🎭 Here's an example script that uses Stealthy Playwright Mode:

(Playwright connects to a stealthy SeleniumBase browser session.)

from playwright.sync_api import sync_playwright
from seleniumbase import sb_cdp

sb = sb_cdp.Chrome(guest=True)
endpoint_url = sb.get_endpoint_url()

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp(endpoint_url)
    page = browser.contexts[0].pages[0]
    page.goto("https://bot.sannysoft.com/")
    page.wait_for_timeout(500)

All Sannysoft tests passed successfully

(All Sannysoft bot-detection tests passed successfully.)


📝 The Browserscan example can be expanded into a test demo:

(Assertions added and elements highlighted with JavaScript.)

from seleniumbase import sb_cdp

sb = sb_cdp.Chrome(locale="en", ad_block=True)
sb.goto("https://browserscan.net/bot-detection")
sb.flash("Test Results", duration=1.5, pause=0.5)
sb.assert_element('strong:contains("Normal")')
print("Bot Not Detected")
sb.flash('strong:contains("Normal")', pause=1)
sb.quit()

📝 This example scrapes Hacker News listings:

from seleniumbase import sb_cdp

sb = sb_cdp.Chrome()
sb.goto("https://news.ycombinator.com/submitted?id=seleniumbase")
elements = sb.find_elements("span.titleline > a")
for element in elements:
    print("* " + element.text)

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

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


⚙️ Stealthy architecture flowchart:

Stealthy architecture flowchart

(For maximum stealth, use CDP Mode, which includes Stealthy Playwright Mode.)


🌐 CLI Options for Supported Chromium Browsers

💡 You can set the Chromium browser to use via command line parameters:

python SCRIPT.py --chromium  # Use the unbranded Chromium browser
python SCRIPT.py --cft  # Use Chrome-for-testing
python SCRIPT.py --edge  # Use Microsoft Edge
python SCRIPT.py --brave  # Use Brave browser

Google Chrome is the default browser. Only unbranded Chromium and Chrome-for-Testing get installed automatically if not already installed.

The Chromium browser can also be set via method args, eg: cft=True, use_chromium=True, browser="edge", browser="brave", etc. Eg:

sb = sb_cdp.Chrome(use_chromium=True)

📝 This example saves Google Search results with UC + CDP Mode:

(Results are saved as PDF, HTML, and PNG files to ./latest_logs/)

from seleniumbase import SB

with SB(uc=True, test=True) as sb:
    url = "https://google.com/ncr"
    sb.activate_cdp_mode(url)
    sb.click_if_visible('button:contains("Accept all")')
    sb.type('[name="q"]', "SeleniumBase GitHub page")
    sb.click('[value="Google Search"]')
    sb.sleep(4)  # The "AI Overview" sometimes loads
    print(sb.get_page_title())
    sb.save_as_pdf_to_logs()
    sb.save_page_source_to_logs()
    sb.save_screenshot_to_logs()
    print("Logs have been saved to: ./latest_logs/")

📝 This example bypasses Cloudflare's challenge page with UC + CDP Mode:

(If the Turnstile isn't bypassed automatically, sb.solve_captcha() handles it.)

from seleniumbase import SB

with SB(uc=True, test=True, locale="en") as sb:
    url = "https://gitlab.com/users/sign_in"
    sb.activate_cdp_mode(url)
    sb.sleep(2)
    sb.solve_captcha()
    # (The rest is for testing and demo purposes)
    sb.assert_text("Username", '[for="user_login"]', timeout=3)
    sb.assert_element('label[for="user_login"]')
    sb.highlight('button:contains("Sign in")')
    sb.highlight('h1:contains("GitLab")')
    sb.post_message("SeleniumBase wasn't detected", duration=4)

SeleniumBase SeleniumBase

(Successfully bypassed bot-detection on a Cloudflare challenge page.)

💡 sb.solve_captcha() handles CAPTCHAs that aren't bypassed automatically.

(If no CAPTCHA is present on the current page, then nothing happens.)


📝 This example handles a CAPTCHA page with Pure CDP Mode:

from seleniumbase import sb_cdp

sb = sb_cdp.Chrome(incognito=True)
sb.goto("https://gitlab.com/users/sign_in")
sb.sleep(2)
sb.solve_captcha()
sb.highlight('h1:contains("GitLab")')
sb.highlight('button:contains("Sign in")')
sb.quit()

🧪 Comprehensive E2E Testing with pytest:

📚 The SeleniumBase/examples/ folder includes over 150 ready-to-run examples of E2E testing. Examples that start with test_ or end with _test.py/_tests.py run with pytest. Other examples run directly with raw python (those generally start with raw_ to avoid confusion).

📝 This example tests an e-commerce site with pytest:

```python from seleniumbase import BaseCase BaseCase.main(name, file) # Call pytest

class MyTestClass(BaseCase): def test_swag_labs(self): self.goto("https://www.saucedemo.com") self.type("#user-name", "standard_user") self.type("#password", "secret_sauce\n") self.assert_element("div.inventory_list") self.click('button[name*="backpack"]') self.click("#shopping_cart_container a") self.assert_text("Backpack", "div.cart_item") self.click("button#checkout") self.type("input#first-name", "SeleniumBase") self.type("input#last-name", "Automation") self.type("input#postal-code", "77

Core symbols most depended-on inside this repo

sleep
called by 862
seleniumbase/core/sb_cdp.py
add_slide
called by 541
seleniumbase/fixtures/base_case.py
click
called by 480
examples/migration/raw_selenium/refined_raw.py
goto
called by 449
examples/migration/raw_selenium/refined_raw.py
highlight
called by 291
seleniumbase/core/sb_cdp.py
sleep
called by 277
seleniumbase/fixtures/base_case.py
assert_text
called by 222
examples/migration/raw_selenium/refined_raw.py
execute_script
called by 211
seleniumbase/fixtures/base_case.py

Shape

Method 3,174
Function 879
Class 339
Route 7

Languages

Python100%
TypeScript1%

Modules by API surface

seleniumbase/fixtures/base_case.py578 symbols
seleniumbase/core/sb_cdp.py261 symbols
seleniumbase/translate/spanish.py164 symbols
seleniumbase/translate/russian.py164 symbols
seleniumbase/translate/portuguese.py164 symbols
seleniumbase/translate/korean.py164 symbols
seleniumbase/translate/japanese.py164 symbols
seleniumbase/translate/italian.py164 symbols
seleniumbase/translate/french.py164 symbols
seleniumbase/translate/dutch.py164 symbols
seleniumbase/translate/chinese.py164 symbols
sbase/steps.py103 symbols

Dependencies from manifests, versioned

express4.21.0 · 1×
Babel2.18.0 · 1×
Jinja23.1.6 · 1×
Markdown3.10.2 · 1×
MarkupSafe3.0.3 · 1×
PyAutoGUI0.9.54 · 1×
attrs26.1.0 · 1×
beautifulsoup44.15.0 · 1×
behave1.2.6 · 1×
cairocffi1.7.1 · 1×
certifi2026.6.17 · 1×
charset-normalizer3.4.7 · 1×

For agents

$ claude mcp add SeleniumBase \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact