Prerequisites
Before you begin, ensure you have:- Python 3.10 or higher installed
- Chrome or a Chromium-based browser installed
- pip package manager
Installation
Install the package
Install Undetected using pip:This will also install the required dependencies: selenium, requests, websockets, and packaging.
Test Bot Detection Bypass
Let’s verify that Undetected successfully bypasses bot detection:If the test site shows green checkmarks for most tests, your setup is working correctly. Some advanced detection methods may still identify automation, but common systems like CloudFlare should be bypassed.
Common Usage Patterns
Headless Mode
Run Chrome without a visible window:Custom Options
Customize browser behavior using ChromeOptions:Using Context Manager
Automatically clean up resources:Multiprocessing
For running multiple browser instances in parallel:When using multiprocessing, always call
Patcher.patch() once in the main process before creating workers, and use user_multi_procs=True in worker processes.Next Steps
Core Concepts
Learn about the Chrome class and its parameters
Advanced Features
Explore CDP events, headless mode, and more
Guides
Follow practical guides for common use cases
API Reference
Complete API documentation for all classes
Best Practices
Always clean up resources
Always clean up resources
Always call
driver.quit() or use a context manager to ensure the browser and ChromeDriver processes are properly terminated.Stick to default settings
Stick to default settings
Undetected works best with default settings. Customizing ChromeOptions can introduce detectable fingerprints.
Handle the first run
Handle the first run
The first run will download and patch ChromeDriver, which may take 10-30 seconds. Plan for this in your automation scripts.
Use natural delays
Use natural delays
Add random delays between actions to mimic human behavior: