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
Is QTP Supports SWT applications? If yes, can you write a sample script for opening a new package in eclipse.
i have to login into gmail loginpage i have to pass testcase into userid and password by using functions. the test case of user id is it should take only lowerletters alphabetin between 4 to 6 length.it should not take spectial letters.it should not take numbers.testcase for password is it should take numbers and it should not take alphabets note the following things must happen 1 when i give correct password and userid that password and userid should be seen in QTP result and notepad,xl sheet 2 when i gave in valid password the system willgive message please give valid password that particular messaage should be seen in QTP result,norepa and xl sheet
Without integrating QC/Testdirector with QTP, is it possible to keep track of the defects?If yes how? How to export QTP results to an excel sheet?
Which HTML specification will be adhered to? How strictly? What variations will be allowed for targeted browsers?
Can we record an application running on a remote machine using qtp?
What is the new version of qtp which is recently released in the market?
What is throw Object?
What is difference between design time and run time data table?
Hi this is chandra if any one have Navigation of LAB QTP, I want Navigation of those tools, if any one have the and know the Navigation each and every part of the QTP, plz send me my mail naruboinac@yahoo. com,naruboinas@ gmail.com
How to associate function library at a run time?
Is virtual object supported in low level recording mode?
Limitations in QTP?
Explain how Does Run time data (Parameterization) is handled in QTP?
Call to copy of an action and call to existing action… i know the diff but in real project how to use..? i want live scenario.pls help me..
How can I use Call dlls in QTP ?