@Test(expectedExceptions = StaleElementReferenceException.class, enabled = false)
public void staleElement() {
try {
String name = "Buttons, Various uses of UIButton";
Criteria c1 = new TypeCriteria(UIATableCell.class);
Criteria c2 = new NameCriteria(name);
Criteria c = new AndCriteria(c1, c2);
UIAElement element = driver.findElement(c);
// should work.
// new screen. The element doesn't exist anymore
element.tap();
// that doesn't throw. The element isn't visible, but it's still accessible with UIAutomation.
String s = element.getName();
Assert.fail("cannot access stale elements");
} finally {
UIAButton
but =
driver.findElement(
new AndCriteria(new NameCriteria("Back"), new TypeCriteria(UIAButton.class)));
but.tap();
}
}