Search code examples
iosswiftxctestxcuitestuitest

Swift UITest cannot access presented viewController's views-buttons


When my viewController comes with segue and presented I can not access buttons inside that viewController. Printed all elements in XCUIApplication there is no buttons with my button identifier.

    self.view1Button.isAccessibilityElement = true
    self.view1Button.accessibilityIdentifier = "createHomeGroupButton"

I give identifiers and make it accessible also its make accessible view1Button.superview. But I can access the presented viewControllers.view with identifier but can not access through the buttons-labels-views etc.

Edit: Also UITest Record can not access the buttons


Solution

  • I give identifiers and make it accessible also its make accessible view1Button.superview.

    If you make the superview of the button accessible, you will not be able to see the button itself as part of the accessibility tree. The button needs to be the first and only accsssible element in its view hierarchy, so make sure all container views have isAccessibilityElement set to false.

    The first accessible element in the tree will obscure any other accessible elements that it contains.