Skip to content

Instantly share code, notes, and snippets.

@tacahiroy
Created December 22, 2012 15:50
Show Gist options
  • Select an option

  • Save tacahiroy/4359546 to your computer and use it in GitHub Desktop.

Select an option

Save tacahiroy/4359546 to your computer and use it in GitHub Desktop.
A sample code of the Watir. This automates 緑のgoo's "水をあげる"
#! 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