Search code examples
iosobjective-cuiimagepickercontrollerui-automationios-ui-automation

UIImagePickerController when editing: buttons()[2] could not be tapped


In the crop screen from UIImagePickerController I'm trying to tap the "Choose" button using UIAutomation, but I got this error:

target.frontMostApp().mainWindow().buttons()[2] could not be tapped

I'm using this code:

var b = target.frontMostApp().mainWindow().buttons()[2];

if (b.checkIsValid()) {
    UIALogger.logPass("b, " + b.isValid() + ", " + b.isEnabled());
    b.logElement();
    b.tap();
} else {
    UIALogger.logFail("!b");
}

And this is the output:

b, true, 1

UIAButton: name:Choose rect:{{287, 604}, {74, 40}}

target.frontMostApp().mainWindow().buttons()[2].tap()

target.frontMostApp().mainWindow().buttons()[2] could not be tapped

Script threw an uncaught JavaScript error: target.frontMostApp().mainWindow().buttons()[2] could not be tapped on line 13 of New%20Script

Somebody knows how to test this?. Thanks for any help.


Solution

  • I was also stuck with this very same problem and I found this solution:

    var b = target.frontMostApp().mainWindow().buttons()[2];
    var x = b.rect().origin.x + 1;
    var y = b.rect().origin.y + 1;
    target.tap({x:x, y:y});
    

    It's not very nice, but it works...