require 'watir'                                       #必须包含watir


check_text = "watir测试框架"                   #定义局部变量
ie = Watir::IE.new                                 # 打开一个IE浏览器
ie.goto("http://www.google.cn")             #打开google首页
ie.text_field(:name,"q").set(check_text)   #输入搜索内容
sleep(1)
ie.radio(:index, 3).set                      
sleep(1)
ie.button(:name,"btnG").click                 # 点击按钮“Google搜索”
if ie.contains_text("符合#{check_text}的查询结果")
  puts "搜索成功!"
else
  puts "搜索失败!"
end
sleep(1)
ie.close                                               #关闭IE窗口

相关文章:

  • 2021-09-12
  • 2021-12-22
  • 2022-12-23
  • 2021-11-15
  • 2021-12-20
  • 2021-07-24
  • 2021-12-01
猜你喜欢
  • 2021-08-18
  • 2022-01-15
  • 2021-08-25
  • 2021-08-18
  • 2022-01-17
  • 2022-12-23
  • 2021-08-04
相关资源
相似解决方案