Module: CapybaraWithPhantomJs
- Includes:
- Capybara::DSL
- Included in:
- Janis::Parsing::SpecificParsers::ProxyListOrgParser
- Defined in:
- lib/janis/specific_parsers/parsing_tools/capybara_with_phantom_js.rb
Instance Method Summary collapse
-
#new_session ⇒ Object
Create a new PhantomJS session in Capybara.
Instance Method Details
#new_session ⇒ Object
Create a new PhantomJS session in Capybara
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# 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 |