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
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 |
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 |
How do we handle run-time errors?
We have an application which generates links( more than thousand) based on the time stamp dynmically.Each link will download an xls file. we are supposed to click a particular link (which link to click will be obtained thru some buisiness logic).Now the issue is QTP is not recogniging the link(say Var1) though its properties showed mandatory fields text=xyz and html tag=A.I used following code to do this. Browser("ABC").Page("123").Link("text:=" &Var1,"html tag:=A").click, can any one suggest why this is not recognised by QTP though syntax is correct?(Is there any sync issue to be considered?Because on clicking the link it will take 5 mins to open that file)
what are the settings to be done to make the recovery scenario created for one test to be used bye all the other tests. please tell me recovery scenario process in detail.
how to write xml output check point bu useing descriptive programing .means without useing output check point
Question:how many types of repositories in QTP9.2?and explain??
How can you write the scripts that operate on different objects depending on run-time information?
Is it possible to run qtp scripts in Test Director(Scripts are uploaded in Test director)???and also how to see the test results in test director???
In how many ways we can add check points to an application using QTP.
How to automate the windows dialog box which is coming in the run mode? Whenever I run my scripts,I am getting dialog box ( for ex: Pls enter zipcode" eventhough I already entered the value,the dialog box pops up).I need to click it. Pls give some idea-How to automate the dialog box which is pop up in the runtime.
How to return a value from a fn, if it has more than one value how to return
Hi All, I have QTP installed on my machine but the application under test (AUT) is on remote desktop.My scenarios is like that,it should contain following steps. 1)Automatically it should click on start and then on remote desktop connection. 2)it should enter the IP address and then connect to remote desktop. 3)and then it should be able to record the application in remote machine and then run it also. Can somebody tell me how to record the application which is in remote machine.
hi all i have qtp 9.0, Active screen is not working means after recording script snap shots not displayed in Active screen window. i have all ready check all setting means Tool...>option...>Active screen...>Default Level button is disabled. Is there other setting is remain to set Pls help i m new for qtp