Sha256: 85344b291456970ea21d834fe7abd759a886ff4142787fde87476ddc2699d07e

Contents?: true

Size: 701 Bytes

Versions: 5

Compression:

Stored size: 701 Bytes

Contents

require 'capybara/poltergeist'
require 'capybara/dsl'

module CapybaraWithPhantomJs
  include Capybara::DSL

  # Create a new PhantomJS session in Capybara
  def new_session

    # Register PhantomJS (aka poltergeist) as the driver to use
    Capybara.register_driver :poltergeist do |app|
      Capybara::Poltergeist::Driver.new(app)
    end

    # Use XPath as the default selector for the find method
    #Capybara.default_selector = :xpath

    # Start up a new thread
    @session = Capybara::Session.new(:poltergeist)

    # Report using a particular user agent
    @session.driver.headers = { 'User-Agent' =>
      "Janis Parser ;)" }

    # Return the driver's session
    @session
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
janis-0.1.4 lib/janis/specific_parsers/parsing_tools/capybara_with_phantom_js.rb
janis-0.1.3 lib/janis/specific_parsers/parsing_tools/capybara_with_phantom_js.rb
janis-0.1.2 lib/janis/specific_parsers/parsing_tools/capybara_with_phantom_js.rb
janis-0.1.1 lib/janis/specific_parsers/parsing_tools/capybara_with_phantom_js.rb
janis-0.1.0 lib/janis/specific_parsers/parsing_tools/capybara_with_phantom_js.rb