Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 636
sebradloff Avatar asked Sep 26 '15 19:09

sebradloff


1 Answers

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.

like image 119
quellish Avatar answered Oct 23 '22 09:10

quellish