Setting Http Proxy when using the selenium-webdriver gem and Firefox

July 14, 2010

I've been using the selenium-webdriver ruby gem to do some automated Cucumber testing of our application. Sadly, I'm sat behind a firewall which requires an HTTP proxy to access the outside world. Using the Chrome WebDriver bridge worked fine as it inherits the system preferences on OS X. However with Firefox I had to perform some trickery to get it to work:

require 'rubygems'
require 'selenium-webdriver'

include Selenium

profile =
profile["network.proxy.type"] = 1
profile["network.proxy.http"] = ""
profile["network.proxy.http_port"] = 80

driver = WebDriver.for(:firefox, :profile => profile) ""

The []= method on Profile is setting the options that you find by typing 'about:config' in the Firefox URL bar. Take a look there in a working Firefox profile to see what variables you should set for your webdriver-specific profile in the code above.


blog comments powered by Disqus