Context: I am using Python, selenium + Geckodriver. Firefox webbrowser automation and I have problem on a private proxy authentification. I cannot manage to configure my socks5 proxy username and password. Thus, Firefox shows up but connection doesnt work.
The simple task that I want to do is :
- I want to use selenium(automated Firefox) with a proxy (SOCKS5 proxy with password)
 - Checking my IP on a website to see if the proxy is working
 
What I noted so far is:
- I am using Firefox V76.0.1 , Geckodriver and Python3
 - The User / Password box that should normally pop up when u choose doesn't pop up, this could be a problem with regards to the Firefox version and it could be fixed by overriding some settings in : about:setings. A solution could be to make this popup work and write some User password auth - see login function below. Honestly , it is unstable I prefer to find a solution that can work without this popup.
 - The only stable way to manage socks5 proxies (regardless of the popup authentification) is using an AddOn called FoxyProxy.
 - I cannot change this (Foxy Proxy AddOn) and all I can change in python with regards to Firefox are the settings that you can acess in Firefox using the URL (about:config)
 - Simple non password protected proxies are not a problem but SOCKS5 proxies with username and pasword are a problem
 - Also: wondering if it is possible to override Foxy Proxy AddOn and add options that can be accessible in Firefox (about:config) ( Honestly I am not a Firefox plugin developper so maybe it is possible!? )
 
So the current code is, replace HOST/USERNAME/PORT/PASSWORD with socks5 proxy data :
    from selenium import webdriver
    from base64 import b64encode
    from selenium import webdriver
    def login(browser):
        alert=browser.switch_to_alert()
        alert.send_keys("username"+webdriver.common.keys.Keys.TAB+"password")
        alert.accept()
    proxy = {'host': HOST, 'port': PORT, 'usr': USERNAME, 'pwd': PASSWORD}
    fp = webdriver.FirefoxProfile()
    fp.set_preference('network.proxy.type', 1)
    fp.set_preference('network.proxy.http', proxy['host'])
    fp.set_preference('network.proxy.http_port', int(proxy['port']))
    fp.set_preference('network.proxy.no_proxies_on', 'localhost, 127.0.0.1')
    fp.set_preference("network.proxy.socks_version", 5)
    credentials = '{usr}:{pwd}'.format(**proxy)
    fp.set_preference("network.proxy.type", 1)
    fp.set_preference("network.proxy.socks_version", 5)
    fp.set_preference("network.proxy.socks", HOST)
    fp.set_preference("network.proxy.socks_port", PORT)
    fp.set_preference("network.http.use-cache", False)
    driver = webdriver.Firefox(fp)
    # normally a proxy login popup should appear and we should call the login function here!!
    driver.get('https://wtfismyip.com')
Doesnt work, Any Ideas ?