Skip to content

Instantly share code, notes, and snippets.

@mzemel
Last active December 19, 2015 03:59
Show Gist options
  • Save mzemel/5894359 to your computer and use it in GitHub Desktop.
Save mzemel/5894359 to your computer and use it in GitHub Desktop.
require 'watir-webdriver'
puts "Please enter a user"
user = gets
user.chomp!
profile = Selenium::WebDriver::Firefox::Profile.new
#profile.proxy = Selenium::WebDriver::Proxy.new :http => '127.0.0.1:8118'
b = Watir::Browser.new :firefox, :profile => profile
b.goto 'reddit.com'
while !b.a(:href => "http://www.reddit.com/user/" + user + "/").present?
b.text_field(:name => 'user').set user
b.text_field(:name => 'passwd').set ('a'..'z').to_a.shuffle![0..7].join("")
b.button(:type => 'submit').click
Watir::Wait.until { b.div(:class => 'status error').present? || b.a(:href => "http://www.reddit.com/user/" + user + "/").present? }
end
puts 'Success!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment