我正在自动执行一个Web应用程序。我目前可以通过网页在表单中输入一些信息并按提交按钮。但是,该页面在提交表单之前需要确认。它调用了confirm()函数,它使用Ok或Cancel弹出一个小窗口。我想自动点击“确定”。VBScript IE自动化 - 在确认弹出框上按“确定”
它不适用于SendKeys,因为当调用confirm()弹出函数时,Wscript似乎暂停&等待确认(Ok或Cancel),然后继续。
我的代码如下附:
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.Navigate "www.abc.com"
Do While objIE.Busy Or (objIE.READYSTATE <> 4)
Wscript.Sleep 100
Loop
objIE.Document.all(73).value = "Testing…" 'this is the form input
objIE.Document.all(106).click 'this is the submit button
'Confirm box will come up here & I want to press 'Ok'
***'Something in here to press the popup Ok button???***
非常感谢!
您能否以不同的方式查看并直接向表单的操作目标运行http post请求? – 2011-05-27 14:25:19
或者只是用你自己总是返回true函数替换confirm函数,比如'objIE.Window.Eval“window.confirm = function(){return true;};”'? – svinto 2011-05-27 15:23:15