require 'watir'
require 'watir/WindowHelper'
require 'win32ole'
class Test
$url="http://www.google.com"
$ie = Watir::IE.new
$ie.goto($url)
$ie.maximize()
$ie.text_field(:name, "q").set("good")
$ie.button(:name, "btnI").click
end
第一次用RUBY写的很简单。即打开google的搜索页面,输入good,点击搜索。很好理解
注意:一些网页的部分内容的name并不知道,可以用dreamweaver来确定。例如上例中的q和btnI
评论