Friday, July 25, 2008

Code for how to handle the nested tables

I have nested tables used to format some pages. Trouble is that deep down in there, there is an image on which I need to click. So, how to get there dynamically? search the tables and find the particular thing for which I am looking, be it a string, or an object of some sort.


Set oDesc = Description.Create()
oDesc("html tag").Value = "TABLE"

Set oChild = Browser("Browser").Page("Page").ChildObjects(oDesc)
iTableCount = oChild.Count

Msgbox "We have " & iTableCount &" tables"

For lCount = 0 to iTableCount - 1 'Zero-based
For lRowCount = 1 to oChild(lCount).RowCount
'Msgbox "Table " & CStr(lCount) & " has " & oChild(lCount).RowCount & " rows and " & Cstr(oChild(lCount).ColumnCount(lRowCount + 1)) & " columns."
For lColumnCount = 1 to oChild(lCount).ColumnCount(lRowCount)
Msgbox "Current Cell: " & lRowCount & "," & lColumnCount
Msgbox "CellData: " & oChild(lCount).GetCellData(lRowCount , lColumnCount)

Next

Next
Next
oChild(0).ChildItem(2,2,"Image",0).Click

Set oChild = Nothing

Set oDesc = Nothing


We are using the Descriptive programming to get at our array of tables. Some interesting notes:

1) The tables array is zero-based

2) The rows/columns seem to be collections, and are therefore 1 based

3) The two tables in my example HTML are nested, but both show up in the tables array. I find this interesting, but very useful. Since it works that way, I don't have to loop a table's row/column combination to determine if a particular cell contains a nested table. Allows for a much more dynamic way to get at certain information.


Regards,

Pavankumar Nandagiri...........



Google Search

Google