Testing NSTouchBar

I am trying to get this XCTestCase code to pass:


    let touchBar = app.children(matching: .touchBar).matching(identifier: "StationsTouchBar").element
    XCTAssertTrue(touchBar.exists)


I have set the accessibilityIdentifier in Storyboard like such:


https://imgur.com/a/6J9XbEu


But the test code just can't find the touchbar with the matching identifier. Its as if setting accessibilityIdentifier on a NSTouchBar doesn't work. I can find the touchbar "globally" by just using:


    XCTAssertTrue(app.touchBars.buttons["TouchBarPlayBtn"].exists)


But that is not specific enough for my tests as the app will have many NSTouchBar's.


Any ideas on how to test NSTouchBar?

Testing NSTouchBar
 
 
Q