[英]How to disable image loading in capybara-webkit?
Poltergeist driver has the feature where you can turn image loading off, how can I achieve the same with capybara-webkit? Poltergeist驱动程序具有可以关闭图像加载的功能,如何使用capybara-webkit实现相同的功能?
This would make my app faster since we load some images using vanity urls. 这将使我的应用程序运行更快,因为我们使用虚荣网址加载了一些图片。
I was debugging some request tests and I switched back and forth from capybara-webkit to poltergeist to selenium. 我正在调试一些请求测试,然后从capybara-webkit切换到poltergeist到selenium。 There is a nice feature poltergeist has which is disable image loading and I discover this awesome dude made it possible for capybara-webkit. poltergeist有一个不错的功能,它禁用了图像加载功能,我发现这个很棒的家伙使capybara-webkit成为可能。
https://github.com/thoughtbot/capybara-webkit/commit/646eabc68d5c6fe5bc0515492ee9ba04c5f49b8f https://github.com/thoughtbot/capybara-webkit/commit/646eabc68d5c6fe5bc0515492ee9ba04c5f49b8f
The problem is that is not well documented. 问题是没有充分记录。 Here is how you turn image loading off in capybara-webkit. 这是您如何在capybara-webkit中关闭图像加载的方法。
# spec_helper.rb
Capybara.register_driver :webkit do |app|
driver = Capybara::Webkit::Driver.new(app)
driver.browser.set_skip_image_loading true
driver
end
Alan's answer didn't work for me but pointed me to this: 艾伦(Alan)的答案对我没有用,但指出了这一点:
# spec_helper.rb
RSpec.configure do |config|
config.before(:each, :type => :feature) do
page.driver.browser.set_skip_image_loading true
end
end
UPDATE: Actually, both settings seem to have no effect, or not always. 更新:实际上,这两种设置似乎都没有效果,或者并非总是如此。 Scratching my head... 挠头...
Capybara docs suggest you want: 水豚文档建议您要:
Capybara::Webkit.configure do |config|
config.skip_image_loading
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.