Skip to content

Instantly share code, notes, and snippets.

@gordonbanderson
Created June 28, 2011 02:29
Show Gist options
  • Save gordonbanderson/1050365 to your computer and use it in GitHub Desktop.
Save gordonbanderson/1050365 to your computer and use it in GitHub Desktop.
Use capybara to screenshot google home page outside of Rails
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
@gordonbanderson
Copy link
Author

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)

@gilesbowkett
Copy link

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