Setting Http Proxy when using the selenium-webdriver gem and Firefox
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 = WebDriver::Firefox::Profile.new profile["network.proxy.type"] = 1 profile["network.proxy.http"] = "www-cache.at.my.work.co.uk" profile["network.proxy.http_port"] = 80 driver = WebDriver.for(:firefox, :profile => profile) driver.navigate.to "http://google.com"
= 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.