OneTestingCenter @ QTP @ Descriptive Programming @ Broken Link Checking
' @@@@@@@@@@@@@@@@@@@@@@@@@@@@
' QTP – DP - Broken Link Checker tool for Any Web App
‘ Broken Link Check – Descriptive Programing
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@
On Error Resume Next
Set oPage=Browser("name:=.*").Page("title:=.*")
DataTable.AddSheet "dtLinkName"
DataTable.GetSheet("dtLinkName").AddParameter "LinkName",""
DataTable.GetSheet("dtLinkName").AddParameter "PageTitle",""
Set oLink=Description.Create()
oLink("micClass").value="Link"
Set AllLinks=oPage.ChildObjects(oLink)
PageTitle=oPage.GetROProperty("title")
MsgBox "Total Number of links on the page: " &vbtab & PageTitle &vbtab & AllLinks.Count
For i= 0 to AllLinks.Count-1
DataTable.GetSheet("dtLinkName").SetCurrentRow(i+1)
DataTable.Value("LinkName","dtLinkName")=AllLinks(i).GetROProperty("name")
Next
RC=DataTable.GetSheet("dtLinkName").GetRowCount
For i= 1 to RC
DataTable.GetSheet("dtLinkName").SetCurrentRow(i)
LinkName=DataTable.Value("LinkName","dtLinkName")
oPage.Link("name:="& LinkName).Click
wait(2)
MyPageTitle=oPage.GetROProperty("title")
' msgBox MyPageTitle
DataTable.Value("PageTitle","dtLinkName")=MyPageTitle
If MyPageTitle<>"404 Error Page" or MyPageTitle<>"500 Internal Server Error" or MyPageTitle<>"Page Can't be found" and MyPageTitle=DataTable.Value() Then
Reporter.ReportEvent micPass, "Link works good", "Clicked on Link" & LinKName
Else
Reporter.ReportEvent micFail, "Link does not work good", "Link is BROKEN " & LinKName
End If
Browser("name:=.*").Back
' SystemUtil.Run AppURL
Wait(3)
Next
0 comments:
Post a Comment