Skip to content

Instantly share code, notes, and snippets.

@mechamogera
Created May 22, 2012 12:54
Show Gist options
  • Save mechamogera/2768869 to your computer and use it in GitHub Desktop.
Save mechamogera/2768869 to your computer and use it in GitHub Desktop.
capybara(webdriver)を用いてyahooで検索する
# -*- encoding: UTF-8 -*-
gem 'capybara', '>= 1.1.2'
gem 'selenium-webdriver' ,'>= 2.20.0'
require 'capybara'
require 'capybara/dsl'
require "selenium-webdriver"
include Capybara::DSL
# ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil # proxyを使わない場合
Capybara.register_driver :selenium do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
Capybara::Selenium::Driver.new(app, :profile => profile)
end
Capybara.default_driver = :selenium
Capybara.app_host = 'http://www.yahoo.co.jp/'
Capybara.run_server = false
visit('/')
fill_in('srchtxt', :with => 'google')
click_button('検索')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment