Peres Peres - 5 months ago 11
iOS Question

UI Automation: Access UIViews inside UIScrollView

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

UIViews
inside an
UIScrollView
? Since the
UIScrollView
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
UIScrollView
and the
UIViews
inside of it.

Thanks.

Answer

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(); 
window.logElementTree();

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

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

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

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