0
votes

I want to use capybara for headless browser but i want to use this driver: Selenium::WebDriver::Remote::Http::Default.new

How to use this driver for capybara? Need to know the browser initialization using that driver not poltergeist or webkit.

Here's the example for chrome initialization in capybara: Capybara::Selenium::Driver.new(app, :browser => :chrome)

2

2 Answers

0
votes

Selenium::WebDriver::Remote::Http::Default.new isn't a driver - it's an http_client that can be used by drivers - I think what you're asking for is to use an instance of Selenium::WebDriver::Remote::Bridge which can be done using

Capybara::Selenium::Driver.new(app, browser: :remote, ...)

where the ... includes other options like :http_client, :desired_capabilites, :url (url for the remote server that will control the actual browser)

The title of this questions mentions phantomjs but never mentions it in the actual question. If thats what you really want then it's

Capybara::Selenium::Driver.new(app, browser: :phantomjs, ...)

where there are similar options http_client, desired_capabilities, url, args, port

0
votes

For Capybara, you can use Poltergeist driver on the top of Phantomjs. To use it you need to install it by gem install poltergeist or add this gem "poltergeist" to your Gemfile and run bundle install. Then add poltergeist option to your env.rb and change your Capybara.javascript_driver = :poltergeist. See the example below:

require 'capybara/poltergeist'

Capybara.register_driver :poltergeist do |app|
   options = {
      :js_errors => false ,
      # :timeout => 120,
      # :debug => true,
      # :inspector => true,
      # :window_size => [1280, 1024],
      # :logger => false,
      # :inspector => false,
      # :visible => false,
      :js => true,
      :timeout => 10000,
      :phantomjs_options => %w[--load-images=no]

   }
   Capybara::Poltergeist::Driver.new(app, options)
end

Capybara.javascript_driver = :poltergeist