In a scenario where more than one Html.Table controls are present in a web page and the recognition properties of the table controls are not enough to distinguish them individually, then the best possible method to capture the table controls are to capture the parent control first and then retrieve these table controls as a child of the parent, provided the parent control has unique recognition property values.
According to the below screenshot, Html.DIV is the parent of Html.TABLE.
While capturing the table control using the below code snippet, Rational Functional Tester (RFT) may throw the following error message:
Error=com.rational.test.ft.object.interfaces.GuiTestObject incompatible with com.rational.test.ft.object.interfaces.StatelessGuiSubitemTestObject
RootTestObject root = getRootTestObject();
TestObject[] findiv = root.find(atList(atChild(".domain","Html"),
atDescendant(".class","Html.DIV", propName1,propval)));
GuiTestObject htmldiv = (GuiTestObject) findiv[0];
TestObject[] findtable = div.getChildren();
StatelessGuiSubitemTestObject htmltable= (StatelessGuiSubitemTestObject) findtable[0];
This is because, getChildren() can retrieve all the mappable and non-mappable controls of a parent. If there are any other non-mappable controls present in between the html.DIV and Html.TABLE that can also be retrieved by getChildren().
In case RFT throws such error message, using getProperties() we can verify whether the getChildren() retrieved the intendant control.
The above stated error can be resolved by replacing getChildren() with find().
RootTestObject root = getRootTestObject();
TestObject[] findiv = root.find(atList(atChild(".domain","Html"),
atDescendant(".class","Html.DIV", propName1,propval)));
GuiTestObject htmldiv = (GuiTestObject) findiv[0];
TestObject[] findtable= htmldiv.find(atChild(".class","Html.TABLE", ".classIndex", "0"));
StatelessGuiSubitemTestObject htmltable= (StatelessGuiSubitemTestObject) findtable[0];