Selenium Grid enables distributed browser testing across multiple machines and browsers. Integrate KnoxProxy at the Grid node or driver level to run parallel geo-distributed test suites, validate region-locked features, and test localization across dozens of countries simultaneously.
Launch the Grid hub that coordinates test distribution.
java -jar selenium-server-4.x.jar hubCreate a node configuration file that sets the proxy for browsers.
# node-proxy.toml
[node]
max-sessions = 4
[node:env]
HTTP_PROXY = "http://USER:PASS@gw.knoxproxy.com:7000"
HTTPS_PROXY = "http://USER:PASS@gw.knoxproxy.com:7000"Launch the Grid node using the proxy-configured TOML file.
java -jar selenium-server-4.x.jar node \
--config node-proxy.toml \
--hub http://localhost:4444Connect to the Grid and set proxy capabilities on the driver.
from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy, ProxyType
proxy = Proxy()
proxy.proxy_type = ProxyType.MANUAL
proxy.http_proxy = "gw.knoxproxy.com:7000"
proxy.ssl_proxy = "gw.knoxproxy.com:7000"
options = webdriver.ChromeOptions()
options.proxy = proxy
driver = webdriver.Remote(
command_executor="http://localhost:4444",
options=options,
)Use Chrome arguments or environment variables for country-specific proxy routing.
options = webdriver.ChromeOptions()
options.add_argument("--proxy-server=http://gw.knoxproxy.com:7000")
# Set env: HTTP_PROXY=http://USER-country-kr:PASS@gw.knoxproxy.com:7000Run Selenium Grid in Docker with proxy environment variables injected.
# docker-compose.yml snippet
services:
chrome:
image: selenium/node-chrome:4
environment:
- SE_EVENT_BUS_HOST=hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- HTTP_PROXY=http://USER:PASS@gw.knoxproxy.com:7000
- HTTPS_PROXY=http://USER:PASS@gw.knoxproxy.com:7000from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium.webdriver.common.by import By
import os
# Set proxy auth via environment
os.environ["HTTP_PROXY"] = "http://USER:PASS@gw.knoxproxy.com:7000"
os.environ["HTTPS_PROXY"] = "http://USER:PASS@gw.knoxproxy.com:7000"
# Configure proxy capabilities
proxy = Proxy()
proxy.proxy_type = ProxyType.MANUAL
proxy.http_proxy = "gw.knoxproxy.com:7000"
proxy.ssl_proxy = "gw.knoxproxy.com:7000"
options = webdriver.ChromeOptions()
options.proxy = proxy
# Connect to Selenium Grid
driver = webdriver.Remote(
command_executor="http://localhost:4444",
options=options,
)
try:
driver.get("https://httpbin.org/ip")
body = driver.find_element(By.TAG_NAME, "pre")
print(f"Exit IP: {body.text}")
driver.get("https://example.com")
assert driver.title != ""
print(f"Page title: {driver.title}")
finally:
driver.quit()Each Grid session creates a new browser and proxy connection. For country-specific nodes, run multiple Grid nodes with different HTTP_PROXY usernames (USER-country-us, USER-country-de). Use USER-session-{id} for sticky IPs within a session.
| Problem | Fix |
|---|---|
| SessionNotCreatedException: Could not start a new session | Verify HTTP_PROXY env var is set on the Grid node. Test with curl from the node machine. |
| WebDriverException: unknown error: net::ERR_PROXY_CONNECTION_FAILED | Check proxy format in capabilities. For Chrome, use --proxy-server arg. For Firefox, use the proxy capability object. |
| Timeout waiting for Grid node | Check Grid hub logs. Ensure node TOML config is valid. Reduce max-sessions if proxy bandwidth is limited. |
USER-country-de-city-berlin-session-profile07Order matters -- geo flags before the session flag. The session name is free text; use the profile ID so the mapping is self-documenting. Password stays as issued; no flags belong there. HTTP on :7000, SOCKS5 on :7001, same credentials.
Configure the proxy at the Grid node level, using environment variables or a node-proxy.toml file, when you want one uniform KnoxProxy connection shared across every session that node runs. Use driver-level proxy capabilities instead, set on the RemoteWebDriver options, when different tests running on the same node each need their own country targeting.
Yes, deploy multiple Grid nodes, each configured with a different HTTP_PROXY country username such as USER-country-us or USER-country-de in its node-proxy.toml file, so nodes run simultaneously from different exit locations. Use Grid node labels to route specific tests to the country node that matches the region under test.
Yes, inject HTTP_PROXY and HTTPS_PROXY as environment variables directly in the docker-compose.yml service definition for the selenium/node-chrome image, or in the equivalent Kubernetes pod spec. Every browser session that container launches then inherits the proxy configuration automatically, without changing the test code that talks to the Grid hub.
Set your KnoxProxy credentials directly in the HTTP_PROXY environment variable on the Grid node, in the format http://USER:PASS@gw.knoxproxy.com:7000. Browser-level proxy capabilities like the ChromeOptions proxy object do not support authentication directly, so node-level environment variables remain the only reliable way to authenticate proxied traffic on the Grid.
Rotating residential proxies -- 10 minutes setup, instant activation, 14-day money-back guarantee.