开发者

Can't grab my scrollView from javascript using UIAutomation

开发者 https://www.devze.com 2023-04-11 08:02 出处:网络
I can\'t seem to create a reference to my scrollView. I\'m trying to test the login page of an iOS application.

I can't seem to create a reference to my scrollView. I'm trying to test the login page of an iOS application.

The xib has a UIView that holds a UIScrollView.

I'm trying to grab the scrollView using this javascript:

target = UIATarget.localTarget();
application = target.frontMostApp();
window = application.mainWindow(); 
scrollView = window.scrollViews()[0];

Printing the objects (using UIALogger.logPass) yields:

[object UIATarget]
[object UIAApplication]
[object UIAWindow]
[object UIAElement]

window.elements() yields an array containing exactly one element. I've set the scrollViews' isAccessibilityElement to YES in the viewController's viewDidLoad.

What am I doing wrong here?

[EDIT]

application.logElementTree() yields:

2) UIAApplication [name:App value:(null) rect:{{x:0, y:20}, {width:768, height:1004}}]
3) UIAWindow [name:(null) value:(null) rect:{{x:0, y:0}, {width:768, height:1024}}]
4) UIAElement [name:(null) value:(null) rect:{{x:0, y:20}, {width:768, height:1004}}]
3) UIAWindow [name:(null) value:(null) rect:{{x:0, y:0}, {width:768, height:1024}}]
4) UIAKeyboard [name:(null) value:(null) rect:{{x:0, y:760}, {width:768, height:264}}]

This doesn't look like what's in my xib. I'm expecting the UIAElement (the root view) to hold a UIAScrollView... Running the app everythin开发者_JAVA百科g works just fine.


Trying to solve this I stumbed upon other questions, one which was answered here. Using that answer I found out that setting the isAccessibilityElement on the UIScrollView to YES somehow cut off the elementTree.

So answer is: set isAccessibilityElement to NO for the UIScrollView.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号