Professional Documents
Culture Documents
Features:
Limitation:
• More than 1 popup: Opening a website or a link which leads to other popup will
make the script fail as it closes on 1 popup. But with small enhancement it can be
easily changed to support these websites also
• Ignoring a link: Clicking on links like “Logout” is not excluded and hence may
fail the script
• Dynamic website: If clicking of a link changes the home page of a website then
the script will fail. Consider the case of www.google.com, now if you run the
script on this page it will fail becuase when the script clicks on one of the
languages link, the home page of website will change and even the no. of links
might change. This can be correct by two ways, one is to close all the browsers
every time and delete all cookies and then go for the next link and other ways
would be to delete the session cookies of the browser. For deleting session
cookies there is no software available except the one that I created and is present
on this website
Dim i_Link
BrowserPage.Object.links(i_Link).click
On Error Resume Next
Browser("CreationTime:=" & i_CreationTime).sync
Browser("CreationTime:=" & i_CreationTime).Page(sPage).sync
On Error GoTo 0
Dim s_LinkDetails
sPage = "micclass:=Page"
sBrowser = "creationtime:="
Dim orgURL, orgCreationTime
Dim i_Link, l_hWnd
Dim b_newBrowser
Dim s_LinkOuterText, s_LinkInnerText, s_Linkhref
s_URL = BrowserPage.GetROProperty("url")
l_hWnd = BrowserObject.GetROProperty("hwnd")
i_CreationTime = 1
i_LinkCount = BrowserPage.Object.links.Length - 1
If Trim(BrowserPage.Object.links(i_Link).target) = "" _
And InStr(BrowserPage.Object.links(i_Link).href,
"javascript:") = 0 Then
b_newBrowser = False
Else
b_newBrowser = TRUE
End If
s_LinkOuterText = BrowserPage.Object.links(i_Link).outerText
s_LinkInnerText = BrowserPage.Object.links(i_Link).innerText
s_Linkhref = BrowserPage.Object.links(i_Link).href
BrowserPage.Object.links(i_Link).click
Dim s_LinkDetails
If b_NewBrowser Then
sBrowser = "CreationTime:=" & i_CreationTime
IHTML = Browser(sBrowser).Page(sPage).Object.Body.innerHTML
Else
IHTML = BrowserPage.Object.Body.innerHTML
End If
'Check if page was not able to be displayed you can update this
code any time
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
CheckLinks2 = 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
If b_NewBrowser Then
sBrowser = "CreationTime:=" & i_CreationTime
While CLng(Browser(sBrowser).GetROProperty("hwnd"))<>l_hwnd
On Error Resume Next
Browser(sBrowser).Sync
Browser(sBrowser).Page(sPage).Close
On Error GoTo 0
Browser(sBrowser).Close
'Tackle links that open a new browser and also opens a
popup using that
'i_CreationTime=i_CreationTime + 1
Wend
i_CreationTime = 1
Else
On Error Resume Next
BrowserObject.Navigate s_URL
BrowserObject.Sync
BrowserObject.Page.Sync
On Error GoTo 0
End If
Next
End Function