XCTest UI testing UIElements size
Asked Answered
C

1

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.

Coincidentally answered 14/9, 2015 at 14:27 Comment(0)
L
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
Linwoodlinz answered 14/9, 2015 at 15:1 Comment(3)
@DejanZuza you're welcome! If this sufficiently answers your question please accept it by clicking the gray checkmark to the left. Thanks!Linwoodlinz
Hi @Joe, could i ask you to look this problem of mine. Thanks #33872864Coincidentally
@JoeMasilotti Still helps in 2017!Manstopper

© 2022 - 2024 — McMap. All rights reserved.