1.编码最好用UTF-8,否则会出现如下代码失效
autoit = WIN32OLE.new('AutoItX3.Control')
autoit.WinWaitActive('Explorer 用户提示','','5')
autoit.ControlClick('Explorer 用户提示','','Button1')
2.require需要加载的各项如下
require "rubygems"
require "watir"
require "win32ole"
require "watir/windowhelper"
3.处理3中弹窗的方法:
•def alert_click
• title_name =
get_title
• ai =WIN32OLE.new('AutoItX3.Control')
• ai.WinWaitActive(title_name,"",5)
• ai.controlclick(title_name, "","Button1")
•end
•def prompt(str)
• title_name = ‘Explorer
用户提示’
# 不同浏览器提示不同
• ai =WIN32OLE.new('AutoItX3.Control')
• ai.WinWaitActive(title_name,"",5)
• ai.ControlSetText(title_name,'','Edit1',str)
• ai.controlclick(title_name, "","Button1")
•end
•def upload(path)
• title_name = ‘选择要加载的文件’#
不同浏览器提示不同
• ai =WIN32OLE.new('AutoItX3.Control')
• ai.WinWaitActive(title_name,"",5)
• ai.ControlSetText(title_name,'','Edit1',path)
• ai.controlclick(title_name, “”,“Button2”)
# Button2 确定, Button3
取消
•end