I am testing an iOS Application and currently I am checking the existence of a particular XCUIElement
using isHittable
.
I wanted to know if we can also check the position of the XCUIElement on the view. For instance, if we have a button in the bottom right corner of the view, can we check if it is actually in the bottom right corner using XCTest framework?
I had a look at the Apple Documentation for XCTest framework but did not get any clue. Any help will be greatly appreciated.
XCUIElement
has a propertyframe
which you can use to find the coordinates of the element in question.There are other ways of retrieving different points relative to the frame, which is a
CGRect
, such asmidX
andmidY
, depending on how you want to assert the position of the element.You should be aware that XCTest is a functional UI testing framework, and if you are using it for asserting the position of an element, the position will probably be different per device/simulator which may make your tests brittle.