Created
April 4, 2011 23:24
-
-
Save alisterscott/902698 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 'highline/import' | |
require 'watir-webdriver' | |
begin | |
username = ask("What is your twitter username?") | |
password = ask("and your password?") { |q| q.echo = false } | |
browser= Watir::Browser.start "twitter.com", :firefox | |
browser.span(:text => "Sign in").click | |
browser.text_field(:id => "username").set username | |
browser.text_field(:id => "password").set password | |
browser.button(:id => "signin_submit").click | |
raise "Could not log into Twitter: either your password is wrong or a CAPTCHA is needed." if browser.url.include? "sessions" | |
100.times do |attempt| | |
browser.text_field(:class => "twitter-anywhere-tweet-box-editor").when_present.set "#SeConf is awesome x #{attempt}! http://tryselenium.org @Watir-WebDriver is even more awesome!" | |
browser.link(:class => "tweet-button button").when_present.click | |
browser.goto "twitter.com" | |
end | |
ensure | |
browser.close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment