IOS UIAutomation: access to user tabs added to UIScrollView in automation script

I am very new to iOS UIAutomation, here is the problem I am facing

I have a hierarchy of views, as shown below, and you want to access CustomView2 items in the sctipt automation section

UIWindow> UIScrollView> CustomView1 (multiple)> CustomView2 (multiple)

In scrollview there are subspecies of type CustomView1, and CustomView1, in turn, has children of type CustomView2.

I assigned accessibility information to all the views in the hierarchy, but I cannot access the CustomView2 elements in my automation script.

When I do logElementTree () in UIScrollView, all I get are instances of CustomView2, CustomView2 is not even in the UIWindow tree structure.

Please suggest if something is missing or something is wrong.

Here is the code I'm using

var mainWindow = application.mainWindow(); var scrollView = mainWindow.scrollViews()[0]; var custom1 = scrollView.elements().withName("CustomView1"); for(var index=0; index<custom1.length; index++){ currentIndustry.tap(); custom1[index].logElementTree(); var custom2 = custom1[index].elements().withName("CustomView2"); UIALogger.logPass("Custom2 Length : " + custom2.length); } 

Tree printed by custom1 [index] .logElementTree (); does not contain instances of CustomView2

PS I need to access the elements CustomView1 and CustomView2

+6
source share
1 answer

This may help you if you have not found your answer:

UIDEutomation Nested Accessibilty Elements Disappear

In your CustomView1 class, do the following:

 - (BOOL)isAccessibilityElement { return NO; } 

This will cause CustomView2 items to be visible when you execute logElementTree ().

If CustomView2 contains accessible elements and is basically a container view, then also implement the above in this class, and its child views will become available.

+5
source

Source: https://habr.com/ru/post/899686/


All Articles