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 |
Apart from VB script What are the fundamental criteria to gain the knowledge to write QTP script without OR and recording ?
Please explain me i am using QTP 9.5 ,i am creating re usable scripts,i have to pass data from one local sheet to another local sheet.for example i am creating emploee information, (data is in action 2 local sheet),In this data table emplyeee number will get,i have to pass employee number to another reusable script search data (action2 local data sheet)
What are the recording modes in wave event?
Up to how much VB scripting knowledge and what type of VB script knowledge is required for a QTP test engineer for real time to work ?
how to capture the run time values of web table.
What is the quicktest professional testing process?
How qtp identifies objects?
hai,i want to select an option from the right click pop up menu.but the qtp is not recognizing the right click pop up menu as a seperate object.can any one tell me the solution.
If some requirements r changed during the testing process ,then how can u handle this in frame work?
how to retreive the xml file data through qtp.can anybody send script for this..
write a qtp script to verify that the business price is twice the economy price in flight reservation window
How to Compare two database tables by using QTP?Please give me code details.