Poltergeist driver has the feature where you can turn image loading off, how can I achieve the same with 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. There is a nice feature poltergeist has which is disable image loading and I discover this awesome dude made it possible for capybara-webkit.
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.
# 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:
# 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.