Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAutomation: Any way to dismiss "Would Like To Use Your Current Location" alert?

my app is using location services, and for automated testing, I want to be able to dismiss the "APP Would Like To Use Your Current Location" popup. However, when I try to do this in Instruments with a UIAutomation script, I get this error:

Fail: Could not start script, target application is not frontmost.

This kind of makes sense, because the alert is produced by a different process. But still, what is Apple's plan for helping people automate their tests in this situation?

like image 770
Asking One Avatar asked Mar 26 '13 18:03

Asking One


1 Answers

**Try**

UIATarget.onAlert = function onAlert(alert)
        {
        return true;
        }
alertTitle = target.frontMostApp().alert().name();
if(alertTitle==="APP Would Like To Use Your Current Location")
{
target.frontMostApp().alert().buttons()["OK"].tap();
}
like image 72
Sanjay Avatar answered Nov 18 '22 23:11

Sanjay