views:

126

answers:

0

I am trying to use UIAutomation in Instruments with the iPhone Simulator and the latest iOS SDK 4.1. Here is the snippet of javascript that is having a problem:

// there are sufficient delays here to make sure the view is loaded
UIATarget.localTarget().frontMostApp().logElementTree();
main.buttons()["theButton"].tap();
UIALogger.logMessage("The button tapped");
for (var b = 0; b < main.buttons().length; b++)
{
    UIALogger.logMessage("Button title: " + main.buttons()[b].name());
}
main.toolbar().buttons()["OK"].tap();
UIALogger.logMessage("OK tapped");

The button name of "theButton" shows up in the logElementTree as well as showing up when I am logging the names of all the buttons, so it is correctly configured in the Interface Builder, but for some reason, it does not get tapped. I have other buttons earlier in the script that are getting tapped just fine, and if I abort the script at the point of the non-tapped button, I can click on the button in the Simulator and it works as expected.

EDIT: In the javascript for loop shown above, I had it tap each of the buttons in the main.buttons() array, and only 1 of the 12 identical buttons on the view gets the tap.

Also, in case you were wondering, I have this code at the top of the javascript file:

var target = UIATarget.localTarget();
var app = target.frontMostApp();
var main = app.mainWindow();

And here is the line that shows the button information from the sequence of entries that logElementTree puts into the log messages:

4) UIAButton [name:theButton value:(null) NSRect: {{25, 93}, {74, 74}}]