Selenium – Set http proxy to the webdriver


I’ve been trying to use a http proxy with Selenium.
What I have so far is:

PROXY = ""
webdriver.DesiredCapabilities.CHROME['proxy'] = {
    "httpProxy": PROXY,
    "ftpProxy": PROXY,
    "sslProxy": PROXY,
    "noProxy": None,
    "proxyType": "MANUAL",
    "class": "org.openqa.selenium.Proxy",
    "autodetect": False

However, it simply doesn’t work and throws:

selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_TUNNEL_CONNECTION_FAILED


Personally, I use a library called selenium-wire which can be used for both authenticated and non-authenticated proxies. Here is the documentation reference for proxy use

I have made a short snippet of code that uses a public proxy to go to

import seleniumwire
from seleniumwire import webdriver

options = {'proxy': 
    'http' : ''}

driver = webdriver.Chrome(seleniumwire_options=options)


Here is also a method that would work without the need for selenium-wire.

options = webdriver.ChromeOptions()

driver = webdriver.Chrome(options=options)


Answered By – Akdeniz

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published