🎯
Why This Matters
- Full State Capture: Cookies + LocalStorage + SessionStorage + IndexedDB
- Same-Origin Handling: Automatic pre-flight navigation solves the silent killer
- Stealth Mode: Built-in bot detection bypass for enterprise sites
- Zero Login Tax: First run takes seconds, every run after is instant
The "Login Tax" is Killing Your Automation
Every automation architect knows the pain. You build a robust test suite, but 40% of your execution time is spent typing usernames, filling 2FA fields, and waiting for redirects.
It's not just wasted time—it's risk.
- Flakiness: Every login attempt is a potential failure point (network glitches, CAPTCHAs).
- Bot Detection: Logging in 50 times an hour from a CI server? That is the fastest way to get your IP flagged by Cloudflare or Google.
- Maintenance: When the login UI changes, every single test breaks.
The industry standard solution has been "just save the cookies." But if you have tried using pickle or random StackOverflow snippets, you know the truth: It rarely works for modern applications.
🔐
Why the "Old Way" Fails
Most developers try to save cookies and inject them into a fresh browser. Here is why that approach crashes and burns in 2025:
1. Cookies Are Not Enough
Modern web apps are complex. That React dashboard? It stores your JWT auth token in localStorage. That checkout flow? It caches the cart ID in sessionStorage. Saving cookies alone captures maybe 30% of the state. If you don't capture the rest, you get logged out immediately.
2. The "Same-Origin" Trap
This is the silent killer of automation scripts.
If you try to inject a cookie for example.com while your fresh browser is sitting on about:blank (the default state), Chrome blocks it instantly due to security policies.
driver.get("about:blank")
driver.add_cookie({"domain": "example.com", ...})
# 💥 CRASH: InvalidCookieDomainException
The Silent Killer
Most libraries don't handle this. Selenium Teleport does.
⚡
Enter: Selenium Teleport
I built selenium-teleport to solve these architectural gaps once and for all. It is not just a cookie saver; it is a Full State Transporter.
It follows a strict "Teleportation Pattern" that guarantees success:
- CAPTURE: Detailed snapshot of Cookies + LocalStorage + SessionStorage + IndexedDB.
- NAVIGATE: Automatically detects the base domain and performs a "Pre-flight" navigation to satisfy the Same-Origin Policy.
- INJECT: Surgically inserts the state into the browser's secure context.
- TELEPORT: Instant reload to your target URL—already authenticated.
How to Use It
The "Standard" Way (Fast & Simple)
Perfect for internal tools, staging environments, and standard SaaS apps.
from selenium_teleport import create_driver, Teleport
# 1. The Setup
driver = create_driver(profile_path="my_sessions")
# 2. The Teleport
with Teleport(driver, "hackernews_identity.json") as t:
if t.has_state():
# ⚡️ SKIP LOGIN ENTIRELY
t.load("https://news.ycombinator.com/submit")
else:
# First run only: Login manually
driver.get("https://news.ycombinator.com/login")
# ... user logs in ...
# You are now authenticated.
assert "logout" in driver.page_source
Result
Result
The first run takes 10 seconds. Every run after that takes 0.5 seconds.
The "Stealth" Way (Enterprise Grade)
This is where the package shines. If you are testing against sites protected by Cloudflare, DataDome, or Imperva, standard Selenium gets blocked.
selenium-teleport comes with a Hybrid Driver Factory that integrates with sb-stealth-wrapper.
from selenium_teleport import create_driver, Teleport
# This driver mimics a real human user to bypass bot detection
# Requires: pip install selenium-teleport[stealth]
driver = create_driver(use_stealth_wrapper=True)
with Teleport(driver, "protected_app.json") as t:
t.load("https://tough-security-site.com/dashboard")
📊
What We Accomplished
This package solves the "Day 3" problems of automation that simple scripts miss:
Feature Comparison
- Cookie Capture: ✅ Naive Script | ✅ Selenium Teleport
- LocalStorage / SessionStorage: ❌ Naive Script | ✅ Selenium Teleport
- Same-Origin Policy Handling: ❌ Crashing (Naive) | ✅ Auto-Pre-flight (Teleport)
- Bot Detection Bypass: ❌ Naive Script | ✅ Built-in Stealth Mode
- IndexedDB Support (For PWAs): ❌ Naive Script | ✅ Selenium Teleport
🎯
The Bigger Picture
selenium-teleport isn't just a utility; it's a shift in how we write tests.
- Reliability: Fewer login attempts means fewer chances for network timeouts or CAPTCHAs to flake your build.
- Focus: Your tests should verify your features, not the stability of your login page.
- Speed: Stop paying the "Login Tax" on every single test execution.
Get Started
Stop writing login scripts. Start teleporting.
pip install selenium-teleport
Built by Dhiraj Das
Automation Architect. Stop fighting login screens—start building features.
Top comments (0)