Telling Watir-Webdriver to use a http and ssl proxy

I’ve been trying to get Watir-WebDriver to use a proxy for both http and https sites, but was having a bit of trouble.
There are a couple of key pointers: you need to specify the proxy address without the ‘http://’ prefix (or it’ll crash), and you need to also specify a :ssl parameter to Firefox profile.

Example: setting a http and https proxy for Firefox

profile =
profile.proxy = :http => '', :ssl => ''
browser = :chrome, :profile => profile

Example: setting a http and https proxy for Chrome

switches = ''
browser = :chrome, :switches => switches

Author: Alister Scott

Alister is an Excellence Wrangler for Automattic.

5 thoughts on “Telling Watir-Webdriver to use a http and ssl proxy”

  1. hello, I tried your sample, but it doesn’t work…

    I tried it :

    require ‘watir-webdriver’

    profile =
    profile.proxy = :http => ‘’, :ssl => ‘’
    browser = WEB_DRIVER, :profile => profile

    but my command prompt says “uninitialized constant WEB_DRIVER (NameError)”
    could help me please? what is the matter,


  2. I tried what you said but it puts :

    C:/Ruby191/lib/ruby/gems/1.9.1/gems/childprocess-0.2.1/lib/childprocess.rb:91:in `close_on_exec=’: close_on_exec=() function is unimplemented on this machine (NotImplementedError)
    from C:/Ruby191/lib/ruby/gems/1.9.1/gems/childprocess-0.2.1/lib/childprocess.rb:91:in `close_on_exec’
    from C:/Ruby191/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.4.0/lib/selenium/webdriver/firefox/socket_lock.rb:46:in `can_lock?’
    from C:/Ruby191/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.4.0/lib/selenium/webdriver/firefox/socket_lock.rb:31:in `lock’
    from C:/Ruby191/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.4.0/lib/selenium/webdriver/firefox/socket_lock.rb:17:in `locked’
    from C:/Ruby191/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.4.0/lib/selenium/webdriver/firefox/launcher.rb:32:in `launch’
    from C:/Ruby191/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.4.0/lib/selenium/webdriver/firefox/bridge.rb:19:in `initialize’
    from C:/Ruby191/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.4.0/lib/selenium/webdriver/common/driver.rb:27:in `new’
    from C:/Ruby191/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.4.0/lib/selenium/webdriver/common/driver.rb:27:in `for’
    from C:/Ruby191/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.4.0/lib/selenium/webdriver.rb:74:in `for’
    from C:/Ruby191/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.2.2/lib/watir-webdriver/browser.rb:35:in `initialize’
    from test.rb:4:in `new’
    from test.rb:4:in `’

    is it worst??


Comments are closed.