Simple Code To Check All Links
‘***********************************************************************
‘SCENARIO NAME :Check all links
‘DESCRIPTION :This code Check all links in any web page
‘PRECONDITIONS :This Assume that when click on Link the new page will open on current window but not in new window
‘AUTHOR :Mohan kumar kakarla
‘***********************************************************************
Set oDesc = Description.Create()
‘ Retrieve HTML tag <A>
oDesc(“html tag”).Value = “A”
Set rc = Browser(“title:=.*”).Page(“title:=.*”).ChildObjects(oDesc)
num = rc.Count()’get the number of link in a page
For i=0 to num-1
Set rc = Browser(“title:=.*”).Page(“title:=.*”).ChildObjects(oDesc)
ref = rc(i).GetROProperty(“href”)’get the “href”propety of the i th link
Browser(“title:=.*”).Page(“title:=.*”).link(“text:=.*”,”index:=”&i).click’click on i th link
Browser(“title:=.*”).sync
title1=Browser(“title:=.*”).getRoproperty(“title”)’get the tile of the target page
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
2 Comments »
Leave a comment
-
Archives
- July 2011 (1)
- March 2011 (1)
- November 2010 (1)
- November 2008 (4)
- October 2008 (2)
- September 2008 (2)
- June 2008 (1)
- March 2008 (4)
- February 2008 (44)
-
Categories
- Automated Test Script Creation Process
- Automating MS Word
- Automating QC
- Automation Object Model For QTP
- Backward compatability in QTP
- Browser Scripts
- COM and QTP
- compare 2 text files
- Descriptive programming
- Descriptive Programming and Child Objetcs
- Dictonary Object
- DotNetFactory
- Excel Automation
- Extra Topics
- Files and Folders
- General Standards to be followed in Test scripts
- New Features In QTP9.5
- QC-OTA
- QTP Additional Faqs
- QTP Faqs
- QTP Naming Convention
- QTP Tips and Faqs
- Running stored procedures from QTP
- Send keyboard keys
- Uncategorized
- Uninstall a software using QTP
- Uninstall a software using vbscript
- Update data in a database
- VBScript and IE Automation
- VBScript Faqs and Useful resources
- What’s New in Quick Test Pro 9.0
- Whats New in QTP 9.5
- XML Scripting
-
RSS
Entries RSS
Comments RSS
[…] Simple Code To Check All Links […]
Pingback by QTP Tutorial » Simple Code To Check All Links | November 16, 2010 |
Wow!! Thank you! I’m trying to study QTP for a week, and only with your example I understood main principles and ways of solving all my troubles!
Comment by Maksim | October 26, 2011 |