watir学习--baidu搜索示例
今天任务不多,有空看了些watir的资料,于是手痒痒的想做个例子练练,网上有个google搜索的示例,本人也就照猫画虎,写了一个baidu搜索的小例子。大牛就直接跳过吧。。。欢迎有兴起的朋友一起交流学习,共进步。代码如下:
require 'watir'
context = "hello"
@broswer = Watir::IE.new
@broswer.goto("http://www.baidu.com/")
@broswer.text_field(:name,"wd").set(context)
sleep 1
@broswer.button(:id,"su").click
if @broswer.contains_text("#{context}")
puts "Pass"
else
puts "Failed"
end
sleep(1)
@broswer.close
作者:Glen.He
出处:http://www.cnblogs.com/puresoul/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。