3

This code used to work well in Automation test with Instruments 4.6:

UIATarget.onAlert = function onAlert(alert) {
    var title = alert.name();
    UIALogger.logWarning("Alert with title ’" + title + "’ encountered!");

    return false; // use default handler
}

I've upgraded to XCode 5.0 and this code doesn't work anymore. There is no reaction to alerts -- onAlert is never called.

Am I missing something or this is really broken by Apple?

Display Name
  • 4,502
  • 2
  • 47
  • 63
Biga
  • 531
  • 4
  • 9
  • Are you running it under iOS 7? Perhaps it's related to the OS version rather than the XCode's. – Display Name Oct 03 '13 at 14:22
  • This use to work. Apple broke it in iOS 7. Alas, we have to file a bug report. – Jonathan Penn Oct 03 '13 at 20:44
  • This probably may be related to iOS 7. Instruments automatically starts iOS 7 sumulator. By the way, is there any way to tell Instruments which simulator to run? – Biga Oct 04 '13 at 07:52
  • Change the hardware, this will be started next time until you change again. – Display Name Oct 04 '13 at 11:44
  • Nope, it always changes hardware to 'iPhone'. I'm running a universal app. With XCode 4.6 I used `defaults write com.apple.iphonesimulator 'SimulateDevice' iPad` to set up the Simulator, but it doesn't work for XCode 5. – Biga Oct 18 '13 at 07:33

2 Answers2

1

Add a delay in. I had this same issue, and adding UIATarget.localTarget().delay(5); above fixed it. It seems, even though Apple does not recommend using the delay() function, I need it more and more, as elements can take a few seconds to show up. The alert was taking a while to appear and the script just went right over the onAlert.

Siriss
  • 3,737
  • 4
  • 32
  • 65
1

I put a UIATarget.delay(0.2) call immediately after the button tap invoke. It worked for me!

djserva
  • 395
  • 1
  • 11