Webshare Guides

Using Webshare Proxies with Selenium: Chrome, Firefox and Authentication

How to use Webshare proxies in Selenium with Chrome and Firefox, including the authentication problem and three ways around it, rotation per driver, sticky sessions and common errors.

By Team of Monkeys Editorial Updated 4 min read Affiliate disclosure

This guide contains affiliate links to Geonode and Webshare. If you buy through them we may earn a commission, at no extra cost to you.

Webshare with Selenium illustration showing Selenium connecting through IP allowlist to Website, covering chrome, firefox, auth 3jdej38j4

The authentication problem

Selenium can tell Chrome or Firefox to use a proxy, but neither browser accepts proxy credentials on the command line. When a proxy needs a username and password, the browser shows a login prompt Selenium can't fill. With Webshare you have three clean solutions:

  1. IP authorization. Authorize your machine's IP and skip credentials entirely. The simplest option.
  2. Selenium Wire or a similar library that handles proxy auth for you.
  3. A small local forwarding proxy that adds credentials.

Background in Selenium proxies.

Add your public IP in the Webshare dashboard (see Webshare IP authorization), then:

python
from selenium import webdriver

opts = webdriver.ChromeOptions()
opts.add_argument("--proxy-server=http://PROXY_IP:PORT")
driver = webdriver.Chrome(options=opts)
driver.get("https://httpbin.org/ip")
print(driver.find_element("tag name", "body").text)
driver.quit()

This works with direct proxies from your list. It also works with the backbone host, but then you can't pass rotate or session options (they live in the username), so you'll get the default behaviour for your plan.

Option 2: Selenium Wire

Selenium Wire runs a local proxy that adds credentials, so you can use the full username, including session and targeting options:

python
from seleniumwire import webdriver

proxy = "http://USERNAME-rotate:PASSWORD@p.webshare.io:80"
driver = webdriver.Chrome(seleniumwire_options={"proxy": {"http": proxy, "https": proxy}})
driver.get("https://httpbin.org/ip")

Selenium Wire is convenient, but it's no longer actively maintained and adds overhead. Pin versions and test before relying on it in production.

Option 3: local forwarder

Tools like a small mitmproxy or Squid instance on localhost can forward to Webshare with credentials, while the browser connects to localhost without any. This is the most robust option for large fleets. See self-hosted Squid proxy for the idea.

Firefox

Firefox proxy settings go through preferences:

python
opts = webdriver.FirefoxOptions()
opts.set_preference("network.proxy.type", 1)
opts.set_preference("network.proxy.http", "PROXY_IP")
opts.set_preference("network.proxy.http_port", 8080)
opts.set_preference("network.proxy.ssl", "PROXY_IP")
opts.set_preference("network.proxy.ssl_port", 8080)
driver = webdriver.Firefox(options=opts)

Use your proxy's actual port. The same authentication limits apply, so pair this with IP authorization.

Java

java
ChromeOptions options = new ChromeOptions();
options.addArguments("--proxy-server=http://PROXY_IP:PORT");
WebDriver driver = new ChromeDriver(options);

Budget tip: Before scaling, run a short pilot with Webshare on your real targets and record success rate, latency and bandwidth per result. Our our complete Webshare guide explains which Webshare product fits which job.

Rotation and sessions

The proxy is fixed when the driver starts. To change IP, start a new driver with a different proxy (or a different session username if you use Selenium Wire). For logged-in work, keep one driver per account and one fixed IP per driver, ideally a dedicated static residential proxy. See Webshare sticky sessions.

Product choice

Selenium jobWebshare product
Testing and QA from other countriesDatacenter list in the needed countries
Scraping protected sitesRotating residential (via Selenium Wire or a forwarder)
Account automationDedicated static residential, IP authorization

Common errors

  • Login popup appears: the proxy wants credentials. Use IP authorization or Selenium Wire.
  • ERR_PROXY_CONNECTION_FAILED: wrong host or port.
  • Works locally, fails on a server: the server's IP isn't authorized.

More in fixing common Webshare errors.

Running Selenium on servers

Headless Selenium on Linux servers is common for QA and scheduled automation. Tips for proxy setups there:

  • Authorize the server's outbound IP once and reuse it for every driver.
  • Use a fixed outbound IP (reserved or NAT) so authorization doesn't break after restarts.
  • Set page load timeouts a little higher than usual to allow for proxy latency.
  • Close drivers reliably in finally blocks; orphaned browsers keep connections open and count against threads.

Selenium Grid and proxies

In a Selenium Grid, each node can use a different proxy. Pass the proxy as a capability per session, and keep a mapping of which test ran through which IP. That makes geo-specific failures easy to trace.

Proxy tip: For a second opinion on hard targets, run the same test through Geonode residential proxies, which support sticky sessions up to 24 hours and ASN targeting. We compare the two in using Geonode with Selenium.

A local forwarder in practice

A local forwarding proxy is the most robust option when you need rotating residential sessions with credentials:

  1. Run a forwarder on localhost (for example, a small mitmproxy script or a Squid instance with a parent proxy).
  2. Configure it to forward to Webshare with your username (including session or targeting options) and password.
  3. Point the browser at http://127.0.0.1:PORT with no credentials.

The browser never sees credentials, and you can change sessions by reconfiguring the forwarder.

Choosing between Selenium and alternatives

Selenium shines for cross-browser QA and existing test suites. For new scraping projects, Playwright's built-in proxy authentication avoids most of this page's workarounds. See Webshare with Playwright.

A real-world example

An insurance comparison company has a large Selenium test suite that checks quote forms in six US states. They need state-specific IPs, and their tests run on a fixed-IP CI server. They authorize the CI server's IP with Webshare and assign each state a static residential proxy in that state, configured through Chrome's --proxy-server flag. Because there are no credentials, there are no login popups, and the suite runs unchanged except for one proxy argument per state.

If you're still shortlisting, compare this setup with the options in our best proxies guide, and use our cheap proxies guide to estimate what a sensible budget looks like. For browser automation in depth, see our Puppeteer proxies guide.

Key takeaways

  • Browsers driven by Selenium can't accept proxy credentials on the command line.
  • IP authorization is the simplest fix; Selenium Wire or a local forwarder handle credentials otherwise.
  • Allowlisting removes username options, so use a forwarder for rotating residential sessions.
  • Start a new driver to change IP.
  • Use fixed-IP servers with authorized IPs for CI and Selenium Grid.

FAQ

Can I use Webshare with Selenium without IP authorization?

Yes, through Selenium Wire or a local forwarding proxy that adds credentials.

Does Selenium support SOCKS5 with Webshare?

Browsers support SOCKS5 proxies, but not SOCKS5 authentication. Use IP authorization if you want SOCKS5.

Is Selenium the best tool for proxy-based scraping?

For heavy scraping, Playwright or plain HTTP clients are usually faster. See Webshare with Playwright.

Why does Chrome show a login popup with my proxy?

Chrome received a proxy that needs credentials but wasn't given them. Use IP authorization, Selenium Wire or a local forwarder.

Can I rotate proxies in a single Selenium session?

Not reliably. Start a new driver for a new IP.

Does Selenium Wire work with Firefox?

Yes, it supports Chrome and Firefox drivers, though it's no longer actively maintained.

Affiliate disclosure: Team of Monkeys is an affiliate of Geonode and Webshare. Links and banners marked as sponsored, and links to Geonode and Webshare in the text, use our referral links, and we may earn a commission if you buy through them, at no extra cost to you. Our explanations and comparisons are written to be useful whichever provider you choose.

Editorial note: Proxy providers change their pools, features and prices often, so treat any figures here as typical ranges at the time of writing and confirm current terms with the provider before you buy.