How to handle native iOS Alerts in Appium using Java

I try to write tests for an app, which shows iOS native alert for Location (This app would like to use your current location). I tried this code

driver.switchTo().alert.accept();

This actually works for other alerts, but not for native ones.

  • Send notification to all the devices connected to a Wi-Fi network
  • Connect with iOS and Android clients to SockJS Backend
  • Analog Java's Netty in Obj-C
  • “Add unimplemented methods” in Xcode like in Eclipse
  • Equivalent in Objective c of BeanUtils.copyProperties.
  • Cannot swipe on appium iOS test
  • Also I noticed, that since 2nd time I run a test(even there is nothing but an sysout), it fails because of SessionNotCreatedException, but if I remove that alert from app, everything is ok.

    I use Appium 1.3.4.
    Thanks in advance.

    Solutions Collect From Internet About “How to handle native iOS Alerts in Appium using Java”

    Try adding to your Desired Capabilities ("autoAcceptAlerts",true).
    It doesn’t work perfectly but you should try it.

    You can also try doing:

    driver.findElement(By.name("OK")).click();
    

    Hope this helps.