2uk8rq
Last Updated: February 25, 2016
·
1.908K
· rondale-sc
E02cf84c29e144cdbdba60a4a6db68b7

Prevent Phantom/Capybara from requesting images

Recently ran into an issue where my cucumber suite was throwing a timeout error. The error was thrown because an image hosted externally wasn't rendering.

Luckily Phantomjs has some amazing Command Line Options available to help us along. On of which is --load-images which allows us to prevent phantom from making the image request.

Let's setup poltergeist (Phantomjs' capybara driver) to accept these options...

Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
  options = { 
    phantomjs_options: ['--load-images=no'] 
   }
  Capybara::Poltergeist::Driver.new(app,options)                                                                                                              end

As you can see we can specify a list of the CLI options and they'll be set when we run our suite. And there you have it, prevent phantomjs from requesting images!

Thanks for reading!

Say Thanks
Respond