-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Description
🐛 Bug Report
Hello Everyone,
Apologies for my english if I wrote something wrong.
My problem is that Firefox webdriver is ignoring proxy settings. So, if I open a Firefox webdriver with proxy the opened Firefox ignores the proxy settings and tries to go directly to the web page.
What's weird is that if after Firefox opens, I manualy go to Netwerk Preferences, the proxy settings are Ok. Proxy ip ok, proxy port ok, everything seems ok...
... what's MORE WEIRD is this >>> if I select Ok in order to leave "Network Preferences", now Firefox starts to use the proxy settings correctly!. This is a sort of walkaround, but its not working for me because it is a manual procedure.
The problem is that I'm need to implement an atomated script that configures proxy, opens Firefox, loads a page, performs some tasks and leave... all 100% automatic. But with this kind of bug the opened Firefox can't go trhoug the proxy, so the page never loads.
Tryed several methods:
Using desiredcapabilities parameter with proxy settings loaded on the desiredcapabilities object
Using "firefox_profile method", does not solved the issue either
profileWebdriver.set_preference("network.proxy.type", 1) # Direct = 0, Manual = 1, PAC = 2, AUTODETECT = 4, SYSTEM = 5
profileWebdriver.set_preference("network.proxy.http", 127.0.0.1)
profileWebdriver.set_preference("network.proxy.http_port", 8080)
profileWebdriver.set_preference("network.proxy.share_proxy_settings", True)
Tried "proxy parameter method", does not solved the issue either. Yes I know it's deprecated but I'm a desperate man and tried it annyway :D
Could not find in the WEB how to set proxy values on options object
Thanks in advance!
To Reproduce
Detailed steps to reproduce the behavior:
Create a webdriver object using proxy configurations
Get a webpage and check that the web page is loaded via the specified proxy
Expected behavior
Must open web pages using the proxy configuration. If proxy is down must fail, if proxy is up must use it.
The problem is that the proxy is not used.
Test script or set of commands reproducing this issue
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")
Environment
OS:
Browser:
Browser version:
Browser Driver version:
Language Bindings version:
Selenium Grid version (if applicable):