Troubleshooting
Problem
The value of an HTML table cell attribute cannot be captured while recording because IBM Rational XDE Tester only recognizes the HTML table as a whole, but not the individual table cells
Cause
XDE Tester only recognizes (highlights) mappable objects and an HTML table cell is not a mappable object
Resolving The Problem
Use the getChildren method.
When run on an object, the getChildren method returns an array of objects that are the children of that object. These child objects may or may not be mappable objects.
From XDE Tester's perspective, HTML table cells may not be the immediate children of an HTML table. The table cells may be seen as the children of a table row object, which is seen as the child of the table body object, which in turn is the immediate child of the HTML table. Therefore, the getChildren method may need to be run on the object's children, grandchildren, etc. to retrieve the HTML table cell objects.
Once the table cell objects are retrieved, the getProperty method can be run to find the value of the attribute in question, for example
TestObject[] children = Table_MyTable().getChildren();
for(int i=0;i<children.length;i++)
{
- System.out.println(children[i].getObjectClassName());
TestObject[] grandchildren = children[i].getChildren();
- for(int j=0;j<grandchildren.length; j++)
{
- System.out.print(" ");
System.out.println(grandchildren[j].getObjectClassName());
TestObject[] ggc = grandchildren[j].getChildren();
- for(int k=0;k<ggc.length; k++)
{
- System.out.print(" ");
System.out.print(ggc[k].getObjectClassName());
System.out.print(" - Table Cell Alignment: ");
System.out.println(ggc[k].getProperty("align"));
To see what list of cell attributes that can be retrieved by XDE Tester, use the getProperties method on the table cell object.
Alternatively, a recursive function could be written that iterates through the object hierarchy within the HTML table until the table cells are reached, for example
public void testMain (Object[] args)
{
- getCellAttributes(Table_MyTable(), "align");
public void getCellAttributes(TestObject to, String attribute)
{
- TestObject[] children = to.getChildren();
int childCount = ( children != null ? children.length : 0 );
for ( int i = 0; i < childCount; i++ )
{
- if (children[i].getObjectClassName().equals("Html.TD"))
{
- String tempProperty =
- children[i].getProperty(attribute).toString();
- (tempProperty.equals("") ? "default" : tempProperty);
getCellAttributes(children[i], attribute);
Note: the sample code provided in this document is for illustrative purposes only and is not supported.
Was this topic helpful?
Document Information
More support for:
Rational XDE Tester
Software version:
2003, 2003.06.00, 2003.06.01, 2003.06.12
Operating system(s):
Windows
Document number:
76801
Modified date:
16 June 2018
UID
swg21173179