Capybara的API似乎不支持配置HTTP代理。有什么方法可以和它一起使用吗?
上下文:我使用capybara和cucumber来测试rails应用程序,并使用akephalos作为javascript驱动程序。页面上有一个向外部站点(在本例中为maps.google.com)发出请求的script标记。cucumber测试失败,并显示以下消息:
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发布于 2011-07-06 19:47:44
我不知道Akephalos,但使用Selenium/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)
endhttps://stackoverflow.com/questions/5266371
复制相似问题