Module: CapybaraWithPhantomJs
- Includes:
- Capybara::DSL
- Included in:
- MypageTools::ScheduleScraper
- Defined in:
- lib/capybara_with_phantom_js.rb
Overview
Voodoo to make Capybara do what I want. Ripped off nearly wholesale from a random blog after hours of Googling.
Instance Method Summary collapse
Instance Method Details
#new_session ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/capybara_with_phantom_js.rb', line 6 def new_session Capybara.register_driver :poltergeist do |app| Capybara::Poltergeist::Driver.new(app) end Capybara.configure do |config| config.run_server = false # Aparrently I have to do this if I'm not locally testing config.default_driver = :poltergeist config.default_selector = :xpath config.ignore_hidden_elements = true config.app_host = "https://mypage.apple.com" end @session = Capybara::Session.new(:poltergeist) @session.driver.headers = { "User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X" } @session end |