Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCTest UI testing UIElements size

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.

like image 260
Dejan Zuza Avatar asked Sep 14 '15 14:09

Dejan Zuza


1 Answers

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
like image 180
Joe Masilotti Avatar answered Sep 27 '22 20:09

Joe Masilotti