Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mozilla ignores proxy configuration #9479

Closed
AlfGod opened this issue May 14, 2021 · 8 comments
Closed

Mozilla ignores proxy configuration #9479

AlfGod opened this issue May 14, 2021 · 8 comments

Comments

@AlfGod
Copy link

AlfGod commented May 14, 2021

🐛 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):

@ghost ghost added the needs-triaging label May 14, 2021
@AlfGod
Copy link
Author

AlfGod commented May 16, 2021

Here I attache a file with the python code:

test.py.txt

@AutomatedTester
Copy link
Member

I think this has been fixed with the latest code. Please can you retry with the selenium 4 beta release. You can install it with pip install selenium --pre

@AlfGod
Copy link
Author

AlfGod commented May 20, 2021

Thanks Automated Tester for your help.
Gonna try it! and I'll tell you the result

@whimboo
Copy link
Contributor

whimboo commented May 21, 2021

FYI it would be best if you wouldn't create a new Firefox profile via Selenium but pass the preferences and the proxy settings via capabilities:

https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities

Sadly proxy capabilities aren't documented there yet, but will match those as listed in the WebDriver spec.

@AutomatedTester
Copy link
Member

@AlfGod Were you able to test this and is it working now? If we don't get a reply in the next week we will likely close the issue

@AlfGod
Copy link
Author

AlfGod commented Jun 11, 2021 via email

@AutomatedTester
Copy link
Member

Closing this as I believe it is fixed. Please raise a new bug if this is not the case

@github-actions
Copy link

github-actions bot commented Sep 5, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants