4

I'm looking for a way to test if an XCUIElement is hidden in Swift 2 XCTestCase UI Tests. It was not working on Xcode 7, so I updated to Xcode 7.1 and it still does not work.

I've tried referring to this post with no luck: Testing if an element is visible with XCode 7 UITest

I'm using a (static) table view with different controls inside cells, that sometimes get set to hidden, most importantly a few UILabels. I have had no luck using hittable to test if any of the controls are hidden or not. It seems to always return true, unless the control started off hidden (through storyboard, and was never updated), then it appears the control doesn't even exist… I'm guessing this has something to do with the way cells and their contentView's are generated and maybe it's buggy or not working, I'm not really sure.

Any help would be greatly appreciated.

Community
  • 1
  • 1
Alex
  • 3,861
  • 5
  • 28
  • 44

1 Answers1

0

Can you share some code and screenshot of your storyboard.

But in general, you should try to check existence first, then you can check for hittable items since iOS will load cells in advance to help on performance.

Like:

 if (page.promoCell.exists) {
     return page.promoCell.isHittable
 } else {
     return false
 }
Farshad Sheykhi
  • 92
  • 1
  • 10