UIAutomation Instrument Exception "Target app is not frontmost"

I have an application for the iPad iOS5 that is using CLLocationManager, which I am testing with UIAutomation.

Before running my test script, I manually click OK in the dialog box that iOS represents when I use CLLocationManager.

Sometimes my test scripts do not run. I click the Play icon in Instrumentsand nothing happens for 12 seconds. Then I get the following exception:

Target app is not frontmost

As soon as this happens, I usually have to restart in order for the tools to work again.

I used the same exception when I left the dialog box CLLocationManagerin front of my application. Does anyone know how to fix this?

+5
source share
2 answers
    //Handling Externally Generated Alerts
UIATarget.onAlert = function onAlert(alert) {
    var title = alert.name();
    UIALogger.logWarning("Alert with title ’" + title + "’ encountered!");
    if (title == "Add Something") {
        alert.buttons()["Add"].tap();
        return true; // bypass default handler
    }
    return false; // use default handler
}

Use this code to handle location alert 
+2
source

This occurs when a pop-up warning appears before the application completes the launch completely. This is an error with automation.

+1
source

All Articles