UI Testing Xcode 7- can't access element within subview

10,617

The subviews are not accessible because the parent view is not a container view. From the section Making Your iOS App Accessible from the Accessibility Programming Guide:

From the perspective of accessibility, a custom view is either an individual view or a container view. An individual view does not contain any other views that need to be accessible.

A container view, on the other hand, contains other elements with which users can interact.

To make the subviews accessible the parent view should tell UIAccessibility that it is an accessibility container by returning NO from -isAccessibilityElement and implementing the methods of the UIAccessibilityContainer protocol.

Share:
10,617
sebradloff
Author by

sebradloff

Updated on June 14, 2022

Comments

  • sebradloff
    sebradloff about 2 years

    I'm trying to access an element within a subview and I'm finding it impossible to do so.

    The hierarchy being:

    View Controller:

    • View
      • tempView
      • userEnterView
        • zipCodeEntered

    I want to access the zipCodeEntered text field. I have an accessibility label on it named "zipCodeEntered".

    When I try and record the automation, it only register the superview "userEnterView" and not the actual text field which I can tap into.

    I print "app.otherElements[SUPER_VIEW_NAME].debugDescription" to see what elements are in that hierarchy and it prints none.

    Any ideas as to why I can not access these elements/how I can access them? enter image description here