2011-03-10 28 views
3

Capybara的API似乎不支持配置HTTP代理。有什么方法可以使用它吗?是否可以使用带有水豚的HTTP代理?

上下文:我使用黄瓜水豚测试rails应用程序,并将akephalos作为javascript驱动程序。网页上有一个script标签,用于向外部网站发出请求(在本例中为maps.google.com)。黄瓜测试失败,出现以下消息:

org.apache.http.conn.HttpHostConnectException: Connection to http://maps.google.com refused (NativeException) 
(drbunix:///tmp/akephalos.24700.sock) -e:1 
./features/step_definitions/named_element_steps.rb:20 

回答

5

我不知道Akephalos,但可以肯定的是可能的硒/ Firefox中:

Capybara.register_driver :selenium do |app| 
    profile = Selenium::WebDriver::Firefox::Profile.new 

    profile["network.proxy.type"] = 1 # manual proxy config 
    profile["network.proxy.http"] = "http://example.com" 
    profile["network.proxy.http_port"] = 80 

    Capybara::Selenium::Driver.new(app, :profile => profile) 
    end 
相关问题