Skip to content

Instantly share code, notes, and snippets.

@kingbin
Created January 29, 2012 16:33
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kingbin/1699540 to your computer and use it in GitHub Desktop.
Save kingbin/1699540 to your computer and use it in GitHub Desktop.
automate testing a web project :)
# Using the web automation driver (watir-webdriver) through the tor network
# Automates webpage actions & bypasses the voting limit on polldaddy
# Casts a vote every 3 seconds for a total of 1000 votes
require 'watir-webdriver'
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 = Watir::Browser.new :firefox
b.goto 'speakimge.wordpress.com/2012/01/25/under-the-covers/'
(1..1000).each do |i|
b.radio(:id => 'PDI_answer26523547').set
b.link(:id => 'pd-vote-button5876349').click
b.link(:href, 'javascript:PDV_go5876349();').click
puts 'Another vote! ' #<< b.span(:class => 'pds-feedback-votes').text.to_s
sleep(3)
end
@lynspyre
Copy link

Any way to show the count of votes?.
Because i remove the # (sharp) from the line and it crash.

@mehh
Copy link

mehh commented Mar 3, 2013

What are you using other than tor? I can only get TOR to work on socks, so how should I go about using the 'http' proxy?

@T-Rave
Copy link

T-Rave commented Mar 5, 2013

If anyones script dies from the page throwing an error, put a rescue in there. Mine was dying with inconstant amounts of votes so the rescue keeps it going.

Also, don't forget to run through a proxy if the voting cast are close together. They will stop you for a brief time if too rapid. Netshade for mac does a good job when you throw it on auto-cycle proxies.

@T-Rave
Copy link

T-Rave commented Mar 6, 2013

@mehh If you have tor running you can add these lines instead of line 7 and it should work through Tor

profile['network.proxy.socks'] = 'localhost'
profile['network.proxy.socks_port'] = 9150
profile['network.proxy.type'] = 1

Comes from the Selenium documentation.

@jfrux
Copy link

jfrux commented Feb 13, 2014

Now we just gotta figure out captcha :-/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment