I want to write UI tests for views inside a UIStackView
thats inside a MKMapView
.
Here's a snippet of the MWE. I created a MKMapView
added a UIStackView
with two UIView
s as subviews.
let map = MKMapView()
let view1 = UIView()
let view2 = UIView()
let stackView = UIStackView()
stackView.addArrangedSubview(view1)
stackView.addArrangedSubview(view2)
map.addSubview(stackView)
view.addSubview(map)
And I declared an accessibilityIdentifier
for each element and set the isAccessibilityElement
attribute to true.
view1.accessibilityIdentifier = "view1"
view2.accessibilityIdentifier = "view2"
stackView.accessibilityIdentifier = "stackView"
view1.isAccessibilityElement = true
view2.isAccessibilityElement = true
stackView.isAccessibilityElement = true
However, there are no subviews of the stack view visible in the app element subtree nor are they accessible.
You can see the UIStackView
with the identifier 'stackView' but not the UIViews
.
Element subtree:
→Application, 0x6000030080e0, pid: 11856, label: 'UITestWithStackView'
Window (Main), 0x600003009500, {{0.0, 0.0}, {414.0, 896.0}}
Other, 0x600003009420, {{0.0, 0.0}, {414.0, 896.0}}
Other, 0x600003009340, {{0.0, 0.0}, {414.0, 896.0}}
Other, 0x600003009260, {{0.0, 0.0}, {414.0, 896.0}}
Other, 0x600003009180, {{0.0, 0.0}, {414.0, 896.0}}
Other, 0x6000030090a0, {{7.0, 348.0}, {400.0, 200.0}}, identifier: 'stackView'
Other, 0x600003008fc0, {{0.0, 0.0}, {414.0, 896.0}}
Map, 0x600003008ee0, {{0.0, 0.0}, {414.0, 896.0}}
Other, 0x600003008e00, {{0.0, 0.0}, {414.0, 896.0}}
Link, 0x600003008d20, {{375.4, 841.3}, {28.6, 10.7}}, label: 'Legal'
Window, 0x600003008c40, {{0.0, 0.0}, {414.0, 896.0}}
Other, 0x600003008b60, {{0.0, 0.0}, {414.0, 896.0}}
Other, 0x600003008a80, {{0.0, 0.0}, {414.0, 896.0}}
Are there any known workarounds for this behavior?