Integrations / Automation libraries / Selenium
Selenium, attached to a Browz profile.
Selenium cannot attach to a browser by itself, but ChromeDriver can, through the debuggerAddress option. Start a Browz profile, point ChromeDriver at its debug port, and your WebDriver code runs in a saved profile with its own cookies, fingerprint and proxy.
pip install selenium browz-mcpSetup
Set it up.
Install Browz and open it
Download Browz and leave it open.
Install the packages
Terminalpip install selenium browz-mcpGet a matching ChromeDriver
ChromeDriver’s major version must equal the Browz engine’s. Start any profile and read the engine version from its CDP endpoint, then download that ChromeDriver from the Chrome for Testing downloads.
Terminalcurl -s http://127.0.0.1:<debugPort>/json/version | grep '"Browser"'Attach and drive
Pass the driver path yourself: otherwise Selenium Manager fetches a driver for whatever Chrome is installed, which is not the engine you are attaching to.
run.pyfrom selenium import webdriver from selenium.webdriver.chrome.service import Service from browz.agents import browz_session CHROMEDRIVER = "/path/to/chromedriver" # same major version as the Browz engine with browz_session(name="selenium-demo") as session: options = webdriver.ChromeOptions() options.add_experimental_option("debuggerAddress", f"127.0.0.1:{session.debug_port}") driver = webdriver.Chrome(service=Service(executable_path=CHROMEDRIVER), options=options) try: driver.get("https://example.com") print(driver.title) finally: driver.quit() # ends the ChromeDriver session; browz_session stops the profile
Options from ChromeDriver capabilities, Chrome for Testing.
Example
A pytest fixture: one fresh profile per test.
Each test gets its own throwaway profile, so no test inherits another’s cookies.
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from browz.agents import browz_session
CHROMEDRIVER = "/path/to/chromedriver"
@pytest.fixture
def driver():
with browz_session() as session:
options = webdriver.ChromeOptions()
options.add_experimental_option("debuggerAddress", f"127.0.0.1:{session.debug_port}")
d = webdriver.Chrome(service=Service(executable_path=CHROMEDRIVER), options=options)
yield d
d.quit()
def test_title(driver):
driver.get("https://example.com")
assert driver.title == "Example Domain"Good to know
Notes and tips.
- A ChromeDriver of another major version refuses the session. Update it when Browz updates its engine.
- Attach to the browser Browz started; never let the library launch its own. A library-launched browser is a stock one with none of the profile’s fingerprint, proxy or cookies.
- A person completes sign-ins, 2FA codes and CAPTCHAs in the profile’s window; your script can wait for the page that follows. Browz never solves or bypasses CAPTCHAs.
- Automate only where each site’s terms allow it. Our acceptable use policy applies to scripts the same as to people.
- The local API, CDP and the SDKs are on every plan, Free included (5 profiles), and are not metered.
FAQ
Selenium and Browz.
Does Selenium in Java or C# work?
Yes. Every Selenium binding has the debuggerAddress option on ChromeOptions; the Python above is one example.
Can I use Selenium Grid?
Not to attach to a profile on your computer: debuggerAddress needs ChromeDriver on the same computer as the profile.
Why not webdriver.Chrome() alone?
That launches a new Chrome with automation flags and none of the profile’s identity, cookies or proxy.
Get started
Download Browz. Every task, its own browser.
curl -fsSL https://gobrowz.com/agents/install.sh | sh