Created
May 22, 2012 12:54
-
-
Save mechamogera/2768869 to your computer and use it in GitHub Desktop.
capybara(webdriver)を用いてyahooで検索する
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
# -*- 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