How to test UIImageView elements in iOS XCTest?

I am trying to test my user interfaces using XCTest UI testing and have problems testing UIImageViewsI in my application (impact tests, presence tests, etc.).

There is no such type in the XCUIElementType list, and when I look at the children of the supervisor, my UIImageViews are not listed there for any reason, although I can see them on the screen and in the UI inspector in Xcode.

Has anyone had such a problem?

+7
source share
1 answer

Confirm the presence of the image by its accessibility tag.

Production code

let image = UIImage(named: "profile") let imageView = UIImageView(image: image) imageView.accessibilityLabel = "Your profile image" 

UI Test Code

 let app = XCUIApplication() XCTAssert(app.images["Your profile image"].exists) 
+14
source

All Articles