IBM Support

Capturing an attribute of an HTML table cell

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"));
      }//end of greatgrandchildren loop
    }//end of grandchildren loop
}//end of children loop

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");
}//End of testMain

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 =
          (tempProperty.equals("") ? "default" : tempProperty);
        System.out.println(tempProperty);
      }
      getCellAttributes(children[i], attribute);
    }//end of for loop
}//end of getCellAttributes

Note: the sample code provided in this document is for illustrative purposes only and is not supported.



[{"Product":{"code":"SSSHZT","label":"Rational XDE Tester"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"--","Platform":[{"code":"PF033","label":"Windows"}],"Version":"2003;2003.06.00;2003.06.01;2003.06.12","Edition":"","Line of Business":{"code":"","label":""}}]

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