Chinaunix首页 | 论坛 | 博客
  • 博客访问: 744116
  • 博文数量: 769
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 4985
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:37
文章分类

全部博文(769)

文章存档

2011年(1)

2008年(768)

我的朋友

分类:

2008-10-15 16:42:15

        set a= Browser("Yahoo!")
        set b= Browser("Yahoo!").Page("Yahoo!")
        call CheckLinks(a,b)
        Function CheckLinks (BrowserObject,BrowserPage)
        CheckLinks=TRUE
        Dim s_URL,i_CreationTime
        Dim s_LinkOuterText,s_LinkInnerText,s_Linkhref
        s_URL=BrowserPage.GetROProperty("url")
        i_CreationTime=1
        i_LinkCount=BrowserPage.object.links.length - 1

        Dim i_Link

        For i_Link=0 to i_LinkCount
        If Trim(BrowserPage.object.links(i_Link).target)="" Then
        BrowserPage.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

【责编:michael】

--------------------next---------------------

阅读(270) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~