|
![](http://wiki.openqa.org/download/attachments/10780767/JavascriptPopUp2.jpg)
针对该类对话框的watir处理方法:
require 'watir'
require 'win32ole'
require 'watir/WindowHelper'
# 登陆
$ie_site ='http://members.shaw.ca/paul_rogers/watir_tests/popups1.html'
$ie = Watir::IE.new
$ie.goto $ie_site
$ie.buttons.each {|b| puts b.to_s}
$ie.button(:value,"Prompt").click_no_wait
sleep(5)
autoit = WIN32OLE.new("autoitx3.control")
ret = autoit.WinWait("Explorer 用户提示","",1)
ress =autoit.ControlFocus("Explorer 用户提示","","Edit1")
resss =autoit.ControlSetText("Explorer 用户提示", "","Edit1","New Text Here")
ss =autoit.ControlClick("Explorer 用户提示", "确定","Button1")
涉及到的函数用法格式和返回值:
WinWait:
WinWait ( "title" [, "text" [, timeout]] )
Success: Returns 1.
Failure: Returns 0 if timeout occurred.
ControlFocus:
ControlFocus ( "title", "text", controlID )
Success: Returns 1.
Failure: Returns 0.
ControlSetText:
ControlSetText ( "title", "text", controlID, "new text" [, flag] )
Success: Returns 1.
Failure: Returns 0 if window/control is not found.
ControlClick:
ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]] )
Success: Returns 1.
Failure: Returns 0.
[ 本帖最后由 Spark.lee 于 2009-9-16 11:23 编辑 ] |
|