Created
June 17, 2013 07:41
-
-
Save jverdeyen/5795242 to your computer and use it in GitHub Desktop.
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
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