How to identify the class of an Object which is in a cell of webtable

2.8k views Asked by At

I have a webtable which MIGHT have a weblink object in it's Row 2, Column 1 cell (also Index of this object is 0). If it indeed is a link I would like to click it else ignore it. Is there a way to identify the class of this object given that we know the row and column number.

Below was my initial code. However it doesn't work always when the webtable cell doesn't have a link to click

Set Table = Browser("Oracle PeopleSoft").Page("Request Payment Predictor").WebTable("Run Control ID").ChildItem(2, 1, "Link", 0)
Table.Click

I would like to know if there a way to find the class of the Object (in cell of a web table) so I can click on the Object only if it's a link Or in other words can we use GetRoProperty("Class Name") on a WebTable Cell Object?

1

There are 1 answers

2
Motti On BEST ANSWER

The ChildItem function returns a test object of the requested type if it exists, otherwise it returns Nothing.

So your code should look like this:

Set aLink = Browser("Oracle PeopleSoft")_
             .Page("Request Payment Predictor")_
               .WebTable("Run Control ID").ChildItem(2, 1, "Link", 0)

If Not aLink is Nothing Then
    aLink.Click
End If

The object returned by ChildItem is a test object (if it's not Nothing) so you can use the regular test object methods on it.

Please note that the object returned is not a table cell object, it's the object of the type you requested, this type may be WebElement which is considered the base class of all web objects. This means that you can use ChildItem with "WebElement" and then see what actual type it is by getting its micClass (which is what the Class Name is called internally).

Print webElem.GetROProperty("micclass")

Pro tip: The indexes are 1 based, you can use the undocumented Highlight function in order to make sure you're working on the right object (obj.Highlight).