Running a UIAutomation script in many poppies?

I can create and play the following script very well in Mac I Use.

  var target = UIATarget.localTarget();

  UIATarget.localTarget().delay(15);

  target.frontMostApp().mainWindow().tableViews()[0].textFields()[0].tap();

When I run the above script in another mac, it shows an error in the third line. after changing the above script of the third line, as shown below, it reproduces perfectly.

  target.frontMostApp().mainWindow().tableViews()[1].textFields()[0].tap();

I just changed the index of the table from 0 to 1. How can I achieve this on multiple Macs? Both macs have the same xcode version (xcode 5) and the simulator version (6.1) and the mac version. Why do the tools use the scripting API differently in different macs?

+4
source share
1 answer

AX ( / / ..). UIAElementArray UIAutomation. , .

:

var mainWindow = UIATarget.localTarget().frontMostApp().mainWindow();
var tableViews = mainWindow.tableViews();
tableViews['TableView'].textFields()[0].tap();

var mainWindow = UIATarget.localTarget().frontMostApp().mainWindow();
var tableViews = mainWindow.tableViews();
tableViews['TableView'].textFields.withName("TextFieldName")[0].tap();

, . , " ":

var mainWindow = UIATarget.localTarget().frontMostApp().mainWindow();
var tableViews = mainWindow.tableViews();
if (tableViews[0].cells().firstWithName("Cell name")) {
    tableViews[0].textFields()[0].tap();
} else if (tableViews[1].cells().firstWithName("Cell name")) {
    tableViews[1].textFields()[0].tap();
}

View, , SO UIACollectionView vs visibleCells , . , , .

+1

All Articles