处理安全弹出框方法

2011-12-11  付民 

方法一、
1, 在watir/WindowHelper.rb文件中增加方法
class AWindowHelper
  require ‘win32ole’
  def initialize
    @auto_it = WIN32OLE.new(“AutoItX3.Control”)
  end
  def push_security_cn1_alert_yes
        @auto_it.WinWait “安全警报”, “”
        @auto_it.Send “{TAB}”
        @auto_it.Send “{TAB}”
        @auto_it.Send “{SPACE}”
      end
   def push_security_cn2_alert_yes
        @auto_it.WinWait “安全信息”, “”
        @auto_it.Send “{SPACE}”
    end
end
2, 定义另一调用文件 tmp.rb
require  File.dirname(__FILE__)+”/WindowHelper.rb”
helper = AWindowHelper.new;
helper.push_security_cn1_alert_yes;
3, 在打开安全URL之前,启动调用ruby文件
Thread.new{system(“ruby #{AN_QUAN1}”)}
方法二、
=begin
安全对话框处理
参数说明:浏览器,页面
=end
a = WIN32OLE.new(“AutoItX3.Control”)
if  (a.WinExists(“安全警报”)==1)
puts “=====#{a.WinExists(“安全警报”) }+++处理安全警报框=========”
pagew=WinModel.attach(WinModel,/^安全警/)
time=1*60*5
while(a.WinExists(“安全警报”)==1)
pagew.find_element(WinElement,”.Button#1″).click#点击“是”
time=time-1
break if time<0
end
end
if  (a.WinExists(“安全信息”)==1)
puts “=====#{a.WinExists(“安全信息”) }++++处理安全信息框==============”
pagew=WinModel.attach(WinModel,/^安全信息/)
time=1*60*5
while(a.WinExists(“安全信息”)==1)
pagew.find_element(WinElement,”.Button#6″).click#点击“是”
time=time-1
break if time<0
end
end
目前就想到这些方法。不知道还有没有更好的方法
转载务必注明出处Taobao QA Team,原文地址:http://qa.taobao.com/?p=14364
391°/3910 人阅读/0 条评论 发表评论

登录 后发表评论