Selenium Proxy Configuration: Python Tutorial
How to configure proxies in Selenium WebDriver for browser automation.
NobleProxy Team
Proxy Experts
Selenium Proxy Setup
Configure proxies in Selenium for automated browser testing and scraping.
TL;DR: Use Chrome Options to set proxy settings, then pass to WebDriver. For authenticated proxies, use extensions or wire protocol.
Basic Chrome Setup
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
proxy = "proxy.nobleproxy.com:8080"
chrome_options = Options()
chrome_options.add_argument(f'--proxy-server=http://{proxy}')
driver = webdriver.Chrome(options=chrome_options)
driver.get('https://httpbin.org/ip')
With Authentication (selenium-wire)
pip install selenium-wire
from seleniumwire import webdriver
proxy_options = {
'proxy': {
'http': 'http://username:password@proxy.nobleproxy.com:8080',
'https': 'http://username:password@proxy.nobleproxy.com:8080'
}
}
driver = webdriver.Chrome(seleniumwire_options=proxy_options)
driver.get('https://httpbin.org/ip')
Firefox Setup
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", "proxy.nobleproxy.com")
profile.set_preference("network.proxy.http_port", 8080)
profile.set_preference("network.proxy.ssl", "proxy.nobleproxy.com")
profile.set_preference("network.proxy.ssl_port", 8080)
driver = webdriver.Firefox(firefox_profile=profile)
Best Practices
- Handle proxy errors gracefully
- Implement retry logic
- Close drivers properly
- Use headless mode when appropriate
Written by NobleProxy Team
Proxy Experts
The NobleProxy team helps businesses scale their cold outreach with reliable static residential proxies. We share our expertise to help you succeed.