iOS 11.0 solution using advanced gesture mobile: alert
https://appium.readthedocs.io/en/stable/en/writing-running-appium/ios-xctest-mobile-gestures/
But first check need to be optimized, as it’s quite slow because of xpath, any solution for this check ?
if(getDriver().findElements(By.xpath("//XCUIElementTypeAlert[contains(@name,'access your location while you are using the app')]")).size() ) {
JavascriptExecutor js = (JavascriptExecutor) getDriver();
HashMap<String, String> tapObject = new HashMap<String, String>();
tapObject.put("action", "accept");
tapObject.put("label", "Allow");
js.executeScript("mobile:alert", tapObject);
}