Skip to content
Nefo

Selenium

How to Use Residential Proxies with Selenium

Vanilla Selenium cannot pass proxy credentials cleanly, so this guide uses selenium-wire to route Chrome or Firefox through Nefo residential proxies without a login popup.

Before you start

Nefo provides residential proxies across 227 countries over HTTP, HTTPS, and SOCKS5 with username/password auth. Generate credentials for free in the dashboard proxy generator; only routed traffic consumes your prepaid bandwidth (from 5 GB for $4.50, non-expiring on flexible plans).

Vanilla Selenium struggles with authenticated proxies, so selenium-wire is the recommended path for passing credentials without a manual login popup.

  • Python 3.9+ with selenium and selenium-wire installed
  • A matching browser driver (ChromeDriver or GeckoDriver)
  • A Nefo account with prepaid bandwidth
  • A username/password from /dashboard/generator
  • Your target country token

Selenium proxy example with selenium-wire

With selenium-wire, pass the full proxy URL in the options:

The username USERNAME-country-us requests a rotating US residential IP; change the country token to move exits, or add state, city, or ASN tokens for precision.

shell
from seleniumwire import webdriver

options = {
    'proxy': {
        'http': 'http://USERNAME-country-us:[email protected]:9000',
        'https': 'http://USERNAME-country-us:[email protected]:9000',
    }
}

driver = webdriver.Chrome(seleniumwire_options=options)
driver.get('https://api.ipify.org')

Selenium rotating vs sticky proxy sessions

Rotating sessions rotate the IP on every request via HTTP port 9000, which fits parallel test runs and broad crawling.

Sticky sessions hold one IP from 1 minute up to 24 hours via HTTP port 10000. Add a token such as USERNAME-country-us-session-run7-lifetime-45 to keep the same IP for a 45-minute session, useful for stateful flows and logins.

Geo-targeting in the Selenium proxy username

All targeting is expressed in the username: country across 227 countries, US state and city, or ASN/ISP within a country. Only the username changes between regions, keeping your driver setup identical.

Automate lawfully, follow the target site's terms of service, and respect applicable law and sensible request pacing.

Frequently asked questions

Chrome and Firefox do not accept inline proxy credentials, which triggers a login popup that Selenium cannot fill. selenium-wire injects the username token and password automatically, so authentication just works.

Start with 5 GB. Keep what you don't use.

Residential bandwidth from $0.53/GB that never expires. Card, PayPal, Apple Pay, Google Pay, Alipay and crypto.