module CapybaraWithPhantomJs

Public Instance Methods

new_session() click to toggle source

Create a new PhantomJS session in Capybara

# File lib/janis/specific_parsers/parsing_tools/capybara_with_phantom_js.rb, line 8
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