Micro Focus QTP (UFT) Forums
child object method?? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: child object method?? (/Thread-child-object-method)



child object method?? - wheelercha - 03-05-2010

I have a web table where all of the objects are named the same.

There are 6 col's. Date, invoice Number, Amount, Date Paid, Edit or View and Delete.

There could be many rows. I want to collect the data from the rows. Then I want to Delete a record or edit a record. So in my case GetCellData is only working for the 1st row not any of the others. I get an error The specified cell does not exist. That said, what do I use to collect the data? ChildObject Method?

Can you give me an example?

Thanks


RE: child object method?? - sreekanth chilam - 03-05-2010

Hi ,

Could you paste the code what ever you have tried?


RE: child object method?? - wheelercha - 03-05-2010

So this only returns 1 row - A

Code:
'A = Browser("Suppliers and Invoices").Page("Suppliers and Invoices").WebTable("Invoices").GetCellData(1,1)
'B = Browser("Suppliers and Invoices").Page("Suppliers and Invoices").WebTable("Invoices").GetCellData(1,2)
'C = Browser("Suppliers and Invoices").Page("Suppliers and Invoices").WebTable("Invoices").GetCellData(1,3)

'msgbox A
'msgbox B
'msgbox C


So needless to say - when I use child object method - it only finds the first row as well


Code:
Call ChildObjects_Example()

Sub ChildObjects_Example()

'The following example retrieves the collection of
'WebEdit objects in order to find a specific
'WebEdit object in a page and set a value for it.

Dim Search, ValueToSet, NumWE

'This is the value of the 'innertext' property for the WebElement object we want to find.
Search = ".*2010"

'Create a description object to help retrieve all WebEdit objects in a specific page.
Set oDesc = Description.Create()
    oDesc("micclass").Value = "WebElement"
    oDesc("class").Value = "x-grid3-row x-grid3-row-selected  x-grid3-row-over"
  
'Retrieve all WebElement objects in this page
Set EditCollection = Browser("Suppliers and Invoices").Page("Suppliers and Invoices").ChildObjects(oDesc)

NumWE = EditCollection.Count

'Search for a specific WebEdit object and set its value
For i = 0 To NumWE -1
    msgbox EditCollection(i).GetROProperty("innertext")
    If EditCollection(i).GetROProperty("innertext") = Search Then
       ValueToSet=   Browser("Suppliers and Invoices").Page("Suppliers and Invoices").WebElement("Delete").Click
      EditCollection(i).Set ValueToSet
      No = Browser("Suppliers and Invoices").Page("Suppliers and Invoices").WebButton("No").Click
      EditCollection(i).Set No
      msgbox editcollection(i)
    End If
Next
End Sub

How can I traverse threw each row to get each one?