6

I am testing my app with XCTest in XCode.

Does someone has example how to test UIElement size? Height of cell in tableView, or height of label in tableView cell. Any example will be appreciated.

Dejan Zuza
  • 359
  • 1
  • 6
  • 14

1 Answers1

17

Use the XCUIElementAttributes protocol on XCUIElement to access the frame. This returns a standard CGRect which you can query for size and origin.

let height = app.buttons.element.frame.size.height
let width = app.buttons.element.frame.size.width
let x = app.buttons.element.frame.origin.x
let y = app.buttons.element.frame.origin.y
Joe Masilotti
  • 16,815
  • 6
  • 77
  • 87
  • @DejanZuza you're welcome! If this sufficiently answers your question please accept it by clicking the gray checkmark to the left. Thanks! – Joe Masilotti Sep 15 '15 at 10:21
  • Hi @Joe, could i ask you to look this problem of mine. Thanks http://stackoverflow.com/questions/33872364/uitesting-xctest-current-viewcontroller-class – Dejan Zuza Nov 23 '15 at 13:36
  • @JoeMasilotti Still helps in 2017! – ShaneG Dec 15 '17 at 17:17