Created
November 12, 2013 15:25
-
-
Save bash0C7/7432700 to your computer and use it in GitHub Desktop.
Web serfing with Webrat
This file contains hidden or 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 'webrat' | |
require 'mechanize' | |
class Hoge | |
Webrat.configure do |config| | |
config.mode = :mechanize | |
end | |
include Webrat::Methods | |
def initialize login_page_url, user_id, password | |
visit login_page_url | |
fill_in "login_id", :with => user_id | |
fill_in "login_password", :with => password | |
click_button "login!!" | |
end | |
#serf(%w{http://example.com/hoge}) {|url, page| puts "#{url}\t#{/some_string/ =~ page.content ? :o : :x}"} | |
def serf target_urls | |
target_urls.each {|url| yield url, visit(url)} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment