Peres Peres - 1 year ago 50
iOS Question

UI Automation: Access UIViews inside UIScrollView

Is there a way to access, using JavaScript with UI Automation tests, the

inside an
? Since the
doesn't give me away to set if it has accessibility or not, I would like to know if it is possible to do that.

The structure in the XIB:

enter image description here

I can see everything on the instrument's log, except the
and the
inside of it.


Answer Source

I was able to access the interior of my Scroll View. What I was doing wrong:

  • Setting accessibility to my root view.
  • Setting accessibility to my Adjusted view.

After removing that, I was able my doing this:

var window = UIATarget.localTarget().frontMostApp().mainWindow(); 

To see all the UIViews inside my UIScrollView. To access one of the buttons:

 var scrollView = window.scrollViews()[0];
 var button=scrollView.buttons()["showMeStuff"];

PS: Is also possible to define the accessibility of an UIScrollView by doing the following:

  scrollView.isAccessibilityElement = YES;
  scrollView.accessibilityLabel = @"someScrollView";