Watir with webdriver, proxy, Firefox

前端 未结 3 851
小鲜肉
小鲜肉 2021-01-17 01:15

I am able to use watir-webdriver with IE, but I would prefer to use Firefox. Problem: I need a proxy. By googling around, I found some code snippets, but I am not able to pu

3条回答
  •  遥遥无期
    2021-01-17 01:59

    Call the underlying Selenium WebDriver.

    I've used this technique to set a path to Firefox 3.6 so I can test with both Firefox 4 and 3.6:

    Selenium::WebDriver::Firefox.path = ENV['FIREWATIRPATH']
    browser = Watir::Browser.new :firefox
    

    So to do what you're trying to do:

    profile = Selenium::WebDriver::Firefox::Profile.new
    proxy = Selenium::WebDriver::Proxy.new(:http => "http://proxy.org:8080")
    profile.proxy = proxy
    
    # You have to do a little more to use the specific profile
    driver = Selenium::WebDriver.for :firefox, :profile => profile
    browser = Watir::Browser.new(driver)
    

    Look at: Selenium Ruby Bindings and Webdriver FAQ for more info.


    What problem are you having with the Proxy line?

    You could try this:

    profile = Selenium::WebDriver::Firefox::Profile.new
    profile["network.proxy.type"] = 1
    profile["network.proxy.http"] = "proxy.myplace.com"
    profile["network.proxy.http_port"] = 8080
    

    The idea is to see what your settings are in about:config and duplicating them in code.

提交回复
热议问题