Integrations · Intermediate

Using proxies with Selenium WebDriver (Chrome and Firefox)

The classic Selenium problem is authentication: browsers show a credentials prompt WebDriver cannot fill. Two clean answers: whitelist your server, or let Selenium Wire inject the credentials.

2 min read 4 sections Updated Published

Add your server's public IPv4 to the whitelist in the dashboard. Chrome then needs only the proxy address and never shows a prompt. The limit: a browser that is not challenged sends no username, so the gateway cannot read targeting parameters and uses the account's default pool. When each session needs its own country or sticky id, use Option 2.

Python, Chrome, whitelisted server
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

opts = Options()
opts.add_argument("--proxy-server=http://res.proxshift.com:9000")
opts.add_argument("--headless=new")
driver = webdriver.Chrome(options=opts)
driver.get("https://api.ipify.org")
print(driver.find_element("tag name", "body").text)
driver.quit()

Option 2: Selenium Wire (username, password and parameters)#

Selenium Wire runs a local proxy that adds the credentials for you, so the ProxShift URL with all its parameters works unchanged.

Python, Selenium Wire
from seleniumwire import webdriver
from selenium.webdriver.chrome.options import Options

proxy = "http://USER-cc-de-city-berlin-sid-sel1-ttl-30m:[email protected]:9000"
sw_options = {"proxy": {"http": proxy, "https": proxy, "no_proxy": "localhost,127.0.0.1"}}

opts = Options()
opts.add_argument("--headless=new")
driver = webdriver.Chrome(seleniumwire_options=sw_options, options=opts)
driver.get("https://api.ipify.org")
print(driver.find_element("tag name", "body").text)
driver.quit()

Firefox#

Python, Firefox
from selenium import webdriver
from selenium.webdriver.firefox.options import Options

opts = Options()
opts.set_preference("network.proxy.type", 1)
opts.set_preference("network.proxy.http", "res.proxshift.com")
opts.set_preference("network.proxy.http_port", 9000)
opts.set_preference("network.proxy.ssl", "res.proxshift.com")
opts.set_preference("network.proxy.ssl_port", 9000)
opts.set_preference("media.peerconnection.enabled", False)  # no WebRTC leak
driver = webdriver.Firefox(options=opts)  # whitelisted server, no prompt

Practical rules#

  • One driver per session id; drivers keep connections alive, so the exit stays the same until the session lifetime ends.
  • Use --headless=new in Chrome; the old headless mode has a distinctive fingerprint.
  • Set the browser language and time zone to the exit's country; Selenium Wire can also rewrite Accept-Language.

Questions people ask#

Why does Chrome show a proxy login prompt with Selenium?

WebDriver has no API to answer the proxy authentication dialog. Whitelist your IP so no prompt appears, or run Selenium Wire, which injects the Proxy-Authorization header for you.

Ready when you are

Run it for real.

Create an account, top up $20 and paste the endpoint from this guide into your tool. Traffic you buy never expires.