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

How can you pass value one action to another action?

0 Answers  


how to capture the run time values of web table.

3 Answers   CTS,


What is meant by Pseudo Code?

5 Answers   Satyam,


Hi Frriends... I have one Query please give the apropriate ans. when we r working with web based application , the user loggedin page name is changed respect to the username ( Take a exp. Yahoomail.com) .When we use Datadriven test to this scenario ,each time the loggedin page name is changed ...then the script is fail.. at that time wat can do... please give the apropriate ans. Thanx in advance..

3 Answers  


Hello everyone, I am trying to parametrize a script. Its clear to me that, we use data table to enter various text data. but if I want to change the radiobutton (e.g. if for first iteration I selected radio button 'A' and for second iteration I want to use 'B' radio button for second iteration) then how can I make it happen. I have tried to define the question but still if not clear plz tell me. Thanks everyone

1 Answers  






can we call runaction in the funcion

1 Answers  


How to get the particular property value?

0 Answers  


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

0 Answers  


Hi Small doubt . i am working as Contract employee in XYZ comany thrw ABC Consultancy. so. How i write my resume ? In Professional experience Column. plz send urgent

2 Answers  


What are the different types of action?

0 Answers  


I register user defined function in one test, I tried to call that function into other test. But that function not works in other test please give the direction for that.

1 Answers  


UFT 12.02 which ALM version will support

0 Answers  


Categories