Created
June 28, 2011 02:29
-
-
Save gordonbanderson/1050365 to your computer and use it in GitHub Desktop.
Use capybara to screenshot google home page outside of Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'capybara' | |
require 'capybara/dsl' | |
require 'yaml' | |
Capybara.run_server = false | |
Capybara.current_driver = :selenium | |
Capybara.app_host = 'http://www.google.com' | |
module MyCapybaraTest | |
class Test | |
include Capybara::DSL | |
def test_google | |
session = Capybara::Session.new(:selenium, 'google') | |
#Uncomment this to see in Chrome | |
driver = session.driver | |
session.visit('/') | |
session.driver.browser.save_screenshot('home.png') | |
end | |
end | |
end | |
t = MyCapybaraTest::Test.new | |
t.test_google |
I was getting deprecation complaints with
include Capybara
My version number is 1.0.0 for capybara,
gem list | grep capy
capybara (1.0.0)
my bad - I'm on 0.4.1.2. stupid mistake, I installed it a while ago, unbundled it, and then bundle install. thx!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey, for what it's worth, this didn't work for me until I erased the "include Capybara::DSL" line. nice little hack tho!
I'm using the latest Capybara, I think; installed it via gem install earlier today.