Selenium
Attach chromedriver to an open VeilBrowser profile and drive it with Selenium in Python, Java, C# or JavaScript.
Selenium does not launch VeilBrowser profiles. Open the profile first, then
attach chromedriver to it through its DevTools address. The browser keeps its
fingerprint, and navigator.webdriver stays false.
1. Get a matching chromedriver
chromedriver must match the profile's Chrome major. A profile on Chrome 153 needs chromedriver 153 (any 153 build works). Download it from Chrome for Testing for your platform, or let Selenium Manager fetch it by asking for that version (shown below).
2. Open the profile
With the CLI:
veil start <profile-id> --json{
"id": "2b7e1f44-9c05-4a3e-8f21-77c0a1d9e2b6",
"debugPort": 52144,
"webSocketDebuggerUrl": "ws://127.0.0.1:52144/devtools/browser/4e0a…"
}Or with the agent's REST API, POST http://127.0.0.1:38923/sessions/profile
with { "profileId": "<profile-id>" } and the agent's X-API-Key. The address
chromedriver needs is 127.0.0.1:<debugPort>.
chromedriver has to run on the same computer as the browser: the DevTools port listens on loopback only.
3. Attach
from selenium import webdriver
options = webdriver.ChromeOptions()
options.debugger_address = "127.0.0.1:52144"
options.browser_version = "153" # lets Selenium Manager fetch chromedriver 153
driver = webdriver.Chrome(options=options)
driver.get("https://example.com")
print(driver.title)If you downloaded chromedriver yourself, point Selenium at it instead of
setting the browser version, e.g. webdriver.Chrome(service=Service("/path/to/chromedriver"), options=options).
4. Finish
driver.quit() ends the chromedriver session; on an attached browser it does
not close the window. Close the profile with veil stop <profile-id>, the
dashboard's Stop, or DELETE /sessions/{id}, so its data is saved.
Troubleshooting
| Error | Cause |
|---|---|
session not created: This version of ChromeDriver only supports Chrome version N | chromedriver and the profile's Chrome major differ |
cannot connect to chrome at 127.0.0.1:… | The profile is closed, or chromedriver runs on another computer |
| Selenium opens a second, plain Chrome | debuggerAddress was not set, so Selenium launched its own browser |