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
Difference between test object and run time object?
Whether qtp 9.0 supports Test director8.0
How reliable are the site's Internet connections required to be? And how does that affect backup system or redundant connection requirements and testing?
How can i click on any Excel sheet's "H" column with out writing coordinates Ex:Window("Book1").WinObject("Book1").Click 498,14 I dont want to give coordinates like 498,14 Can i open "H" column by writing like Ex:Window("Book1").WinObject("Book1").Click "H" or Ex:Window("Book1").WinObject("Book1").Click "H","1" or Ex:Window("Book1").WinObject("Book1").Click H,1 If i want to click on "Sheet3" of an excel sheet, Can i open like Ex:Window("Book1").WinObject("Book1").Click "Sheet3" Please help me any one
How many types of parameters are there?
Explain the concept of object repository & how qtp recognizes objects?
in data driven testing for performing operations which method is easy from manual test data,keyword view,or from database.and why?
What are the methods of the TextStream object that are used for reading from a text file?
How you are developing the script? Using record and play back or manual?
In Remote acess server how u run a test?
What is the script for database check point, bitmapchek point, regular expression ?
Hai anyone please "Explain about Framework in QTP?"
if there is a web table of having row and colmns.a button is placed at 2nd row's 3rd column which is worked for both edit and delete..how to write script for the button to test both operation on the web table using desriptive programing.. plz help me on script wheather using getroproperty Q2)what is the command for taking valiue from a web table in qtp
What is recovery scenario manager? When you go for recovery scenario manager? Tell me one scenario were your used recovery scenario in your project?
How do you delete unwanted results in qtp?