Tuesday 27 August 2013

Check all Links !!! QTP

systemutil.Run "firefox","http://argos.co.uk"
browser("title:=.*").page("title:=.*").Sync

Set li=description.Create()
li("html tag").value="A"
Set a=browser("title:=.*").page("title:=.*").ChildObjects(li)
msgbox a.count
'num=a.count
For i=0 to a.count-1
   'tag = a(i).GetROProperty("innertext")
   'href = a(i).GetROProperty("href")
   'Reporter.ReportEvent 0,  "Links in Page", "name:" & tag &  ";url: " & href
    'print a(i).GetROProperty("text")
    'print a(i).GetROProperty("href")
Set a = Browser("title:=.*").Page("title:=.*").ChildObjects(li)
ref = a(i).GetROProperty("href")
Browser("title:=.*").Page("title:=.*").link("text:=.*","index:="&i).click
Browser("title:=.*").sync
title1=Browser("title:=.*").getRoproperty("title")
MsgBox title1
Browser("title:=.*").navigate(ref)
'Navigates to the url taken from "href" property
Browser("title:=.*").sync
title2=Browser("title:=.*").getRoproperty("title")
'get the tile of the tNavigated page
MsgBox title2
If title1=title2 Then
'condition to check for the targetted page and Navigated page
Reporter.ReportEvent 0, "Navigated To Correct Page",""&title1
'Reports if correct
else
Reporter.ReportEvent 1,""&title1,""&title2
End If
Browser("title:=.*").back
'Navigates back to main page
Browser("title:=.*").sync
Next

No comments:

Post a Comment