Function CheckLinks (BrowserObject,BrowserPage)
CheckLinks=TRUE
Dim s_URL,i_CreationTime
Dim s_LinkOuterText,s_LinkInnerText,s_Linkhref
s_URL=Browser("百度一下,你就知道").Page("百度一下,你就知道").GetROProperty("url")
msgbox s_URL
i_CreationTime=1
i_LinkCount=Browser("百度一下,你就知道").Page("百度一下,你就知道").object.links.length - 1
msgbox i_LinkCount
Dim i_Link
For i_Link=0 to i_LinkCount
If Trim(Browser("百度一下,你就知道").Page("百度一下,你就知道").object.links(i_Link).target)="" Then
Browser("百度一下,你就知道").Page("百度一下,你就知道").object.links(i_Link).target="_blank"
' Set the link to open i a new window so that we dont have any change in current window
End If
BrowserPage.object.links(i_Link).click
On error resume next
Browser("CreationTime:=" & i_CreationTime).sync
Browser("CreationTime:=" & i_CreationTime).Page("micClass:=Page").sync
On error goto 0
Dim s_LinkDetails
IHTML = Browser("CreationTime:=" & i_CreationTime).Page("micClass:=Page").object.Body.innerHTML
'Check if page was not able to be displayed
If (InStr(IHTML,"HTTP 404") <> 0) Or (InStr(IHTML,"cannot be displayed") <> 0) Then
s_LinkDetails="Link Broken" + vbcrlf + "Link Details:" +vbcrlf
s_LinkDetails=s_LinkDetails+"OuterText: "+ s_LinkOuterText + vbcrlf
s_LinkDetails=s_LinkDetails+"InnerText: "+ s_LinkInnerText + vbcrlf
s_LinkDetails=s_LinkDetails+ "href: " + s_Linkhref+ vbcrlf
s_LinkDetails=s_LinkDetails+ "Links Open in New Browse: " & bNewBrowser & vbcrlf
Reporter.ReportEvent micWarning,"Check Link(" & i_Link & ") -> " & s_LinkOuterText ,s_LinkDetails
CheckLinks=FALSE
Else
s_LinkDetails="Link Working" + vbcrlf + "Link Details:" +vbcrlf
s_LinkDetails=s_LinkDetails+"OuterText: "+ s_LinkOuterText + vbcrlf
s_LinkDetails=s_LinkDetails+"InnerText: "+ s_LinkInnerText+ vbcrlf
s_LinkDetails=s_LinkDetails+ "href: " + s_Linkhref+ vbcrlf
s_LinkDetails=s_LinkDetails+ "Links Open in New Browse: " & bNewBrowser & vbcrlf
Reporter.ReportEvent micPass,"Check Link(" & i_Link & ") -> " & s_LinkOuterText ,s_LinkDetails
End If
Browser("CreationTime:=1").close
' Close the link open.
Next
End Function作者: jifeng 时间: 2008-10-28 17:44
也是收集的,给你参考吧作者: skyphoenix 时间: 2008-10-28 22:33
enable and disable???