Skip to content

Instantly share code, notes, and snippets.

@rafops
Created July 26, 2012 19:17
Show Gist options
  • Save rafops/3183926 to your computer and use it in GitHub Desktop.
Save rafops/3183926 to your computer and use it in GitHub Desktop.
Capybara Google Hello World with screenshot
#sudo apt-get install libxslt-dev libxml2-dev
#gem install nokogiri
#gem install capybara
#
#sudo apt-get install libqt4-dev
#sudo apt-get install g++
#
#gem install poltergeist
#
#--------------------------------------------------------------------------------
#
#https://github.com/jonleighton/poltergeist
#
#sudo update-alternatives --install "/bin/phantomjs" "phantomjs" /opt/phantomjs-1.6.1-linux-x86_64-dynamic/bin/phantomjs 1
require 'capybara'
require 'capybara/dsl'
require 'capybara/poltergeist'
Capybara.default_driver = :poltergeist
Capybara.run_server = false
Capybara.app_host = 'http://www.google.com.br'
class MyCapybaraTest
include Capybara::DSL
def test_google
visit('/')
fill_in 'q', with: "Hello World"
click_button('Estou com sorte')
page.driver.render 'random.png'
end
end
test = MyCapybaraTest.new
test.test_google
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment