Reputation: 1402
I am trying to add proxies in Firefox driver (which do have authentication). Though I set the proxy by the below code, it is not clear to add authentication for the proxies.
myProxy = "xxx.xxx.xxx.xxx:80"
proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': myProxy,
'ftpProxy': myProxy,
'sslProxy': myProxy,
'noProxy': ''
})
driver = webdriver.Firefox(proxy=proxy)
I have gone through this answer for authentication but it is also not working.
Any help will be appreciated.
Thanks in advance
Upvotes: 2
Views: 2188
Reputation: 173
Here is what I was (finally) able to get to work. I wasn't able to change the port - I didn't see anything to do that in the proxy.py file either, but I will admit I didn't look too hard since my proxies are on port 80 anyway.
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.proxy import Proxy
proxy_use= "xxx.xxx.xxx.xxx"
desired_capability = webdriver.DesiredCapabilities.FIREFOX
desired_capability['proxy'] = {
'proxyType': "manual",
'httpProxy': proxy_use,
'ftpProxy': proxy_use,
'sslProxy': proxy_use,
}
queryURL = "https://insert.yourwebsitetocheckip.here"
browser = webdriver.Firefox(capabilities=desired_capability)
browser.get(queryURL)
I have my function doing a lot more than this, so I just pulled out the relevant part. Looking at this quickly you might not have to import Options - try it without and see if it works.
Upvotes: 1