Give me some scripts for 1). checking webpage links
(counting links,opening web pages,counting child elements)

Answer Posted / rnashok

' Create object references to the Browser and Page objects.
Set BrowserObj =Browser("Yahoo!")
Set BrowserPageObj = Browser("Yahoo!").Page("Yahoo!")

' Set a description object to identify links.
Set oDesc = Description.Create()
oDesc("html tag").Value = "A"

' Get a collection of links
Set oLinkCollection = BrowserPageObj.ChildObjects(oDesc)
ItemCnt = oLinkCollection.Count-1
' Loop through the link collection
For i = 0 to ItemCnt
msg = ""
' Highlight and click link i.
Set oLink = oLinkCollection.Item(i)
oLink.Highlight
linkText = oLink.GetROProperty("innertext")

msg = "link text = " & linkText & vbNewLine
oLink.Click
BrowserObj.Sync

' Read page title.
titleStr = mid(BrowserPageObj.GetROProperty("title"),1,50)
msg = msg & "page title = " & titleStr & vbNewLine

' Check if page load had error.
If instr(1,titleStr,"Cannot find server") > 0 or
instr(1,titleStr,"HTTP 404") > 0 Then
msg = msg & "==> broken link" & vbNewLine
Reporter.ReportEvent micFail, "Link " & linkText, msg
else
msg = msg & "==> good link" & vbNewLine
Reporter.ReportEvent micPass, "Link " & linkText, msg
End If

' Navigate back to links page.
BrowserObj.Back
BrowserObj.Sync

' Rebuild link collection, navigating away and back
destroys previous collection.
Set oLinkCollection = BrowserPageObj.ChildObjects(oDesc)
Next

' Release the objects
Set oLinkCollection = nothing
Set BrowserObj = nothing
Set BrowserPageObj = nothing
Set oDesc = nothing

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Diff b/w Health care domain and Banking Domain?

4423


How does quicktest professional identifies the object in the application?

762


Suggest and Define a solution for an application whose objects are not recognized by UFT?

869


Hi Every body please explain me in steps to use checkpoints and object Repositories in QTP for Flight Reservation application please tell me the steps for this its urgent pls thanx for urs answers

1828


i need qtp tutorial. pls send it to sridhar.k151@g mail.com

1861


how will load the object during runtime?

1806


Pls can anyone give me the entire code for the Keyword driven framework with respect to he Flight Reservation Window in detail with explanation. Pls explain in detail stepwise. Thanks a lot. Pls very urgent?.

1759


what is object and child object.. explain ..if possible give some example for better understanding ..

1745


Object repositories types, which and when to use?

822


What is difference between Recording time object identification and Run time (Execution) time.

1253


How to integrate the qualitycenter with qtp

1985


Hi, I have 2 dropdown listboxes called region and city/area. It needs to select one region(Santa Clara) and one city/Area (Sunnyvale).So I put this in the for loop and I am storing the Items in the variable called itemname. The regions value will get changed,so I used reg expression for this regions. This is my code Browser("MLSListings.com").Page("MLSListings.com").Link("» County/Area").Click Browser("MLSListings.com").Page("MLSListings.com").WebList ("regions").Check CheckPoint("regions") ListSize=Browser("MLSListings.com").Page ("MLSListings.com").WebList("regions").GetTOProperty("items count") For i = 1 To ListSize-1 Itemname =Browser("MLSListings.com").Page ("MLSListings.com").WebList("regions").GetItem(i+1) Browser("MLSListings.com").Page("MLSListings.com").WebList ("regions").Select Itemname ................. If I run the script,I am getting the following error, Cannot identify the specified item of the regions object. Confirm that the specified item is included in the object's item collection. Any Help? Thank you, Uma

1543


How to find the name of the machine where you are running your automation scripts in qtp?

762


How the exception handling can be done using quicktest professional (qtp)?

759


What are the features of quick test pro(qtp)?

727