Skip to content

Instantly share code, notes, and snippets.

@jverdeyen
Created June 17, 2013 07:41
Show Gist options
  • Save jverdeyen/5795242 to your computer and use it in GitHub Desktop.
Save jverdeyen/5795242 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'mechanize'
agent = Mechanize.new
agent.get('https://account.dyn.com/entrance/') do |page|
puts page.title # Output: Create Dyn Account or Login
# Submit the login form
my_page = page.form_with(:action => '/entrance/') do |form|
form.username = "<insert username here>"
form.password = "<insert password here>"
end.click_button
puts my_page.title # Output: My Dyn Account
# Click the logout link
logout_page = agent.click(my_page.link_with(:text => /Log Out/))
puts logout_page.title # Output: Thank you for using Dyn
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment