swiftxcuitestxcuielement

Why are the child elements inheriting the parent accessibility identifier?


I have this view (and accessibility identifier):

private var carStack: some View {
    CarSwiftUIView(viewModel: viewModel.carViewModel)
        .accessibilityIdentifier("car")
        .accessibilityElement(children: .ignore)
}

If I use .ignore or .contain, the child elements within the CarSwiftUIView have the same named accessibility identifiers (car) as what's specified above.

Using .combine, I think, gives every child element the same identifier by default.

How can I make it so there's a parent accessibility identifier of car, and then within that view, I can name the child elements with different identifiers?

Thank you.


Solution

  • They were inheriting the parent's accessibilityIdentifier because they're not strictly "children". They are elements which form part of the parent's view.