ImportError: cannot import name _saferef from blinker
blinker 1.8 removed a module that selenium-wire still uses. Install blinker==1.7.0 in the same environment.
Selenium WebDriver automates real Chrome, Firefox and Edge browsers and is common in testing teams and older scraping stacks. Setting a proxy address is easy, but WebDriver has no standard way to send a proxy username and password, which is where most Selenium proxy problems start.
There are two reliable approaches. selenium-wire runs a small local proxy that adds your credentials, so the browser itself needs none. The second is to allowlist your server IP in the dashboard and pass only the gateway address with --proxy-server.
Updated 23 November 2026
With selenium-wire you can use HTTP on 8000 or SOCKS5 on 9000 with credentials. With plain --proxy-server, credentials are not possible, so use the allowlist. Your username and token appear on the Proxy setup page of your dashboard after your first order.
Follow the steps in order. Replace YOUR_TOKEN with the token from your dashboard and change the country, city or session in the username to suit the job.
Selenium 4.6 and later downloads the right driver automatically through Selenium Manager. selenium-wire is no longer actively maintained and imports a module removed in blinker 1.8, so pin blinker to 1.7.0 alongside it.
python -m pip install selenium selenium-wire "blinker==1.7.0"Chrome reads --proxy-server as an address only. Writing user:pass@ inside it is ignored, and the browser then shows a sign-in dialog that WebDriver cannot fill. Firefox proxy preferences have the same limit. That is why the next steps add credentials outside the browser.
Import webdriver from seleniumwire instead of selenium and pass the proxy in seleniumwire_options. The no_proxy list keeps the local driver traffic direct.
from seleniumwire import webdriver
PROXY = "http://user-country-us:YOUR_TOKEN@gate.firstproxy.shop:8000"
options = {
"proxy": {
"http": PROXY,
"https": PROXY,
"no_proxy": "localhost,127.0.0.1",
}
}
driver = webdriver.Chrome(seleniumwire_options=options)
driver.get("https://ipinfo.io/json")
print(driver.find_element("tag name", "body").text)
driver.quit()Build the username with a session per driver. Tests that log in and click through several pages then stay on one IP, and parallel workers each get their own.
import uuid
sid = uuid.uuid4().hex[:8]
user = f"user-country-us-city-chicago-session-{sid}-ttl-30m"
PROXY = f"http://{user}:YOUR_TOKEN@gate.firstproxy.shop:8000"
driver = webdriver.Chrome(seleniumwire_options={
"proxy": {"http": PROXY, "https": PROXY, "no_proxy": "localhost,127.0.0.1"}
})If you would rather not run selenium-wire, add the public IPv4 address of the machine running the tests to the allowlist in your dashboard (up to 10 addresses). Requests from that address are accepted without a password, so --proxy-server with only the host and port works. This suits stable servers and CI runners with a fixed IP.
from selenium import webdriver
opts = webdriver.ChromeOptions()
opts.add_argument("--proxy-server=http://gate.firstproxy.shop:8000")
driver = webdriver.Chrome(options=opts)
driver.get("https://ipinfo.io/json")Without a username, there is nowhere to write country or session targeting. Use selenium-wire when each run needs its own location or sticky session.
Load ipinfo.io/json in the driven browser and print the page text. Compare it with a run without the proxy to be sure the IP changed.
A working proxy returns a response like the one shown, trimmed to the main fields. The IP belongs to the exit, the city and country follow your username, and the time zone is where that IP is located, here United States.
driver.get("https://ipinfo.io/json")
print(driver.find_element("tag name", "body").text){
"ip": "203.0.113.24",
"city": "New York",
"country": "US",
"timezone": "America/New_York"
}203.0.113.24 is a documentation address. Your result shows a real exit IP.
All targeting is written into the username, so Selenium needs no extra settings to change location. Parts are joined with hyphens in this order after your proxy user. The password is always your token.
| Part | Format | Example | Rule |
|---|---|---|---|
| Country | -country-{cc} | -country-us | Required. Two-letter country code in lowercase. 64 countries are available. |
| City | -city-{city} | -city-new-york | Optional. City name in lowercase, spaces become hyphens. 172 cities are available. |
| Session | -session-{id} | -session-a1b2c3 | Optional. Any letters and digits you choose. The same id keeps the same IP, a new id gets a new IP. |
| Session length | -ttl-{minutes}m | -ttl-30m | Used with a session. Residential 1 to 120 minutes, mobile 1 to 60, long-acting ISP up to 720 (12 hours). |
user-country-us-city-new-york-session-a1b2c3-ttl-30mFind country codes and city values on the proxy locations page.
The problems people run into most often with Selenium, with the message you are likely to see and how to solve it.
blinker 1.8 removed a module that selenium-wire still uses. Install blinker==1.7.0 in the same environment.
Credentials were put into --proxy-server or Firefox preferences, where they are ignored. Switch to selenium-wire, or allowlist the machine IP and drop the credentials.
selenium-wire decrypts HTTPS locally to add headers, using its own certificate authority. It tells the driver to accept that certificate. If a site or test rejects it, use allowlist mode, which leaves TLS untouched.
The allowlist checks the public IP the request comes from. Behind NAT, a VPN or a cloud runner, that differs from the local address. Look up your public IP and add that one.
Every request passes through Python. Set driver.scopes to the domains you need to inspect, or disable request capture with the disable_capture option, to cut the overhead.
All products share one account, one prepaid balance and the same gateway, so you can switch type by changing the product, not the code.
From $0.23 per GB
Rotating or sticky home IPs for cross-country UI checks and scraping with real browsers.
View residential proxiesFrom $0.33 per IP per month
A fixed, fast IP per test runner that works with allowlist mode and plain --proxy-server.
View static isp proxiesFrom $2.34 per IP per month
One residential IP that stays yours for the month, for tests that log in to the same accounts.
View static residential proxiesBuilding a scraper? The web scraping use case covers request rates, retries and product choice in more depth.
Short answers to what people ask most about using a proxy with Selenium.
Use selenium-wire and pass the proxy URL with credentials in seleniumwire_options. Plain Selenium cannot send proxy credentials, because Chrome and Firefox read only a host and port from their proxy settings.
No. Chrome ignores credentials in that flag and shows a sign-in dialog instead. Use selenium-wire or allowlist the IP of the machine that runs the browser.
It works with Selenium 4 but is no longer actively maintained. Pin blinker to 1.7.0 and test after Selenium upgrades. For long-term projects, allowlist mode or a move to Playwright avoids the dependency.
Start each driver with a new session name in the username, or with no session for rotating IPs. Allowlist mode uses one gateway address, so per-test targeting needs selenium-wire.
Launch or context-level proxy with username and password, one IP per browser context.
Scraping and automation librariesPuppeteer proxy setup--proxy-server plus page.authenticate, per-context proxies and SOCKS5 through a local bridge.
Scraping and automation librariesPython requests proxy setupThe proxies dict, sessions with sticky IPs, SOCKS5 with socks5h and async options.
Web browsersFirefox proxy setupBuilt-in manual proxy fields, Proxy DNS for SOCKS5, FoxyProxy and WebRTC settings.
Get your token and run the first Selenium request
Create an account, top up from $40 with crypto, and copy the gateway, username and token from the dashboard.