Search code examples
javascriptiosios-ui-automation

Extract UIATableCell value


I am working on iOS-ui-Automation and would like to extract the UIATableCell value. The procedure is as following:

  1. check if table view exists
  2. what is in the first cell

The following code snippet of TEST.JS is used to test the App:

.
.
.
if ( target.frontMostApp().mainWindow().tableViews()[0].checkIsValid() )
{
    UIALogger.logStart("Table view recognized ...");
    target.delay(2.0);
    var TableViewInfo = target.frontMostApp().mainWindow().tableViews()[0].cells()[0]
    UIALogger.logStart(TableViewInfo);

}

In the instruments log I see the following:

UIATableView "(null)" {{99, 99}, {99, 99}}
        elements: {
            UIATableCell "xyz" {{99, 99}, {99, 99}}
            elements: {
                UIAStaticText "xyz" {{99, 99}, {99, 99}}
                UIAWebView "(null)" {{99, 99}, {99, 99}}
                elements: {
                    UIAStaticText "xyz." {{99, 99}, {99, 99}}
                }
            }

How would you read out "xyz" and log it out in TEST.JS?


Solution

  • To extract the "xyz" string from an element, you should be able to use the .name() method on it.

    In this case, it looks like that would be TableViewInfo.cells()[0].name().