Watir/Ruby 框架,无法关闭JS弹出框

kinged87 2014-04-21 01:19:09
最近学习Watir,写了个脚本,实现的是登陆网站,并判断是否登陆成功,测试的时候用的搜狐焦点的网站: http://http://house.focus.cn/.
代码如下:
require 'rubygems'
require 'watir'
require 'watir/dialog'

#open the IE browser
ie = Watir::IE.new
#Step 1: go to the test web: http://house.focus.cn/
ie.goto('http://house.focus.cn/')
ie.text_field(:id,'email').set('123456')
ie.text_field(:id,'password').set('123456')
ie.button(:id,'submit').click

if ie.contains_text("我的博客")
puts "successful"
else
dia = Watir::Dialog.new
dia.close
puts "failed"

end

Dialog类是新加的吧,从网站看到好些关JS弹出框的方法,感觉和Dialog里的方法差不多,可是就是关闭不了。
也用过
autoit = WIN32OLE.new('AutoItX3.Control')
ret = autoit.WinWaitActive("来自网页的信息", "",3)
if ret==1
autoit.Send("{Enter}")
end


请大家帮帮忙,看一下,谢谢了!
ie.close
...全文
564 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
幼稚王的小号 2014-09-23
  • 打赏
  • 举报
回复
我也才学RUBY不久呀,看不懂这个
点点朋 2014-04-28
  • 打赏
  • 举报
回复
看了,不懂这个。
kinged87 2014-04-23
  • 打赏
  • 举报
回复
没人看到吗
kinged87 2014-04-22
  • 打赏
  • 举报
回复
没有人看到吗。。。。。。

2,763

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ruby/Rails
社区管理员
  • Ruby/Rails社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧