0

With python-selenium I am running the following short python snippet:

from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.http", "localhost")
profile.set_preference("network.proxy.http_port", "9998")
browser = webdriver.Firefox(firefox_profile = profile)
browser.get("http://www.google.co.uk")

in which I define a proxy running at the localhost at port 9998. The test finishes fine, i.e. the google webpage is being shown.

However, there is no proxy running at port 9998. I was expecting an error.

Question: Why do I not get an error?

Alex
  • 41,580
  • 88
  • 260
  • 469
  • possible duplicate of [Proxy Selenium Python Firefox](https://stackoverflow.com/questions/18719980/proxy-selenium-python-firefox) – Murthi Jan 18 '18 at 09:04

1 Answers1

0

The code example is incorrect. With the following code example it works just fine, and when specifying a wrong port you will get an error immediately:

from selenium import webdriver
PROXY = "0.0.0.0:9999"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
    "httpProxy":PROXY,
    "ftpProxy":PROXY,
    "sslProxy":PROXY,
    "proxyType":"MANUAL"
}
driver = webdriver.Firefox()
driver.get("http://www.google.co.in")
Alex
  • 41,580
  • 88
  • 260
  • 469