Selenium with Proxy in Firefox 67+

Viewed 48

I have tried several variations of setups both with firefox profile settings, and the current method seen below, and yet Seleniun continues to ignore the proxy settings and connect direct. I can't seem to find any instructions or tutorials anywhere that actually work in the latest firefox. What's wrong with my code?

        logger.info("Using Proxy Options")
        # Selenium Firefox Profile Path
        profile_path = ffprofile_path
        extension_dir = os.path.join(ffprofile_path, "extensions")
        profile = webdriver.FirefoxProfile(profile_path)
        user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0"
        http_proxy = "my_proxy_ip:1027"
        # # Direct = 0, Manual = 1, PAC = 2, AUTODETECT = 4, SYSTEM = 5
        # profile.set_preference("network.proxy.type", 0)
        # profile.set_preference("network.proxy.http", proxy_ip)
        # profile.set_preference("network.proxy.http_port", int(proxy_port))
        # profile.set_preference("general.useragent.override", user_agent)
        # profile.update_preferences()
        proxy = Proxy({
            'proxyType': ProxyType.MANUAL,
            'httpProxy': http_proxy,
            'ftpProxy': http_proxy,
            'sslProxy': http_proxy,
            'noProxy': ''  # set this value as desired
        })
        ##########################################################
        ##########################################
        cap["firefox_profile"] = profile.encoded
        driver = webdriver.Firefox(
            firefox_profile=profile,
            capabilities=cap,
            options=opts,
            executable_path=gecko_path,
            proxy=proxy
        )
    # Test to see if Proxy is Working
    logger.info("Testing Proxy")
    driver.get("https://www.actual_url_redacted_")
    show_ip = driver.page_source
    logger.info('IP Shown: ' + str(show_ip))
0 Answers
Related