Question

I'm working under test automation for some app and faced with issue that i cannot manage Alert at the start of app. When my app starts i get alert - "Would Like to Use Your Current Location" with Don't Allow and OK buttons. I tried the following code:

UIATarget.onAlert = function onAlert(alert){
    return false; // use default handler
}

Also i tried the following thing:

UIATarget.onAlert = function onAlert(alert) {
        alert.buttons()["OK"].tap();
        return true;
}

But it doesn't lead to expected result: Could not start script, target application is not frontmost.

So, i need help. I see 2 solutions: first it's handle this alert in someway, maybe someone know how? second way, it's use some script and set permissions for my app in Simulator Settings but i also don't have any idea how i can realize that.

Thanks everybody who try to answer!!

This solution is great for me:

tell application "iPhone Simulator"
    activate
end tell

tell application "System Events"
    tell process "iPhone Simulator"
        click button "OK" of window 1
    end tell
end tell

Preconditions: Turn On on your Mac: System Preferences > Accessibility > Enable access for assistive devices

Thanks a lot Shaun for help!

Was it helpful?

Solution

This alert provide by system (Apple iOS) so, you are not able to handle it or can not do any changes with it so best way is stop fighting with it :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top