from selenium import webdriver from selenium.webdriver.firefox.options import Options from selenium.webdriver.common.proxy import Proxy, ProxyType if name == 'main': opts = Options() opts.headless = False # ----- desired_capability method desired_capability = webdriver.DesiredCapabilities.FIREFOX prox = Proxy() prox.proxy_type = ProxyType.MANUAL prox.http_proxy = "127.0.0.1:8080" prox.add_to_capabilities(desired_capability) # ----- profile method profile = webdriver.FirefoxProfile() profile.set_preference("dom.disable_beforeunload", True) profile.set_preference("browser.tabs.warnOnClose", False) PrivateMode = False profile.set_preference("browser.privatebrowsing.autostart", PrivateMode) profile.set_preference("browser.privatebrowsing.autostart", PrivateMode) profile.set_preference("network.proxy.type", 1) # Direct = 0, Manual = 1, PAC = 2, AUTODETECT = 4, SYSTEM = 5 profile.set_preference("network.proxy.http", "127.0.0.1") profile.set_preference("network.proxy.http_port", 2020) profile.set_preference("network.proxy.share_proxy_settings", True) profile.update_preferences() # None of the following procedures works #1 Using firefox_profile BrowserManager = webdriver.Firefox(options=opts, firefox_profile=profile) #2 desired_capabilities #BrowserManager = webdriver.Firefox(options=opts, firefox_profile=profile, # desired_capabilities=desired_capability) #3 proxy # BrowserManager = webdriver.Firefox(options=opts, # firefox_profile=profile, # proxy=prox) BrowserManager.get("https://whatismyipaddress.com/") print("The End")