I am using Firefox WebDriver in Python 2.7 with Selenium. My python program starts Firefox browser and visits different websites when I run the program. But, I need to set the proxy with authentication, so that when program visits any website, it will visit through the proxy server.
There are some similar questions on SO. But, there is no specific solution for Selenium Firefox WebDriver of Python.
Dup of: How to set proxy AUTHENTICATION username:password using Python/Selenium
Selenium-wire: https://github.com/wkeeling/selenium-wire
Install selenium-wire
Import it
Auth to proxy
Warning
Take a look to the selenium-wire cache folder. I had a problem because it take all my disk space. You have to remove it sometimes in your script when you want.
In addition to running Firefox with a profile which has the credentials saved. You can do it loading an extension that writes in the
loginTextbox
andpassword1Textbox
ofchrome://global/content/commonDialog.xul
(the alert window).There are already some extensions that will do the job. For instance:
Close Proxy Authentication
https://addons.mozilla.org/firefox/downloads/latest/close-proxy-authentication/addon-427702-latest.xpi
In an addition to the answer with extension.
You can also use form filling to dynamically change credentials on your proxy. Just load the extension page, fill the form automatically and click save!
There is an example for Firefox + Python but without the authentication here. Then you can find other available parameters here in source code. So it looks like you need the following:
For example:
or with preferences:
EDIT:
I looked at it again and it seems that it is impossible to set authentication details in FF, even manually. The only way is just to remember the details that you have already entered which done by 2 parameters:
that can be configured with the
set_preference()
method. You can also manually view all FF options by browsing toabout:config
.