new AndCriteria(new TypeCriteria(UIAStaticText.class), new NameCriteria("Show Simple"));
UIAElement el = driver.findElements(c).get(1);
// opens an alert.
el.tap();
UIAAlert alert = driver.findElement(new TypeCriteria(UIAAlert.class));
// check the alert has all its elements
alert.findElement(UIAStaticText.class, new NameCriteria("UIAlertView"));
alert.findElement(UIAStaticText.class, new NameCriteria("<Alert message>"));
String version = driver.getCapabilities().getSDKVersion();
IOSVersion v = new IOSVersion(version);
Class type;
if (v.isGreaterOrEqualTo("7")) {
type = UIATableCell.class;
} else {
type = UIAButton.class;
}
UIAElement ok = alert.findElement(type, new NameCriteria("OK"));
ok.tap();
// wait for the alert to disappear.
Thread.sleep(500);
driver.switchTo().alert();