Hi
I'm trying to get all the broken links from a website. I used the
following code that I got from online.
I've about 153 links. For some links I get the response back and for
others I'm getting "Operation timed out" error.
Please help! Most the links that I'm getting this error for are
clickable, so why am I getting this error?
Thanks
Browser("ABC").Page("HomePage").Sync
Set oLink = Description.Create
oLink("micclass").Value = "Link"
Set oAllLinks = Browser("ABC").Page("HomePage").ChildObjects(oLink)
'Find out the count of links
iTotalLinks = oAllLinks.Count
'Loop through all the links to find if the link is broken or not
For i=0 to iTotalLinks - 1
'Find out the url for the link
sURL = oAllLinks(i).GetROProperty("url")
'Create a WinHTTP Request using the link's URL
Set objWinHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
objWinHTTP.Open "GET", sURL, False
objWinHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MyApp
1.0; Windows NT 5.1)"
'Send the Request to the Server and capture the response
objWinHTTP.Send
iReturnVal = objWinHTTP.Status
'Find out if the Link exists or is broken
If iReturnVal = 200 Then
msgbox "Link - " & sURL & " Exists"
ElseIf iReturnVal = 404 Then
msgbox "Link - " & sURL & " is Broken"
Else
msgbox "Code" - iReturnVal
End If
Set objWinHTTP = Nothing
Next
--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
---
You received this message because you are subscribed to the Google Groups "QTP
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.