'Selenium Webdriver Firefox (Geckodriver) does not accept proxy options
Very odd behavior from Firefox (geckodriver) with Selenium webdriver. Given the exact same parameters as Chrome (chromedriver) with Selenium, geckodriver seems to ignore proxy settings and connect directly to the Internet. Any reason why geckodriver operates this way or how to work around it?
def selenium_chrome_full(proxy, url)
options = Selenium::WebDriver::Chrome::Options.new(args: ["start-maximized", "--proxy-server=%s" % proxy])
driver = Selenium::WebDriver.for(:chrome, capabilities: options)
driver.get(url)
end
def selenium_firefox_full(proxy, url)
options = Selenium::WebDriver::Firefox::Options.new(args: ["start-maximized", "--proxy-server=%s" % proxy])
driver = Selenium::WebDriver.for(:firefox, capabilities: options)
driver.get(url)
end
proxy = "0.0.0.0:8080"
url = "https://www.google.com/search?client=firefox-b-1-d&q=whatsmyip"
selenium_firefox_full(proxy, url)
selenium_chrome_full(proxy, url)
For a bit of additional context, I also ran a debugger to see the value of options after initialization they are as follows for Firefox and Chrome respectively:
#<Selenium::WebDriver::Firefox::Options:0x000000010814b390 @debugger_address=nil, @options={:args=>["start-maximized", "--proxy-server=0.0.0.0:8080"], :browser_name=>"firefox", :prefs=>{}}, @profile=nil>
#<Selenium::WebDriver::Chrome::Options:0x0000000102362150 @options={:args=>["start-maximized", "--proxy-server=0.0.0.0:8080"], :prefs=>{}, :emulation=>{}, :local_state=>{}, :exclude_switches=>[], :perf_logging_prefs=>{}, :window_types=>[], :browser_name=>"chrome"}, @profile=nil, @logging_prefs={}, @encoded_extensions=[], @extensions=[]>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
