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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / lkiran

Hi Rnashok,

I used similar function in my script.But getting syntax
error when I try to run the script.Let me know how to solve
it.Herez my function.....

Function eTimeSummary(hours)

rowCount = Browser("XYZ").Page("XYZ_8").WebTable
("Employee #").RowCount

cellData = Browser("XYZ").Page("XYZ_8").WebTable
("Employee #").GetCellData(1,1)

If cellData <> "Commission Information is not available
for this time period" Then

For i = 2 to 2'rowCount
hoursTotal = Browser("XYZ").Page
("XYZ_8").WebTable("Employee #").GetCellData(rowCount, 6)

If Trim(hours)= Trim(hoursTotal) Then
Reporter.ReportEvent 0, "Verifying
AssociateSummaryForODhours and eTimeSummaryhours
Total", "Summary Total Passed."
'msgbox "testpassed"
Else
Reporter.ReportEvent 1, "Verifying
AssociateSummaryForODhours and eTimeSummaryhours
Total", "Summary Total Failed."
End If
Next

End If

Browser("XYZ").Back
Browser("XYZ").Page("XYZ_4").Sync
End Function

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More QTP Interview Questions

after click on compose mail how can we attached a file in qtp with vbscript code

0 Answers  


Waht is diff between SystemUtil.Run and invokeapplication

5 Answers  


Give me exact application where we should use low level recording?

6 Answers   CTS,


Hi my name is mohan. I am working as a manual tester.. And now i want learn QTP.. is there any online websites to learn QTP for free if u know any plz help me out..,.or send mail to k.mohann.mohan@gmail.com

3 Answers   Wipro,


Brief the process of testing with UFT?

0 Answers  






HOW do we find a datasheet when there are 4 datasheets in data table.this question was asked by covansys interview.

5 Answers   CTS,


what is the difference between image and bitmap check point

3 Answers  


How to capture a window in qtp or how to take snapshot of any window while writing script in qtp

3 Answers  


wt is automation framework? give explonation?

1 Answers   Mindlance,


Using Regular expression in Date format DD/MM/YYYY (0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[12])/([0-9]{4}) in this regular expression year 0000 also accepted.I need atleast any one single digit must be nonzero value (like 0009,1000,0034)

1 Answers  


How to call the userdefined functions to script? If i am stored 'add()' function in Library functions folder. i want to cal that function in my script.

4 Answers  


I would like to do some certifications in QTP. please suggese what kind of certifications can i do. I am currently put up at chennai. So please suggest some reputed centres where these courses are offered.

1 Answers  


Categories