Skip to content

Instantly share code, notes, and snippets.

@bash0C7
Created Nov 12, 2013
Embed
What would you like to do?
Web serfing with Webrat
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