Complication interaction in XCUITest

Hi guys,

Basically, my question - Is there a way to tap on Apple Watch's complication in XCUITest?

Yes! You should be able to.

On watchOS, the SpringBoard equivalent is called Carousel.

Carousel's bundle identifier is "com.apple.Carousel"

You should be able to navigate to the watch face screen of your watchOS device (real or simulated) using a home button press https://developer.apple.com/documentation/xctest/xcuidevice/1619052-press

Then, create an instance of XCUIApplication that references Carousel https://developer.apple.com/documentation/xctest/xcuiapplication/2879415-init

let watchOS = XCUIApplication(bundleIdentifier: "com.apple.Carousel")

You can print out the accessibility tree of Carousel using the app's debug description: print(watchOS.debugDescription)

This should list all of the interactable elements on screen, including your complication if it is being used!

You can write a normal UI test from that point.

Complication interaction in XCUITest
 
 
Q