0

I try UI Testing on xcode 7 beta.

After an XCUIElement dismissed, its .exists property still remains YES.

e.g.

XCUIElement *button = app.sheets[@"Sample sheet"].buttons[@"Sample button"];
[button tap]; // Tapping will dismiss UIActionSheet and its button will no longer exist.
XCTAssertFalse(button.exists); // -> Error here.

Is there any way to detect an XCUIElement not exists after being dismissed?

a developer
  • 149
  • 2
  • 10

3 Answers3

2

XCUIElement has an exists method which returns BOOL.

In your code:

if (button.exists) {
   [button tap];
}
Matt Hudson
  • 7,329
  • 5
  • 49
  • 66
1

Best way is to check an XCUIElement exists and hitable or not before fire a tap event

In your code:

if (button.exists && button.isHitable) {
   [button tap];
}
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256
0

You can check for app.sheets.count

M.Y.
  • 1,105
  • 1
  • 11
  • 30