The Selenium proxy challenge
Selenium drives real browsers, which is great for realism and testing. Its one awkward area is authenticated proxies. Chrome's --proxy-server flag doesn't accept a username and password, and browsers show a native login dialog for proxy authentication that classic Selenium can't fill in. There are three reliable ways around it with Geonode:
- IP whitelisting: authorise your machine's IP in the Geonode dashboard, so no credentials are needed.
- A local forwarding proxy: a small proxy on your machine adds credentials and forwards to Geonode.
- Browser-specific mechanisms: such as newer Selenium network features or extensions, which vary by version.
For most teams, whitelisting (on servers with fixed IPs) or a local forwarder (everywhere else) is the most dependable. See proxy authentication methods.
Option 1: IP whitelisting with Chrome
If your server has a fixed public IP, add it to Geonode's whitelist, then pass only the host and port:
import os
from selenium import webdriver
opts = webdriver.ChromeOptions()
opts.add_argument(f"--proxy-server=http://{os.environ['GEONODE_HOST']}:{os.environ['GEONODE_PORT']}")
opts.add_argument("--force-webrtc-ip-handling-policy=disable_non_proxied_udp")
driver = webdriver.Chrome(options=opts)
driver.get("https://api.ipify.org")
print(driver.find_element("tag name", "body").text)
driver.quit()With whitelisting, location targeting is usually chosen in the dashboard or by port rather than in the username. Check the options your dashboard offers for whitelisted access.
Option 2: a local forwarding proxy
Run a tiny forwarder that listens locally without authentication and forwards to Geonode with your credentials. Tools such as proxy-chain (Node.js) or a minimal configuration of a local proxy server do this. Then point Selenium at the local address:
opts.add_argument("--proxy-server=http://127.0.0.1:8000")The forwarder holds the Geonode username (including any targeting suffix, such as -country-us in the pattern Geonode documents) and password. Run one forwarder per identity if you need different locations or sessions in parallel.
Firefox
Firefox reads proxy settings from preferences:
from selenium import webdriver
opts = webdriver.FirefoxOptions()
host, port = os.environ["GEONODE_HOST"], int(os.environ["GEONODE_PORT"])
opts.set_preference("network.proxy.type", 1)
opts.set_preference("network.proxy.http", host)
opts.set_preference("network.proxy.http_port", port)
opts.set_preference("network.proxy.ssl", host)
opts.set_preference("network.proxy.ssl_port", port)
opts.set_preference("media.peerconnection.enabled", False) # disable WebRTC
driver = webdriver.Firefox(options=opts)Authentication still needs whitelisting or a forwarder in most setups.
Newer Selenium features
Recent Selenium releases have added WebDriver BiDi support, including network features that can respond to authentication challenges in some browsers and language bindings. If you're on a recent version, check the official documentation for your language; it may let you authenticate without a forwarder. Pin your Selenium version and re-test proxy authentication after upgrades.
Proxy tip: Before scaling, run a short pilot on your real targets with Geonode and record success rate, latency and GB per result. Our our complete Geonode guide explains which Geonode product to start with.
Sessions and location
- Rotating: start a new driver (or a new forwarder session) per job for a fresh exit.
- Sticky: use a sticky endpoint in the forwarder for flows that need one IP.
- Match the browser to the exit: set language with
--lang(Chrome) orintl.accept_languages(Firefox), and timezone through the environment or browser options where supported.
Testing
After setup, load an IP check page and confirm the IP and country, then a WebRTC leak test. Keep that check as the first step of every test run.
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
| Proxy login dialog appears | Authenticated proxy without whitelisting or forwarder | Whitelist your IP or use a forwarder |
| Exit shows your server's IP | Proxy flag missing or bypassed | Check options; confirm on an IP page |
| 407 from forwarder | Wrong credentials in forwarder config | Copy from Geonode dashboard |
| Real IP visible in WebRTC test | WebRTC not restricted | Add the WebRTC flag or preference |
Selenium in testing pipelines with Geonode
Selenium is most often used for testing, and proxies make geo-testing possible. A practical pipeline:
- One forwarder per market, each configured with a Geonode username targeted to that country, listening on its own local port.
- A test matrix that maps each market to its forwarder port, locale and expected content (currency, language, legal text).
- A smoke step that opens an IP check page through each forwarder and asserts the expected country before any tests run.
- Screenshots on failure, named by market, attached to the test report.
- Credentials in CI secrets, injected into the forwarders at startup, never committed.
If you use Selenium Grid, run forwarders alongside the nodes and pass the right local address in each session's capabilities. Keep the forwarders' credentials and targeting in one configuration file so adding a market is a one-line change.
When to consider alternatives
Selenium remains a solid choice when you need its language bindings, its browser coverage or an existing test suite. If authenticated per-context proxies are central to your work and you're starting fresh, Playwright's built-in proxy credentials remove the need for forwarders. If you only need page content rather than browser behaviour, an HTTP client or the Geonode Scraper API is simpler and cheaper. For geo QA practice in general, see Geonode for localization testing.
Starting small
Begin with one market and one forwarder, prove the smoke test and a single geo check in CI, then add markets one at a time.
FAQ
Can I put Geonode credentials in Chrome's proxy flag?
No. Chrome ignores credentials there. Use whitelisting or a local forwarder.
Is Selenium Wire still a good option?
It was popular for authenticated proxies but is no longer actively maintained. Prefer whitelisting, a forwarder, or newer built-in features.
How do I use different countries in parallel?
Run one forwarder per country (or session), each with its own targeted Geonode username, and point each driver at its forwarder.
Should I switch to Playwright?
If authenticated proxies per context matter a lot, Playwright handles them natively. See Geonode with Playwright.
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.