import io.appium.java_client.AppiumDriver;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.Alert;
import org.openqa.selenium.remote.DesiredCapabilities;
public class alert_learning {
public static void main(String[] args) throws MalformedURLException, InterruptedException {
// TODO Auto-generated method stub
DesiredCapabilities capabilities= new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Iphone");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "ios");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.3.5");
capabilities.setCapability("udid", "499ae5ae6d066971991c5d27e8fbff07899a489d");
capabilities.setCapability("bundleId", "com.example.apple-samplecode.UICatalog");
AppiumDriver driver= new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
Thread.sleep(8000);
//**********************************************
driver.scrollTo("Alert Views").click();
Thread.sleep(3000);
driver.findElementByXPath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]"
+ "/UIATableCell[1]/UIAStaticText[1]").click();
Thread.sleep(5000);
Alert alert = driver.switchTo().alert();
alert.accept();
driver.findElementByXPath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]"
+ "/UIATableCell[2]/UIAStaticText[1]").click();
Alert alert2 = driver.switchTo().alert();
alert2.dismiss();
}
}