Created
December 22, 2012 15:50
-
-
Save tacahiroy/4359546 to your computer and use it in GitHub Desktop.
A sample code of the Watir. This automates 緑のgoo's "水をあげる"
This file contains hidden or 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
| #! ruby | |
| # coding: utf-8 | |
| require "rubygems" | |
| require "watir-webdriver" | |
| browser = Watir::Browser.new :firefox, :profile => "default" | |
| browser.goto "http://green.goo.ne.jp/" | |
| btn = browser.div(:id => "tree").div(:class => "btn").images[0] | |
| div = browser.div(:id => "tree").ul(:class => "clearfix").li(:class => "count").divs[2] | |
| count = div.class_name.scan(/\d+\Z/)[0].to_i | |
| count.times do | |
| until btn.src =~ %r!/mytree_btn_water.jpg! do end | |
| btn.click | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment