Failing to set up proxy for chrome in Selenium (Python 3.7)


When running the following program, the following error pops up:

selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: cannot parse capability: proxy from invalid argument: unrecognized proxy type: unspecified

I can't figure out what I'm doing wrong. I think it has something to do with setting up the chrome webdriver but I have no idea how to correctly do this as the internet gives me a lot of different answers.

from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy, ProxyType
import random
from string import ascii_lowercase

PATH = r"C:\Users\...\PythonProject\chromedriver.exe"

def proxy_update():
    global driver
    proxies = []
    proxy_search = driver.find_element_by_xpath("""//*[@id="proxylisttable"]/tbody""").text.split('ago\n')
    for pr in proxy_search:
        proxies.append(pr.split(' '))
    for lst in proxies:
        for pr in lst:
            if pr == "elite":
                proxies.append(lst[0] + ':' + lst[1])
    if len(proxies) > 20:
        return random.sample(proxies, k=1)

capabilities = webdriver.DesiredCapabilities.CHROME.copy()
prox = Proxy()
prox.proxy_type = ProxyType.MANUAL
driver = webdriver.Chrome(PATH, desired_capabilities=capabilities)
chrome_options = webdriver.ChromeOptions()
driver = webdriver.Chrome(PATH, desired_capabilities=capabilities, options=chrome_options)
prox.http_proxy = f"{proxy_update()}"
prox.socks_proxy = f"{proxy_update()}"
prox.ssl_proxy = f"{proxy_update()}"



This is the full error:

Traceback (most recent call last):
  File "C:/Users/.../", line 36, in <module>
    driver = webdriver.Chrome(PATH, desired_capabilities=capabilities)
  File "C:\Users\...\venv\lib\site-packages\selenium\webdriver\chrome\", line 81, in __init__
  File "C:\Users\...\venv\lib\site-packages\selenium\webdriver\remote\", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\...\venv\lib\site-packages\selenium\webdriver\remote\", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\...\venv\lib\site-packages\selenium\webdriver\remote\", line 321, in execute
  File "C:\Users\...\venv\lib\site-packages\selenium\webdriver\remote\", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: cannot parse capability: proxy
from invalid argument: unrecognized proxy type: unspecified

Below is the correct way to add proxy in chrome ,


ChromeOptions chromeOptions = new ChromeOptions();
String proxyadd = "";
Proxy proxy = new Proxy();
chromeOptions.setCapability("proxy", proxy);
WebDriver driver  = new ChromeDriver(chromeOptions);


from selenium import webdriver

webdriver.DesiredCapabilities.CHROME['proxy'] = {
    "httpProxy": PROXY,
    "ftpProxy": PROXY,
    "sslProxy": PROXY,
    "proxyType": "MANUAL",



driver =webdriver.Chrome(r".\chromedriver.exe")


It seems that chrome is not able to connect to proxy may be it is using system proxy. Try above mentioned approach to set proxy

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at


Login to comment


How to set proxy for Chrome browser in selenium using Java code

Set proxy server with selenium and Chrome

Set up Python 3 build system with Sublime Text 3

How to set Proxy setting for Chrome in Selenium Java

Selenium opens up chrome not signed into Chrome account

Set up tests with PHPUnit and Selenium

Set up a proxy with python requests

set proxy address with selenium chrome

Disable proxy via Python for Selenium with headless Chrome

how to set proxy in python 3.x httplib2?

How do you run headless chrome and a proxy using selenium in python?

how to set proxy with authentication in selenium chromedriver python?

Can not set Luminati proxy on Selenium in Python 3

How to set up a python application with selenium in a docker container

Set up proxy on selenium geckodriver

How to set proxy AUTHENTICATION username:password using Python/Selenium

How to set preferences for Chrome in Selenium Python

selenium & chrome 78 failing basic authentication

Python: Selenium webdriver Chrome opens up browser but not the site selected

How can I set up the python environment variable on Windows 7?

Python selenium use the same window instead of having 3 pop up?

How to set proxy while using urllib3.PoolManager in python

How to set up a Selenium Python environment for Firefox

Python selenium PhantomJS proxy

pod set up is failing Mac OS Sierra

Multiprocessing selenium in Python 3 using Chrome issues

Set up proxy for selenide?

Python script that uses Selenium webdriver for Chrome, trying (and failing) to print elements contained in a listbox

Python requests with proxy failing for WinError 10060