Function IE_WaitUntilLoadFinish(sec_time)
'IE等待状态栏提示完成,直到超过指定时间
loadFinish="no"
For i=1 To sec_time '等待指定时间
ieHint=Browser("title:=XXXXXX").WinStatusBar("regexpwndclass:=msctls_statusbar32").GetRoproperty("regexpwndtitle")
If RegExpTest("正在打开网页",ieHint)>0 Then
wait(1)
ElseIf ieHint="网页上有错误" Then
ElseIf ieHint="完毕" Then
loadFinish="yes"
Exit For
End If
Next
IE_WaitUntilLoadFinish=loadFinish
If loadFinish="no" Then
captureFileName=ErrorCapture("系统加载过慢") 'ErrorCapture是自定义的全屏捕捉函数
Reporter.ReportEvent micFail,"系统加载过慢,详见截图"&captureFileName&"","错误"
End If
End Function
RegExpTest这个函数是我修改帮助里面的同名函数而来,代码如下
Function RegExpTest(patrn, strng)
'返回匹配要求的字符串数量
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
RegExpTest = Matches.Count
End Function作者: dreamever 时间: 2009-4-22 09:49
用IE的document.readystate属性来判断,当页面全部加载完成时,readystate值是4,如果已经加载完成的页面,进度条却还在跑,那么readystate值是3,我在自己的测试项目上测试通过了作者: xiaoyaoke 时间: 2009-4-22 10:08
试试这个:
Set IE=CreateObject("InternetExplorer.Application")
With IE
.Navigate(Link)
.Visible = 1
.Width = 1200
.Height = 800
End With
While IE.busy
WScript.Sleep 1000
Wend作者: blueeagle9999 时间: 2009-4-22 11:12 标题: 回复 7# 的帖子 这个好,有空我也试试,不过要是网页有错误呢?作者: shanxi 时间: 2009-4-22 13:09 标题: 一般是两个一起用: Do Until Not ie.Busy And ie.ReadyState = 4/READYSTATE_COMPLETE